Skip to content

Commit cdd26ab

Browse files
author
Oleg Gorbik
committed
Add possibility to use custom return URL
1 parent 3bbcea3 commit cdd26ab

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ This `README` provide introduction to the library usage.
4444
- Verify 3-D Secure enrollment
4545
- Complete card verification
4646

47+
- Tokenization
48+
- Create payment data token
49+
4750
#### Basic usage
4851
You can find several examples realisation in examples folder:
4952
[ExampleScripts](https://github.com/TransactPRO/gw3-python-client/blob/master/examples/)

gateway/builders/merchant_order_builder.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,19 @@ def add_custom_3d_return_url(self, custom_3d_return_url=None):
187187
self.__req_params.GENERAL_DATA_ORDER_DATA_CUSTOM_3D_RETURN_URL: custom_3d_return_url
188188
}
189189
)
190+
191+
def add_custom_return_url(self, custom_return_url=None):
192+
"""
193+
Add custom return url
194+
195+
Args:
196+
custom_return_url (str): custom return url
197+
"""
198+
self.__data_structure_util.add_to_dict(
199+
source_dict=self.__general_data_set[self.__GENERAL_DATA_KEY],
200+
working_dict=self.__order_data_structure,
201+
new_key=self.__ORDER_DATA_KEY,
202+
new_dict={
203+
self.__req_params.GENERAL_DATA_ORDER_DATA_CUSTOM_RETURN_URL: custom_return_url
204+
}
205+
)

gateway/data_sets/request_parameters.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class RequestParameters:
6969
GENERAL_DATA_ORDER_DATA_RECIPIENT_NAME = 'recipient-name'
7070
GENERAL_DATA_ORDER_DATA_MERCHANT_REFERRING_NAME = 'merchant-referring-name'
7171
GENERAL_DATA_ORDER_DATA_CUSTOM_3D_RETURN_URL = 'custom-3d-return-url'
72+
GENERAL_DATA_ORDER_DATA_CUSTOM_RETURN_URL = 'custom-return-url'
7273

7374
# Payment data sets
7475
PAYMENT_METHOD_DATA_PAN = 'pan'
@@ -136,6 +137,7 @@ class RequestParametersTypes(RequestParameters):
136137
GENERAL_DATA_ORDER_DATA_RECIPIENT_NAME = str
137138
GENERAL_DATA_ORDER_DATA_MERCHANT_REFERRING_NAME = str
138139
GENERAL_DATA_ORDER_DATA_CUSTOM_3D_RETURN_URL = str
140+
GENERAL_DATA_ORDER_DATA_CUSTOM_RETURN_URL = str
139141

140142
# Payment data sets
141143
PAYMENT_METHOD_DATA_PAN = str

tests/builders/test_merchant_order_builder.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ def test_build_with_add_custom_3d_return_url(self):
110110
new.add_custom_3d_return_url('Lorem Ipsum is simply dummy text.')
111111
mock.assert_called_once_with('Lorem Ipsum is simply dummy text.')
112112

113+
def test_build_with_add_custom_return_url(self):
114+
"""Will succeed"""
115+
new = self.BUILDER
116+
with patch.object(new, 'add_custom_return_url') as mock:
117+
new.add_custom_return_url('Lorem Ipsum is simply dummy text.')
118+
mock.assert_called_once_with('Lorem Ipsum is simply dummy text.')
119+
113120
def test_merchant_data_structure_build(self):
114121
valid_data_structure = {
115122
'general-data': {
@@ -121,6 +128,7 @@ def test_merchant_data_structure_build(self):
121128
'recipient-name': 'Jone Doe',
122129
'merchant-referring-name': 'REF NAME',
123130
'custom-3d-return-url': 'https://example.com',
131+
'custom-return-url': 'https://another-example.com',
124132
'order-meta': {
125133
'url': 'nice.example.com',
126134
'sequence': '0',
@@ -140,6 +148,7 @@ def test_merchant_data_structure_build(self):
140148
new.add_recipient_name('Jone Doe')
141149
new.add_merchant_referring_name('REF NAME')
142150
new.add_custom_3d_return_url('https://example.com')
151+
new.add_custom_return_url('https://another-example.com')
143152
new.add_merchant_order_meta(
144153
json_object={
145154
'f_name': 'Jane',

0 commit comments

Comments
 (0)