Skip to content

Commit abc4a4a

Browse files
Merge pull request #648 from recurly/add_gateway_attributes_account_reference
Add gateway_attributes and account_reference to Billing Info
2 parents 8976d7f + 2b4ac35 commit abc4a4a

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

recurly/__init__.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,16 @@ class BillingInfoFraudInfo(recurly.Resource):
470470
'decision',
471471
)
472472

473+
class GatewayAttributes(Resource):
474+
475+
"""Additional attributes to send to the gateway"""
476+
477+
nodename = 'gateway_attributes'
478+
479+
attributes = (
480+
'account_reference',
481+
)
482+
473483
class BillingInfo(Resource):
474484

475485
"""A set of billing information for an account."""
@@ -515,6 +525,7 @@ class BillingInfo(Resource):
515525
'external_hpp_type',
516526
'gateway_token',
517527
'gateway_code',
528+
'gateway_attributes',
518529
'three_d_secure_action_result_token_id',
519530
'transaction_type',
520531
'iban',
@@ -532,6 +543,7 @@ class BillingInfo(Resource):
532543
xml_attribute_attributes = ('type',)
533544
_classes_for_nodename = {
534545
'fraud': BillingInfoFraudInfo,
546+
'gateway_attributes': GatewayAttributes
535547
}
536548

537549
# Allows user to call verify() on billing_info object
@@ -541,7 +553,7 @@ def verify(self, account_code, gateway_code = None):
541553

542554
def verify_cvv(self, account_code, verification_value = None):
543555
recurly.Account.get(account_code).verify_cvv(verification_value)
544-
556+
545557
class ShippingAddress(Resource):
546558

547559
"""Shipping Address information"""

tests/fixtures/billing-info/created.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ Content-Type: application/xml; charset=utf-8
1212
<country>US</country>
1313
<currency>USD</currency>
1414
<first_name>Verena</first_name>
15+
<gateway_attributes>
16+
<account_reference>ABC123</account_reference>
17+
</gateway_attributes>
1518
<gateway_code>gatewaycode123</gateway_code>
1619
<gateway_token>gatewaytoken123</gateway_token>
1720
<last_name>Example</last_name>
@@ -45,6 +48,9 @@ Location: https://api.recurly.com/v2/accounts/binfomock/billing_info
4548
<currency>USD</currency>
4649
<gateway_token>gatewaytoken123</gateway_token>
4750
<gateway_code>gatewaycode123</gateway_code>
51+
<gateway_attributes>
52+
<account_reference>ABC123</account_reference>
53+
</gateway_attributes>
4854
<fraud>
4955
<score type="integer">87</score>
5056
<decision>DECLINED</decision>

tests/test_resources.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
SubscriptionAddOn, Transaction, MeasuredUnit, Usage, GiftCard, Delivery, ShippingAddress, AccountAcquisition, \
1111
Purchase, Invoice, InvoiceCollection, CreditPayment, CustomField, ExportDate, ExportDateFile, DunningCampaign, \
1212
DunningCycle, InvoiceTemplate, PlanRampInterval, SubRampInterval, ExternalSubscription, ExternalProduct, \
13-
ExternalProductReference, CustomFieldDefinition, ExternalInvoice, ExternalCharge, ExternalAccount
13+
ExternalProductReference, CustomFieldDefinition, ExternalInvoice, ExternalCharge, ExternalAccount, GatewayAttributes
1414
from recurly import Money, NotFoundError, ValidationError, BadRequestError, PageError
1515
from recurly import recurly_logging as logging
1616
from recurlytests import RecurlyTest
@@ -862,6 +862,7 @@ def test_billing_info(self):
862862
log_content = StringIO()
863863
log_handler = logging.StreamHandler(log_content)
864864
logger.addHandler(log_handler)
865+
gateway_attributes = GatewayAttributes(account_reference='ABC123')
865866

866867
binfo = BillingInfo(
867868
first_name='Verena',
@@ -878,6 +879,7 @@ def test_billing_info(self):
878879
month='12',
879880
gateway_token='gatewaytoken123',
880881
gateway_code='gatewaycode123',
882+
gateway_attributes=gateway_attributes,
881883
)
882884
with self.mock_request('billing-info/created.xml'):
883885
account.update_billing_info(binfo)
@@ -886,6 +888,7 @@ def test_billing_info(self):
886888
self.assertEqual(binfo.gateway_code, 'gatewaycode123')
887889
self.assertEqual(binfo.fraud.score, 87)
888890
self.assertEqual(binfo.fraud.decision, 'DECLINED')
891+
self.assertEqual(binfo.gateway_attributes.account_reference, 'ABC123')
889892

890893
logger.removeHandler(log_handler)
891894
log_content = log_content.getvalue()

0 commit comments

Comments
 (0)