@@ -38,47 +38,42 @@ secret_key = "123456789abcdef"
3838client = RedirectClient(secret_key)
3939```
4040
41- ### 2. Create a request
41+ ### 2. Set up the request parameters
4242
4343``` python
44- request = client.create_request()
44+ parameters = {
45+ " merchant_code" : " 100000001" ,
46+ " terminal" : " 1" ,
47+ " transaction_type" : STANDARD_PAYMENT ,
48+ " currency" : EUR ,
49+ " order" : " 000000001" ,
50+ " amount" : D(" 10.56489" ).quantize(D(" .01" ), ROUND_HALF_UP ),
51+ " merchant_data" : " test merchant data" ,
52+ " merchant_name" : " Example Commerce" ,
53+ " titular" : " Example Ltd." ,
54+ " product_description" : " Products of Example Commerce" ,
55+ " merchant_url" : " https://example.com/redsys/response" ,
56+ }
4557```
4658
47- ### 3. Set up the request parameters
48-
49- ``` python
50- request.merchant_code = " 100000001"
51- request.terminal = " 1"
52- request.transaction_type = STANDARD_PAYMENT
53- request.currency = EUR
54- request.order = " 000000001"
55- # The amount must be defined as decimal and pre-formatted with only two decimals
56- request.amount = D(" 10.56489" ).quantize(D(" .01" ), ROUND_HALF_UP )
57- request.merchant_data = " merchant data for tracking purpose like order_id, session_key, ..."
58- request.merchant_name = " Example Commerce"
59- request.titular = " Example Ltd."
60- request.product_description = " Products of Example Commerce"
61- request.merchant_url = " https://example.com/redsys/response"
62- ```
63-
64- ### 4. Prepare the request
59+ ### 3. Prepare the request
6560
6661This method returns a dict with the necessary post parameters that are
6762needed during the communication step.
6863
6964``` python
70- args = client.prepare_request(request )
65+ args = client.prepare_request(parameters )
7166```
7267
73- ### 5 . Communication step
68+ ### 4 . Communication step
7469
75- Redirect the _ user-agent_ to the corresponding Redsys's endpoint using
70+ Redirect the _ user-agent_ to the corresponding Redsys' endpoint using
7671the post parameters given in the previous step.
7772
7873After the payment process is finish, Redsys will respond making a
79- request to the ` merchant_url ` defined in step 3 .
74+ request to the ` merchant_url ` defined in step 2 .
8075
81- ### 6 . Create and check the response
76+ ### 5 . Create and check the response
8277
8378Create the response object using the received parameters from Redsys.
8479The method ` create_response() ` throws a ` ValueError ` in case the
@@ -94,7 +89,7 @@ if response.is_paid():
9489 # Do the corresponding actions after a successful payment
9590else :
9691 # Do the corresponding actions after a failed payment
97- raise Exception (response.response , response.message)
92+ raise Exception (response.code , response.message)
9893```
9994
10095** Methods for checking the response:**
@@ -111,8 +106,7 @@ According to the Redsys documentation:
111106 ** paid** , ** refunded** or ** canceled** .
112107
113108Also, you can directly access the code or the message defined in Redsys
114- documentation using ` response.response_code ` or
115- ` response.response_message ` .
109+ documentation using ` response.code ` or ` response.message ` .
116110
117111## Contributions
118112
0 commit comments