Skip to content

Commit d443cfe

Browse files
feat: increamental authorization
1 parent 0595e36 commit d443cfe

File tree

5 files changed

+184
-3
lines changed

5 files changed

+184
-3
lines changed

processout/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from processout.gateway import Gateway
1717
from processout.gatewayconfiguration import GatewayConfiguration
1818
from processout.invoice import Invoice
19+
from processout.invoicetax import InvoiceTax
1920
from processout.invoiceexternalfraudtools import InvoiceExternalFraudTools
2021
from processout.invoicerisk import InvoiceRisk
2122
from processout.invoicedevice import InvoiceDevice

processout/client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ def new_invoice(self, prefill = None):
115115
prefill -- Data used to prefill the object (optional)"""
116116
return processout.Invoice(self, prefill)
117117

118+
def new_invoice_tax(self, prefill = None):
119+
"""Create a new InvoiceTax instance
120+
Keyword argument:
121+
prefill -- Data used to prefill the object (optional)"""
122+
return processout.InvoiceTax(self, prefill)
123+
118124
def new_invoice_external_fraud_tools(self, prefill = None):
119125
"""Create a new InvoiceExternalFraudTools instance
120126
Keyword argument:

processout/invoice.py

Lines changed: 107 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ def __init__(self, client, prefill = None):
5050
self._device = None
5151
self._external_fraud_tools = None
5252
self._exemption_reason_3ds2 = None
53+
self._sca_exemption_reason = None
54+
self._challenge_indicator = None
55+
self._incremental = None
56+
self._tax = None
5357
if prefill != None:
5458
self.fill_with_data(prefill)
5559

@@ -602,6 +606,67 @@ def exemption_reason_3ds2(self, val):
602606
self._exemption_reason_3ds2 = val
603607
return self
604608

609+
@property
610+
def sca_exemption_reason(self):
611+
"""Get sca_exemption_reason"""
612+
return self._sca_exemption_reason
613+
614+
@sca_exemption_reason.setter
615+
def sca_exemption_reason(self, val):
616+
"""Set sca_exemption_reason
617+
Keyword argument:
618+
val -- New sca_exemption_reason value"""
619+
self._sca_exemption_reason = val
620+
return self
621+
622+
@property
623+
def challenge_indicator(self):
624+
"""Get challenge_indicator"""
625+
return self._challenge_indicator
626+
627+
@challenge_indicator.setter
628+
def challenge_indicator(self, val):
629+
"""Set challenge_indicator
630+
Keyword argument:
631+
val -- New challenge_indicator value"""
632+
self._challenge_indicator = val
633+
return self
634+
635+
@property
636+
def incremental(self):
637+
"""Get incremental"""
638+
return self._incremental
639+
640+
@incremental.setter
641+
def incremental(self, val):
642+
"""Set incremental
643+
Keyword argument:
644+
val -- New incremental value"""
645+
self._incremental = val
646+
return self
647+
648+
@property
649+
def tax(self):
650+
"""Get tax"""
651+
return self._tax
652+
653+
@tax.setter
654+
def tax(self, val):
655+
"""Set tax
656+
Keyword argument:
657+
val -- New tax value"""
658+
if val is None:
659+
self._tax = val
660+
return self
661+
662+
if isinstance(val, dict):
663+
obj = processout.InvoiceTax(self._client)
664+
obj.fill_with_data(val)
665+
self._tax = obj
666+
else:
667+
self._tax = val
668+
return self
669+
605670

606671
def fill_with_data(self, data):
607672
"""Fill the current object with the new values pulled from data
@@ -677,6 +742,14 @@ def fill_with_data(self, data):
677742
self.external_fraud_tools = data["external_fraud_tools"]
678743
if "exemption_reason_3ds2" in data.keys():
679744
self.exemption_reason_3ds2 = data["exemption_reason_3ds2"]
745+
if "sca_exemption_reason" in data.keys():
746+
self.sca_exemption_reason = data["sca_exemption_reason"]
747+
if "challenge_indicator" in data.keys():
748+
self.challenge_indicator = data["challenge_indicator"]
749+
if "incremental" in data.keys():
750+
self.incremental = data["incremental"]
751+
if "tax" in data.keys():
752+
self.tax = data["tax"]
680753

681754
return self
682755

@@ -717,8 +790,36 @@ def to_json(self):
717790
"device": self.device,
718791
"external_fraud_tools": self.external_fraud_tools,
719792
"exemption_reason_3ds2": self.exemption_reason_3ds2,
793+
"sca_exemption_reason": self.sca_exemption_reason,
794+
"challenge_indicator": self.challenge_indicator,
795+
"incremental": self.incremental,
796+
"tax": self.tax,
797+
}
798+
799+
def increment authorization(self, amount, options = {}):
800+
"""Create an incremental authorization
801+
Keyword argument:
802+
amount -- Amount to increment authorization by
803+
options -- Options for the request"""
804+
self.fill_with_data(options)
805+
806+
request = Request(self._client)
807+
path = "/invoices/" + quote_plus(self.id) + "/increment_authorization"
808+
data = {
809+
'amount': amount
720810
}
721811

812+
response = Response(request.post(path, data, options))
813+
return_values = []
814+
815+
body = response.body
816+
body = body["transaction"]
817+
transaction = processout.Transaction(self._client)
818+
return_values.append(transaction.fill_with_data(body))
819+
820+
821+
return return_values[0]
822+
722823
def authorize(self, source, options = {}):
723824
"""Authorize the invoice using the given source (customer or token)
724825
Keyword argument:
@@ -730,6 +831,7 @@ def authorize(self, source, options = {}):
730831
path = "/invoices/" + quote_plus(self.id) + "/authorize"
731832
data = {
732833
'device': self.device,
834+
'incremental': self.incremental,
733835
'synchronous': options.get("synchronous"),
734836
'retry_drop_liability_shift': options.get("retry_drop_liability_shift"),
735837
'capture_amount': options.get("capture_amount"),
@@ -760,6 +862,7 @@ def capture(self, source, options = {}):
760862
path = "/invoices/" + quote_plus(self.id) + "/capture"
761863
data = {
762864
'device': self.device,
865+
'incremental': self.incremental,
763866
'authorize_only': options.get("authorize_only"),
764867
'synchronous': options.get("synchronous"),
765868
'retry_drop_liability_shift': options.get("retry_drop_liability_shift"),
@@ -947,6 +1050,8 @@ def create(self, options = {}):
9471050
'metadata': self.metadata,
9481051
'details': self.details,
9491052
'exemption_reason_3ds2': self.exemption_reason_3ds2,
1053+
'sca_exemption_reason': self.sca_exemption_reason,
1054+
'challenge_indicator': self.challenge_indicator,
9501055
'gateway_data': self.gateway_data,
9511056
'merchant_initiator_type': self.merchant_initiator_type,
9521057
'statement_descriptor': self.statement_descriptor,
@@ -961,7 +1066,8 @@ def create(self, options = {}):
9611066
'shipping': self.shipping,
9621067
'device': self.device,
9631068
'require_backend_capture': self.require_backend_capture,
964-
'external_fraud_tools': self.external_fraud_tools
1069+
'external_fraud_tools': self.external_fraud_tools,
1070+
'tax': self.tax
9651071
}
9661072

9671073
response = Response(request.post(path, data, options))

processout/invoicetax.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
try:
2+
from urllib.parse import quote_plus
3+
except ImportError:
4+
from urllib import quote_plus
5+
6+
import processout
7+
import json
8+
9+
from processout.networking.request import Request
10+
from processout.networking.response import Response
11+
12+
# The content of this file was automatically generated
13+
14+
class InvoiceTax(object):
15+
def __init__(self, client, prefill = None):
16+
self._client = client
17+
18+
self._amount = None
19+
self._rate = None
20+
if prefill != None:
21+
self.fill_with_data(prefill)
22+
23+
24+
@property
25+
def amount(self):
26+
"""Get amount"""
27+
return self._amount
28+
29+
@amount.setter
30+
def amount(self, val):
31+
"""Set amount
32+
Keyword argument:
33+
val -- New amount value"""
34+
self._amount = val
35+
return self
36+
37+
@property
38+
def rate(self):
39+
"""Get rate"""
40+
return self._rate
41+
42+
@rate.setter
43+
def rate(self, val):
44+
"""Set rate
45+
Keyword argument:
46+
val -- New rate value"""
47+
self._rate = val
48+
return self
49+
50+
51+
def fill_with_data(self, data):
52+
"""Fill the current object with the new values pulled from data
53+
Keyword argument:
54+
data -- The data from which to pull the new values"""
55+
if "amount" in data.keys():
56+
self.amount = data["amount"]
57+
if "rate" in data.keys():
58+
self.rate = data["rate"]
59+
60+
return self
61+
62+
def to_json(self):
63+
return {
64+
"amount": self.amount,
65+
"rate": self.rate,
66+
}
67+
68+

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
setup(
44
name = 'processout',
55
packages = ['processout', 'processout.errors', 'processout.networking'],
6-
version = '6.18.5',
6+
version = '6.19.0',
77
description = 'ProcessOut API bindings.',
88
author = 'ProcessOut',
99
author_email = '[email protected]',
1010
url = 'https://github.com/processout/processout-python',
11-
download_url = 'https://github.com/processout/processout-python/tarball/6.18.5',
11+
download_url = 'https://github.com/processout/processout-python/tarball/6.19.0',
1212
keywords = ['ProcessOut', 'api', 'bindings'],
1313
classifiers = [],
1414
)

0 commit comments

Comments
 (0)