Skip to content

Commit

Permalink
Merge pull request #767 from recurly/add_gateway_attributes_account_r…
Browse files Browse the repository at this point in the history
…eference

Add GatewayAttributes to BillingInfo
  • Loading branch information
isaacvance1027 authored May 26, 2023
2 parents 1520c89 + 5bcf396 commit 5c8102e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Tests/Recurly/Billing_Info_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,18 @@ public function testForOnlineBankingPaymentType() {

public function testForGatewayToken() {
$billing_info = new Recurly_BillingInfo(null, $this->client);
$gateway_attributes = new Recurly_GatewayAttributes();
$gateway_attributes->account_reference = '123ABC';
$billing_info->gateway_token = 'x1x2x3';
$billing_info->gateway_code = 'abc123';
$billing_info->month = '11';
$billing_info->year = '2025';
$billing_info->gateway_attributes = $gateway_attributes;

$this->assertInstanceOf('Recurly_BillingInfo', $billing_info);
$this->assertEquals(
$billing_info->xml(),
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<billing_info><month>11</month><year>2025</year><gateway_token>x1x2x3</gateway_token><gateway_code>abc123</gateway_code></billing_info>\n"
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<billing_info><month>11</month><year>2025</year><gateway_token>x1x2x3</gateway_token><gateway_code>abc123</gateway_code><gateway_attributes><account_reference>123ABC</account_reference></gateway_attributes></billing_info>\n"
);
}

Expand Down
1 change: 1 addition & 0 deletions lib/recurly.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
require_once(__DIR__ . '/recurly/gift_card.php');
require_once(__DIR__ . '/recurly/gift_card_list.php');
require_once(__DIR__ . '/recurly/delivery.php');
require_once(__DIR__ . '/recurly/gateway_attributes.php');

require_once(__DIR__ . '/recurly/push_notification.php');
require_once(__DIR__ . '/recurly/util/hmac_hash.php');
3 changes: 2 additions & 1 deletion lib/recurly/billing_info.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* @property string $online_banking_payment_type Used to indicate payment made out of via an online banking (e.g. ideal).
* @property string $gateway_token The token generated by the payment gateway (Vantiv for example). When using this attribute you must set gateway_code. Also, billing_info.month will be the month of the token's expiration instead of the card's expiration month, and billing_info.year will be the year of the token's expiration instead of the card's expiration year.
* @property string $gateway_code The identifier for the gateway to use. This code can be found on the payment gateways page in the admin UI.
* @property Recurly_GatewayAttributes $gateway_attributes Additional attributes to send to the gateway
* @property int $account_number Bank account number between 4 and 17 digits.
* @property int $routing_number Must be a real U.S. bank account routing number. All routing numbers are 9 digits.
* @property string $name_on_account The name associated with the bank account. This may be a person's full name or a business name.
Expand Down Expand Up @@ -146,7 +147,7 @@ protected function getWriteableAttributes() {
'vat_number', 'number', 'month', 'year', 'verification_value',
'account_number', 'routing_number', 'account_type',
'paypal_billing_agreement_id', 'amazon_billing_agreement_id', 'currency',
'token_id', 'external_hpp_type', 'gateway_token', 'gateway_code',
'token_id', 'external_hpp_type', 'gateway_token', 'gateway_code', 'gateway_attributes',
'braintree_payment_nonce', 'roku_billing_agreement_id',
'three_d_secure_action_result_token_id', 'transaction_type', 'iban', 'sort_code', 'bsb_code', 'type',
'tax_identifier', 'tax_identifier_type', 'primary_payment_method', 'backup_payment_method',
Expand Down
17 changes: 17 additions & 0 deletions lib/recurly/gateway_attributes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

/**
* Class Recurly_GatewayAttributes
* @property string $account_reference Used by Adyen gateways. The Shopper Reference value used when the external token was created. Must be used in conjunction with gateway_token and gateway_code.
*/
class Recurly_GatewayAttributes extends Recurly_Resource
{
protected function getNodeName() {
return 'gateway_attributes';
}
protected function getWriteableAttributes() {
return array(
'account_reference'
);
}
}
1 change: 1 addition & 0 deletions lib/recurly/util/xml_tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class XmlTools
'external_subscription' => 'Recurly_ExternalSubscription',
'external_subscriptions' => 'Recurly_ExternalSubscriptionList',
'fraud' => 'Recurly_FraudInfo',
'gateway_attributes' => 'Recurly_GatewayAttributes',
'gift_card' => 'Recurly_GiftCard',
'gift_cards' => 'Recurly_GiftCardList',
'gifter_account' => 'Recurly_Account',
Expand Down

0 comments on commit 5c8102e

Please sign in to comment.