From 1cb4b5eef121d5dcbcb3f0cd14a871bb431090b3 Mon Sep 17 00:00:00 2001 From: Benjamin Eckel Date: Wed, 21 Aug 2019 10:59:34 -0500 Subject: [PATCH 1/2] Bump API 2.22 --- lib/recurly/client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/recurly/client.php b/lib/recurly/client.php index 48929fe2..7be3ad12 100644 --- a/lib/recurly/client.php +++ b/lib/recurly/client.php @@ -22,7 +22,7 @@ class Recurly_Client /** * API Version */ - public static $apiVersion = '2.21'; + public static $apiVersion = '2.22'; /** * The path to your CA certs. Use only if needed (if you can't fix libcurl/php). From 29e251f2ef05d2cbbfdc7506fd80114e87311875 Mon Sep 17 00:00:00 2001 From: Benjamin Eckel Date: Wed, 21 Aug 2019 10:59:44 -0500 Subject: [PATCH 2/2] MOTO transactions --- Tests/Recurly/Account_Test.php | 12 ++++++++++++ Tests/Recurly/Billing_Info_Test.php | 11 +++++++++++ Tests/Recurly/Invoice_Test.php | 2 +- Tests/Recurly/Purchase_Test.php | 3 ++- lib/recurly/account.php | 3 ++- lib/recurly/billing_info.php | 3 ++- lib/recurly/invoice.php | 11 +++++++++-- lib/recurly/purchase.php | 3 ++- lib/recurly/subscription.php | 3 ++- 9 files changed, 43 insertions(+), 8 deletions(-) diff --git a/Tests/Recurly/Account_Test.php b/Tests/Recurly/Account_Test.php index 9aeeee6a..d14edc47 100644 --- a/Tests/Recurly/Account_Test.php +++ b/Tests/Recurly/Account_Test.php @@ -150,6 +150,18 @@ public function testXml() { ); } + /** + * Test that transaction_type is rendered + */ + public function testTransactionType() { + $account = Recurly_Account::get('abcdef1234567890', $this->client); + $account->transaction_type = 'moto'; + $this->assertEquals( + "\nmoto\n", + $account->xml() + ); + } + /** * Test that updates to nested account addresses are detected when generating * XML to send. diff --git a/Tests/Recurly/Billing_Info_Test.php b/Tests/Recurly/Billing_Info_Test.php index ec6abcc9..3f2a6dc1 100644 --- a/Tests/Recurly/Billing_Info_Test.php +++ b/Tests/Recurly/Billing_Info_Test.php @@ -107,6 +107,17 @@ public function testCreateForAccountWithToken() { $billing_info->create(); } + public function testTransactionType() { + $billing_info = new Recurly_BillingInfo(null, $this->client); + $billing_info->transaction_type = 'moto'; + + $this->assertInstanceOf('Recurly_BillingInfo', $billing_info); + $this->assertEquals( + $billing_info->xml(), + "\nmoto\n" + ); + } + public function testForExternalHppType() { $billing_info = new Recurly_BillingInfo(null, $this->client); $billing_info->token_id = 'abc123'; diff --git a/Tests/Recurly/Invoice_Test.php b/Tests/Recurly/Invoice_Test.php index 1da19010..cdd8e2e7 100644 --- a/Tests/Recurly/Invoice_Test.php +++ b/Tests/Recurly/Invoice_Test.php @@ -112,7 +112,7 @@ public function testForceCollect() { $this->client->addResponse('PUT', 'https://api.recurly.com/v2/invoices/1001/collect', 'invoices/force_collect-200.xml'); $invoice = Recurly_Invoice::get('1001', $this->client); - $invoice->forceCollect(); + $invoice->forceCollect('moto'); $this->assertEquals($invoice->state, 'paid'); } diff --git a/Tests/Recurly/Purchase_Test.php b/Tests/Recurly/Purchase_Test.php index 34c8ae23..56fd578a 100644 --- a/Tests/Recurly/Purchase_Test.php +++ b/Tests/Recurly/Purchase_Test.php @@ -16,6 +16,7 @@ function defaultResponses() { public function mockPurchase() { $purchase = new Recurly_Purchase(); + $purchase->transaction_type = 'moto'; $purchase->currency = 'USD'; $purchase->gateway_code = 'aBcD1234'; $purchase->collection_method = 'automatic'; @@ -61,7 +62,7 @@ public function testXml() { $purchase = $this->mockPurchase(); $this->assertEquals( - "\naba9209a-aa61-4790-8e61-0a2692435fee7z6furn4jvb9
123 Main St.San FranciscoCA94110US555-555-5555
400 Dolores StSan FranciscoCA94110USHomeDoloresDu Monde
USD10001at_invoiceabcd123automaticUSDCustomer NotesTerms and ConditionsVAT Reverse Charge NotesaBcD1234
\n", + "\naba9209a-aa61-4790-8e61-0a2692435fee7z6furn4jvb9
123 Main St.San FranciscoCA94110US555-555-5555
400 Dolores StSan FranciscoCA94110USHomeDoloresDu Monde
USD10001at_invoiceabcd123automaticUSDCustomer NotesTerms and ConditionsVAT Reverse Charge NotesaBcD1234moto
\n", $purchase->xml() ); } diff --git a/lib/recurly/account.php b/lib/recurly/account.php index 24da1b9c..9a28fad6 100644 --- a/lib/recurly/account.php +++ b/lib/recurly/account.php @@ -34,6 +34,7 @@ * @property DateTime $updated_at The date and time the account or its billing info was last updated. * @property DateTime $closed_at For closed accounts, the date and time it was closed. * @property Recurly_AccountAcquisition $account_acquisition The nested account acquisition information: cost_in_cents, currency, channel, subchannel, campaign. + * @property string $transaction_type Indicates type of resulting transaction. accepted_values: "moto". */ class Recurly_Account extends Recurly_Resource { @@ -109,7 +110,7 @@ protected function getWriteableAttributes() { 'email', 'company_name', 'accept_language', 'billing_info', 'address', 'tax_exempt', 'entity_use_code', 'cc_emails', 'shipping_addresses', 'preferred_locale', 'custom_fields', 'account_acquisition', 'exemption_certificate', - 'parent_account_code' + 'parent_account_code', 'transaction_type' ); } protected function getRequiredAttributes() { diff --git a/lib/recurly/billing_info.php b/lib/recurly/billing_info.php index 5ad47442..b13b9de2 100644 --- a/lib/recurly/billing_info.php +++ b/lib/recurly/billing_info.php @@ -31,6 +31,7 @@ * @property string $amazon_billing_agreement_id Amazon's billing agreement * @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. * @property string $roku_billing_agreement_id Roku's CIB if billing through Roku + * @property string $transaction_type Indicates type of resulting transaction. accepted_values: "moto". */ class Recurly_BillingInfo extends Recurly_Resource { @@ -99,7 +100,7 @@ protected function getWriteableAttributes() { 'paypal_billing_agreement_id', 'amazon_billing_agreement_id', 'currency', 'token_id', 'external_hpp_type', 'gateway_token', 'gateway_code', 'braintree_payment_nonce', 'roku_billing_agreement_id', - 'three_d_secure_action_result_token_id' + 'three_d_secure_action_result_token_id', 'transaction_type' ); } } diff --git a/lib/recurly/invoice.php b/lib/recurly/invoice.php index e04baa97..e99e9456 100644 --- a/lib/recurly/invoice.php +++ b/lib/recurly/invoice.php @@ -125,8 +125,15 @@ public function markSuccessful() { /** * @throws Recurly_Error */ - public function forceCollect() { - $this->_save(Recurly_Client::PUT, $this->uri() . '/collect'); + public function forceCollect($transaction_type = null) { + $body = null; + if ($transaction_type != null) { + $doc = $this->createDocument(); + $root = $doc->appendChild($doc->createElement('invoice')); + $root->appendChild($doc->createElement('transaction_type', $transaction_type)); + $body = $this->renderXML($doc); + } + $this->_save(Recurly_Client::PUT, $this->uri() . '/collect', $body, $this->_client); } /** diff --git a/lib/recurly/purchase.php b/lib/recurly/purchase.php index 4b313eb1..f9e29ed6 100644 --- a/lib/recurly/purchase.php +++ b/lib/recurly/purchase.php @@ -16,6 +16,7 @@ * @property integer $shipping_address_id Optional id of an existing ShippingAddress to be applied to all subscriptions and adjustments in purchase. * @property string $gateway_code Optional base36 encoded id for the gateway you wish to use for this transaction. * @property Recurly_ShippingFee[] $shipping_fees Optional array of shipping fees to apply to the purchase. + * @property string $transaction_type Indicates type of resulting transaction. accepted_values: "moto". */ class Recurly_Purchase extends Recurly_Resource { @@ -116,7 +117,7 @@ protected function getWriteableAttributes() { 'account', 'adjustments', 'collection_method', 'currency', 'po_number', 'net_terms', 'subscriptions', 'gift_card', 'coupon_codes', 'customer_notes', 'terms_and_conditions', 'vat_reverse_charge_notes', 'shipping_address_id', - 'gateway_code', 'shipping_fees' + 'gateway_code', 'shipping_fees', 'transaction_type' ); } } diff --git a/lib/recurly/subscription.php b/lib/recurly/subscription.php index 80cb9830..167f0c3f 100644 --- a/lib/recurly/subscription.php +++ b/lib/recurly/subscription.php @@ -45,6 +45,7 @@ * @property string $gateway_code The unique identifier of a payment gateway used to specify which payment gateway you wish to process this subscriptions’ payments * @property string $shipping_method_code The unique identifier of the shipping method for this subscription. * @property integer $shipping_amount_in_cents The amount charged for shipping in cents. + * @property string $transaction_type Indicates type of resulting transaction. accepted_values: "moto". */ class Recurly_Subscription extends Recurly_Resource { @@ -279,7 +280,7 @@ protected function getWriteableAttributes() { 'shipping_address', 'shipping_address_id', 'imported_trial', 'remaining_pause_cycles', 'custom_fields', 'auto_renew', 'renewal_billing_cycles', 'gateway_code', 'shipping_method_code', - 'shipping_amount_in_cents' + 'shipping_amount_in_cents', 'transaction_type' ); } }