Skip to content

Commit 99600ef

Browse files
BREAKING CHANGE: breaking: change response types for invoices-authorize, invoices-capture, invoices-native-payment; breaking: create/update card; add invoice expiry; add invoice qr_code; add invoice delete; add project public metadata; add hosted payment page support (#19)
Co-authored-by: ProcessOut Fountain <internal@processout.com>
1 parent bc7c4d5 commit 99600ef

11 files changed

+209
-138
lines changed

processout/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
from processout.nativeapmtransactiondetailsgateway import NativeAPMTransactionDetailsGateway
6666
from processout.nativeapmtransactiondetailsinvoice import NativeAPMTransactionDetailsInvoice
6767
from processout.nativeapmtransactiondetails import NativeAPMTransactionDetails
68-
from processout.invoicesprocessnativepaymentresponse import InvoicesProcessNativePaymentResponse
6968

7069
from processout.gatewayrequest import GatewayRequest
7170

processout/cardshipping.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ def __init__(self, client, prefill=None):
2323
self._country_code = None
2424
self._zip = None
2525
self._phone = None
26+
self._first_name = None
27+
self._last_name = None
28+
self._email = None
2629
if prefill is not None:
2730
self.fill_with_data(prefill)
2831

@@ -126,6 +129,45 @@ def phone(self, val):
126129
self._phone = val
127130
return self
128131

132+
@property
133+
def first_name(self):
134+
"""Get first_name"""
135+
return self._first_name
136+
137+
@first_name.setter
138+
def first_name(self, val):
139+
"""Set first_name
140+
Keyword argument:
141+
val -- New first_name value"""
142+
self._first_name = val
143+
return self
144+
145+
@property
146+
def last_name(self):
147+
"""Get last_name"""
148+
return self._last_name
149+
150+
@last_name.setter
151+
def last_name(self, val):
152+
"""Set last_name
153+
Keyword argument:
154+
val -- New last_name value"""
155+
self._last_name = val
156+
return self
157+
158+
@property
159+
def email(self):
160+
"""Get email"""
161+
return self._email
162+
163+
@email.setter
164+
def email(self, val):
165+
"""Set email
166+
Keyword argument:
167+
val -- New email value"""
168+
self._email = val
169+
return self
170+
129171
def fill_with_data(self, data):
130172
"""Fill the current object with the new values pulled from data
131173
Keyword argument:
@@ -144,6 +186,12 @@ def fill_with_data(self, data):
144186
self.zip = data["zip"]
145187
if "phone" in data.keys():
146188
self.phone = data["phone"]
189+
if "first_name" in data.keys():
190+
self.first_name = data["first_name"]
191+
if "last_name" in data.keys():
192+
self.last_name = data["last_name"]
193+
if "email" in data.keys():
194+
self.email = data["email"]
147195

148196
return self
149197

@@ -156,4 +204,7 @@ def to_json(self):
156204
"country_code": self.country_code,
157205
"zip": self.zip,
158206
"phone": self.phone,
207+
"first_name": self.first_name,
208+
"last_name": self.last_name,
209+
"email": self.email,
159210
}

processout/cardupdaterequest.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,10 @@ class CardUpdateRequest(object):
1616
def __init__(self, client, prefill=None):
1717
self._client = client
1818

19-
self._update_type = None
20-
self._update_reason = None
2119
self._preferred_scheme = None
2220
if prefill is not None:
2321
self.fill_with_data(prefill)
2422

25-
@property
26-
def update_type(self):
27-
"""Get update_type"""
28-
return self._update_type
29-
30-
@update_type.setter
31-
def update_type(self, val):
32-
"""Set update_type
33-
Keyword argument:
34-
val -- New update_type value"""
35-
self._update_type = val
36-
return self
37-
38-
@property
39-
def update_reason(self):
40-
"""Get update_reason"""
41-
return self._update_reason
42-
43-
@update_reason.setter
44-
def update_reason(self, val):
45-
"""Set update_reason
46-
Keyword argument:
47-
val -- New update_reason value"""
48-
self._update_reason = val
49-
return self
50-
5123
@property
5224
def preferred_scheme(self):
5325
"""Get preferred_scheme"""
@@ -65,19 +37,13 @@ def fill_with_data(self, data):
6537
"""Fill the current object with the new values pulled from data
6638
Keyword argument:
6739
data -- The data from which to pull the new values"""
68-
if "update_type" in data.keys():
69-
self.update_type = data["update_type"]
70-
if "update_reason" in data.keys():
71-
self.update_reason = data["update_reason"]
7240
if "preferred_scheme" in data.keys():
7341
self.preferred_scheme = data["preferred_scheme"]
7442

7543
return self
7644

7745
def to_json(self):
7846
return {
79-
"update_type": self.update_type,
80-
"update_reason": self.update_reason,
8147
"preferred_scheme": self.preferred_scheme,
8248
}
8349

@@ -91,8 +57,6 @@ def update(self, card_id, options={}):
9157
request = Request(self._client)
9258
path = "/cards/" + quote_plus(card_id) + ""
9359
data = {
94-
'update_type': self.update_type,
95-
'update_reason': self.update_reason,
9660
'preferred_scheme': self.preferred_scheme
9761
}
9862

processout/client.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,3 @@ def new_native_apm_transaction_details(self, prefill=None):
410410
Keyword argument:
411411
prefill -- Data used to prefill the object (optional)"""
412412
return processout.NativeAPMTransactionDetails(self, prefill)
413-
414-
def new_invoices_process_native_payment_response(self, prefill=None):
415-
"""Create a new InvoicesProcessNativePaymentResponse instance
416-
Keyword argument:
417-
prefill -- Data used to prefill the object (optional)"""
418-
return processout.InvoicesProcessNativePaymentResponse(self, prefill)

processout/invoice.py

Lines changed: 74 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def __init__(self, client, prefill=None):
2929
self._token_id = None
3030
self._details = None
3131
self._url = None
32+
self._url_qrcode = None
3233
self._name = None
3334
self._order_id = None
3435
self._amount = None
@@ -47,6 +48,7 @@ def __init__(self, client, prefill=None):
4748
self._require_backend_capture = None
4849
self._sandbox = None
4950
self._created_at = None
51+
self._expires_at = None
5052
self._risk = None
5153
self._shipping = None
5254
self._device = None
@@ -293,6 +295,19 @@ def url(self, val):
293295
self._url = val
294296
return self
295297

298+
@property
299+
def url_qrcode(self):
300+
"""Get url_qrcode"""
301+
return self._url_qrcode
302+
303+
@url_qrcode.setter
304+
def url_qrcode(self, val):
305+
"""Set url_qrcode
306+
Keyword argument:
307+
val -- New url_qrcode value"""
308+
self._url_qrcode = val
309+
return self
310+
296311
@property
297312
def name(self):
298313
"""Get name"""
@@ -527,6 +542,19 @@ def created_at(self, val):
527542
self._created_at = val
528543
return self
529544

545+
@property
546+
def expires_at(self):
547+
"""Get expires_at"""
548+
return self._expires_at
549+
550+
@expires_at.setter
551+
def expires_at(self, val):
552+
"""Set expires_at
553+
Keyword argument:
554+
val -- New expires_at value"""
555+
self._expires_at = val
556+
return self
557+
530558
@property
531559
def risk(self):
532560
"""Get risk"""
@@ -850,6 +878,8 @@ def fill_with_data(self, data):
850878
self.details = data["details"]
851879
if "url" in data.keys():
852880
self.url = data["url"]
881+
if "url_qrcode" in data.keys():
882+
self.url_qrcode = data["url_qrcode"]
853883
if "name" in data.keys():
854884
self.name = data["name"]
855885
if "order_id" in data.keys():
@@ -886,6 +916,8 @@ def fill_with_data(self, data):
886916
self.sandbox = data["sandbox"]
887917
if "created_at" in data.keys():
888918
self.created_at = data["created_at"]
919+
if "expires_at" in data.keys():
920+
self.expires_at = data["expires_at"]
889921
if "risk" in data.keys():
890922
self.risk = data["risk"]
891923
if "shipping" in data.keys():
@@ -938,6 +970,7 @@ def to_json(self):
938970
"token_id": self.token_id,
939971
"details": self.details,
940972
"url": self.url,
973+
"url_qrcode": self.url_qrcode,
941974
"name": self.name,
942975
"order_id": self.order_id,
943976
"amount": self.amount,
@@ -956,6 +989,7 @@ def to_json(self):
956989
"require_backend_capture": self.require_backend_capture,
957990
"sandbox": self.sandbox,
958991
"created_at": self.created_at,
992+
"expires_at": self.expires_at,
959993
"risk": self.risk,
960994
"shipping": self.shipping,
961995
"device": self.device,
@@ -1028,8 +1062,12 @@ def authorize(self, source, options={}):
10281062
body = body["transaction"]
10291063
transaction = processout.Transaction(self._client)
10301064
return_values.append(transaction.fill_with_data(body))
1065+
body = response.body
1066+
body = body["customer_action"]
1067+
customerAction = processout.CustomerAction(self._client)
1068+
return_values.append(customerAction.fill_with_data(body))
10311069

1032-
return return_values[0]
1070+
return tuple(return_values)
10331071

10341072
def capture(self, source, options={}):
10351073
"""Capture the invoice using the given source (customer or token)
@@ -1061,8 +1099,12 @@ def capture(self, source, options={}):
10611099
body = body["transaction"]
10621100
transaction = processout.Transaction(self._client)
10631101
return_values.append(transaction.fill_with_data(body))
1102+
body = response.body
1103+
body = body["customer_action"]
1104+
customerAction = processout.CustomerAction(self._client)
1105+
return_values.append(customerAction.fill_with_data(body))
10641106

1065-
return return_values[0]
1107+
return tuple(return_values)
10661108

10671109
def fetch_customer(self, options={}):
10681110
"""Get the customer linked to the invoice.
@@ -1183,12 +1225,15 @@ def process_native_payment(self, invoice_id, options={}):
11831225
return_values = []
11841226

11851227
body = response.body
1186-
invoicesProcessNativePaymentResponse = processout.InvoicesProcessNativePaymentResponse(
1187-
self._client)
1188-
return_values.append(
1189-
invoicesProcessNativePaymentResponse.fill_with_data(body))
1228+
body = body["transaction"]
1229+
transaction = processout.Transaction(self._client)
1230+
return_values.append(transaction.fill_with_data(body))
1231+
body = response.body
1232+
body = body["native_apm"]
1233+
nativeAPMResponse = processout.NativeAPMResponse(self._client)
1234+
return_values.append(nativeAPMResponse.fill_with_data(body))
11901235

1191-
return return_values[0]
1236+
return tuple(return_values)
11921237

11931238
def initiate_three_d_s(self, source, options={}):
11941239
"""Initiate a 3-D Secure authentication
@@ -1330,7 +1375,8 @@ def create(self, options={}):
13301375
'billing': self.billing,
13311376
'unsupported_feature_bypass': self.unsupported_feature_bypass,
13321377
'verification': self.verification,
1333-
'auto_capture_at': self.auto_capture_at
1378+
'auto_capture_at': self.auto_capture_at,
1379+
'expires_at': self.expires_at
13341380
}
13351381

13361382
response = Response(request.post(path, data, options))
@@ -1366,3 +1412,23 @@ def find(self, invoice_id, options={}):
13661412
return_values.append(obj.fill_with_data(body))
13671413

13681414
return return_values[0]
1415+
1416+
def delete(self, invoice_id, options={}):
1417+
"""Delete an invoice by its ID. Only invoices that have not been used yet can be deleted.
1418+
Keyword argument:
1419+
invoice_id -- ID of the invoice
1420+
options -- Options for the request"""
1421+
self.fill_with_data(options)
1422+
1423+
request = Request(self._client)
1424+
path = "/invoices/" + quote_plus(invoice_id) + ""
1425+
data = {
1426+
1427+
}
1428+
1429+
response = Response(request.delete(path, data, options))
1430+
return_values = []
1431+
1432+
return_values.append(response.success)
1433+
1434+
return return_values[0]

0 commit comments

Comments
 (0)