Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Portico gateway users to submit the AutoSubstantiation and FirstAdditionalAmtInfo elements for Flex card support #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,32 @@ except ApiException as e:
// handle errors
```

#### Process a Payment with Healthcare Amount Example

This passes on to the issuing bank what part of the total payment amount was used for a healthcare purchase. This allows the use of FSA (Flex) cards. This is currently only supported with users of the Portico Gateway.

```python
card = CreditCardData()
card.number = '4111111111111111'
card.exp_month = '12'
card.exp_year = '2025'
card.cvn = '123'
card.card_holder_name = 'Joe Smith'

try:
response = card.charge(129.99) \
.with_currency("EUR") \
.with_healthcare_amount(100.00) \
.execute()

result = response.response_code # 00 == Success
message = response.response_message # [ test system ] AUTHORISED

except ApiException as e:
// handle errors
```


#### Test Card Data

Name | Number | Exp Month | Exp Year | CVN
Expand Down
5 changes: 5 additions & 0 deletions globalpayments/api/builders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class AuthorizationBuilder(TransactionBuilder):
schedule_id = None
shipping_address = None
timestamp = None
healthcare = None

def with_address(self, address, address_type=AddressType.Billing):
if not isinstance(address, Address):
Expand All @@ -119,6 +120,10 @@ def with_alias(self, action, value):
self.alias = value
self.alias_action = action
return self

def with_healthcare_amount(self, value):
self.healthcare = value
return self

def with_cash_back(self, value):
self.cash_back_amount = value
Expand Down
6 changes: 6 additions & 0 deletions globalpayments/api/gateways/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,12 @@ def process_authorization(self, builder):
et.SubElement(block1, 'AllowPartialAuth').text = \
'Y' if builder.allow_partial_auth else 'N'

if builder.healthcare is not None:
auto_substantiation = et.SubElement(block1, 'AutoSubstantiation')
first_addl_amt_info = et.SubElement(auto_substantiation, 'FirstAdditionalAmtInfo')
et.SubElement(first_addl_amt_info, 'AmtType').text = 'TOTAL_HEALTHCARE_AMT'
et.SubElement(first_addl_amt_info, 'Amt').text = builder.healthcare

if builder.amount is not None:
et.SubElement(block1, 'Amt').text = str(builder.amount)

Expand Down