1
-
2
1
# ** Checkout-P2P Python Integration Library**
3
2
4
3
[ ![ pypi] ( https://img.shields.io/pypi/v/checkout-p2p.svg )] ( https://pypi.org/project/checkout-p2p/ )
@@ -59,9 +58,9 @@ checkout = Checkout({
59
58
from checkout import RedirectRequest
60
59
61
60
redirect_request = RedirectRequest(
62
- returnUrl = " https://example.com/return" ,
63
- ipAddress = " 192.168.1.1" ,
64
- userAgent = " Test User Agent" ,
61
+ return_url = " https://example.com/return" ,
62
+ ip_address = " 192.168.1.1" ,
63
+ user_agent = " Test User Agent" ,
65
64
payment = {" reference" : " TEST _q" , " description" : " Test Payment" , " amount" : {" currency" : " COP" , " total" : 10000 }}
66
65
)
67
66
@@ -73,23 +72,66 @@ print("Redirect to:", response.process_url)
73
72
3.Query a Payment Request
74
73
75
74
``` python
76
-
77
-
78
75
query_response = checkout.query(123456 ) # Replace with your request ID
79
76
80
77
print (" Request Status:" , query_response.status)
81
78
```
82
79
83
- 4.Reverse a Payment
80
+ 4 Charge using token
84
81
85
82
``` python
83
+ from checkout import CollectRequest
84
+
85
+ collect_request = CollectRequest(
86
+ return_url = " https://example.com/return" ,
87
+ ip_address = " 192.168.1.1" ,
88
+ user_agent = " Test User Agent" ,
89
+ instrument = {" token" : {" token" : " your_token_c5583922eccd6d2061c1b0592b099f04e352a894f37ae51cf1a" }},
90
+ payer = {
91
+
92
+ " name" : " Andres" ,
93
+ " surname" : " López" ,
94
+ " document" : " 111111111" ,
95
+ " documentType" : " CC" ,
96
+ " mobile" : " +573111111111"
97
+ },
98
+ payment = {
99
+ " reference" : " TEST_COllECT" ,
100
+ " description" : " Test Payment" ,
101
+ " amount" : {" currency" : " COP" , " total" : 15000 }
102
+ }
103
+ )
104
+
105
+ # Collect. Returns a `InformationResponse` object.
106
+ collect_response = checkout.collect(collect_request)
107
+
108
+ print (" Collect Status :" , collect_response.status)
109
+ ```
110
+
111
+ 5.Reverse a Payment
86
112
113
+ ``` python
87
114
# Reverse a transaction. Returns a `ReverseResponse` object.
88
115
reverse_response = checkout.reverse(" internal_reference" )
89
116
90
117
print (" Reverse Status:" , reverse_response.status)
91
118
```
92
119
120
+ 6.Invalidate token
121
+
122
+ ``` python
123
+ invalidate_token_request = {
124
+ " locale" : " en_US" ,
125
+ " instrument" : {" token" : {" token" : " your_token_c5583922eccd6d2061c1b0592b099f04e352a894f37ae51cf1a" }}
126
+ }
127
+
128
+ # invalite token. Returns a `Status` object.
129
+ invalidate_response = checkout.invalidate_token(invalidate_token_request)
130
+
131
+ print (" Invalidate Status:" , invalidate_response.status)
132
+ print (" Message:" , invalidate_response.message)
133
+ ```
134
+
93
135
## ** License**
94
136
95
137
This project is licensed under the MIT License. See the [ LICENSE] ( LICENSE.txt ) file for details.
0 commit comments