Skip to content

Commit d90efa3

Browse files
authored
Merge pull request #421 from recurly/api_version_2_22
Release 2.12.5 / API version 2.22
2 parents 96e96fd + 13e0861 commit d90efa3

File tree

11 files changed

+51
-10
lines changed

11 files changed

+51
-10
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Recurly PHP Client Library CHANGELOG
22

3+
## Version 2.12.5 (August 21st, 2019)
4+
5+
This brings us up to API version 2.22. There are no breaking changes
6+
7+
* Moto transactions [PR](https://github.com/recurly/recurly-client-php/pull/420)
8+
39
## Version 2.12.4 (June 27th, 2019)
410

511
This brings us up to API version 2.21. There are no breaking changes

Tests/Recurly/Account_Test.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,18 @@ public function testXml() {
150150
);
151151
}
152152

153+
/**
154+
* Test that transaction_type is rendered
155+
*/
156+
public function testTransactionType() {
157+
$account = Recurly_Account::get('abcdef1234567890', $this->client);
158+
$account->transaction_type = 'moto';
159+
$this->assertEquals(
160+
"<?xml version=\"1.0\"?>\n<account><transaction_type>moto</transaction_type></account>\n",
161+
$account->xml()
162+
);
163+
}
164+
153165
/**
154166
* Test that updates to nested account addresses are detected when generating
155167
* XML to send.

Tests/Recurly/Billing_Info_Test.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,17 @@ public function testCreateForAccountWithToken() {
107107
$billing_info->create();
108108
}
109109

110+
public function testTransactionType() {
111+
$billing_info = new Recurly_BillingInfo(null, $this->client);
112+
$billing_info->transaction_type = 'moto';
113+
114+
$this->assertInstanceOf('Recurly_BillingInfo', $billing_info);
115+
$this->assertEquals(
116+
$billing_info->xml(),
117+
"<?xml version=\"1.0\"?>\n<billing_info><transaction_type>moto</transaction_type></billing_info>\n"
118+
);
119+
}
120+
110121
public function testForExternalHppType() {
111122
$billing_info = new Recurly_BillingInfo(null, $this->client);
112123
$billing_info->token_id = 'abc123';

Tests/Recurly/Invoice_Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function testForceCollect() {
112112
$this->client->addResponse('PUT', 'https://api.recurly.com/v2/invoices/1001/collect', 'invoices/force_collect-200.xml');
113113

114114
$invoice = Recurly_Invoice::get('1001', $this->client);
115-
$invoice->forceCollect();
115+
$invoice->forceCollect('moto');
116116
$this->assertEquals($invoice->state, 'paid');
117117
}
118118

Tests/Recurly/Purchase_Test.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ function defaultResponses() {
1616

1717
public function mockPurchase() {
1818
$purchase = new Recurly_Purchase();
19+
$purchase->transaction_type = 'moto';
1920
$purchase->currency = 'USD';
2021
$purchase->gateway_code = 'aBcD1234';
2122
$purchase->collection_method = 'automatic';
@@ -61,7 +62,7 @@ public function testXml() {
6162
$purchase = $this->mockPurchase();
6263

6364
$this->assertEquals(
64-
"<?xml version=\"1.0\"?>\n<purchase><account><account_code>aba9209a-aa61-4790-8e61-0a2692435fee</account_code><billing_info><token_id>7z6furn4jvb9</token_id></billing_info><address><address1>123 Main St.</address1><city>San Francisco</city><state>CA</state><zip>94110</zip><country>US</country><phone>555-555-5555</phone></address><shipping_addresses><shipping_address><address1>400 Dolores St</address1><city>San Francisco</city><state>CA</state><zip>94110</zip><country>US</country><nickname>Home</nickname><first_name>Dolores</first_name><last_name>Du Monde</last_name></shipping_address></shipping_addresses></account><adjustments><adjustment><currency>USD</currency><unit_amount_in_cents>1000</unit_amount_in_cents><quantity>1</quantity><revenue_schedule_type>at_invoice</revenue_schedule_type><product_code>abcd123</product_code></adjustment></adjustments><collection_method>automatic</collection_method><currency>USD</currency><customer_notes>Customer Notes</customer_notes><terms_and_conditions>Terms and Conditions</terms_and_conditions><vat_reverse_charge_notes>VAT Reverse Charge Notes</vat_reverse_charge_notes><gateway_code>aBcD1234</gateway_code></purchase>\n",
65+
"<?xml version=\"1.0\"?>\n<purchase><account><account_code>aba9209a-aa61-4790-8e61-0a2692435fee</account_code><billing_info><token_id>7z6furn4jvb9</token_id></billing_info><address><address1>123 Main St.</address1><city>San Francisco</city><state>CA</state><zip>94110</zip><country>US</country><phone>555-555-5555</phone></address><shipping_addresses><shipping_address><address1>400 Dolores St</address1><city>San Francisco</city><state>CA</state><zip>94110</zip><country>US</country><nickname>Home</nickname><first_name>Dolores</first_name><last_name>Du Monde</last_name></shipping_address></shipping_addresses></account><adjustments><adjustment><currency>USD</currency><unit_amount_in_cents>1000</unit_amount_in_cents><quantity>1</quantity><revenue_schedule_type>at_invoice</revenue_schedule_type><product_code>abcd123</product_code></adjustment></adjustments><collection_method>automatic</collection_method><currency>USD</currency><customer_notes>Customer Notes</customer_notes><terms_and_conditions>Terms and Conditions</terms_and_conditions><vat_reverse_charge_notes>VAT Reverse Charge Notes</vat_reverse_charge_notes><gateway_code>aBcD1234</gateway_code><transaction_type>moto</transaction_type></purchase>\n",
6566
$purchase->xml()
6667
);
6768
}

lib/recurly/account.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
* @property DateTime $updated_at The date and time the account or its billing info was last updated.
3535
* @property DateTime $closed_at For closed accounts, the date and time it was closed.
3636
* @property Recurly_AccountAcquisition $account_acquisition The nested account acquisition information: cost_in_cents, currency, channel, subchannel, campaign.
37+
* @property string $transaction_type Indicates type of resulting transaction. accepted_values: "moto".
3738
*/
3839
class Recurly_Account extends Recurly_Resource
3940
{
@@ -109,7 +110,7 @@ protected function getWriteableAttributes() {
109110
'email', 'company_name', 'accept_language', 'billing_info', 'address',
110111
'tax_exempt', 'entity_use_code', 'cc_emails', 'shipping_addresses',
111112
'preferred_locale', 'custom_fields', 'account_acquisition', 'exemption_certificate',
112-
'parent_account_code'
113+
'parent_account_code', 'transaction_type'
113114
);
114115
}
115116
protected function getRequiredAttributes() {

lib/recurly/billing_info.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
* @property string $amazon_billing_agreement_id Amazon's billing agreement
3232
* @property string $braintree_payment_nonce Braintree's payment method nonce representing the Paypal billing agreement id. This is required when processing Paypal transactions through Braintree.
3333
* @property string $roku_billing_agreement_id Roku's CIB if billing through Roku
34+
* @property string $transaction_type Indicates type of resulting transaction. accepted_values: "moto".
3435
*/
3536
class Recurly_BillingInfo extends Recurly_Resource
3637
{
@@ -99,7 +100,7 @@ protected function getWriteableAttributes() {
99100
'paypal_billing_agreement_id', 'amazon_billing_agreement_id', 'currency',
100101
'token_id', 'external_hpp_type', 'gateway_token', 'gateway_code',
101102
'braintree_payment_nonce', 'roku_billing_agreement_id',
102-
'three_d_secure_action_result_token_id'
103+
'three_d_secure_action_result_token_id', 'transaction_type'
103104
);
104105
}
105106
}

lib/recurly/client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Recurly_Client
2222
/**
2323
* API Version
2424
*/
25-
public static $apiVersion = '2.21';
25+
public static $apiVersion = '2.22';
2626

2727
/**
2828
* The path to your CA certs. Use only if needed (if you can't fix libcurl/php).
@@ -50,7 +50,7 @@ class Recurly_Client
5050
private static $apiUrl = 'https://%s.recurly.com/v2';
5151

5252

53-
const API_CLIENT_VERSION = '2.12.4';
53+
const API_CLIENT_VERSION = '2.12.5';
5454
const DEFAULT_ENCODING = 'UTF-8';
5555

5656
const GET = 'GET';

lib/recurly/invoice.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,15 @@ public function markSuccessful() {
125125
/**
126126
* @throws Recurly_Error
127127
*/
128-
public function forceCollect() {
129-
$this->_save(Recurly_Client::PUT, $this->uri() . '/collect');
128+
public function forceCollect($transaction_type = null) {
129+
$body = null;
130+
if ($transaction_type != null) {
131+
$doc = $this->createDocument();
132+
$root = $doc->appendChild($doc->createElement('invoice'));
133+
$root->appendChild($doc->createElement('transaction_type', $transaction_type));
134+
$body = $this->renderXML($doc);
135+
}
136+
$this->_save(Recurly_Client::PUT, $this->uri() . '/collect', $body, $this->_client);
130137
}
131138

132139
/**

lib/recurly/purchase.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* @property integer $shipping_address_id Optional id of an existing ShippingAddress to be applied to all subscriptions and adjustments in purchase.
1717
* @property string $gateway_code Optional base36 encoded id for the gateway you wish to use for this transaction.
1818
* @property Recurly_ShippingFee[] $shipping_fees Optional array of shipping fees to apply to the purchase.
19+
* @property string $transaction_type Indicates type of resulting transaction. accepted_values: "moto".
1920
*/
2021
class Recurly_Purchase extends Recurly_Resource
2122
{
@@ -116,7 +117,7 @@ protected function getWriteableAttributes() {
116117
'account', 'adjustments', 'collection_method', 'currency', 'po_number',
117118
'net_terms', 'subscriptions', 'gift_card', 'coupon_codes', 'customer_notes',
118119
'terms_and_conditions', 'vat_reverse_charge_notes', 'shipping_address_id',
119-
'gateway_code', 'shipping_fees'
120+
'gateway_code', 'shipping_fees', 'transaction_type'
120121
);
121122
}
122123
}

0 commit comments

Comments
 (0)