Skip to content

Commit 42d9cf4

Browse files
authored
Merge pull request #414 from recurly/api_version_2_20
Release version 2.12.3
2 parents 28465f3 + 6b1ccde commit 42d9cf4

File tree

9 files changed

+125
-12
lines changed

9 files changed

+125
-12
lines changed

CHANGELOG.md

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

3+
## Version 2.12.3 (May 21st, 2019)
4+
5+
This brings us up to API version 2.20. There are no breaking changes
6+
7+
* Add shipping fees [PR](https://github.com/recurly/recurly-client-php/pull/412)
8+
* Support updating a subscription at next bill date [PR](https://github.com/recurly/recurly-client-php/pull/413)
9+
310
## Version 2.12.2 (April 26th, 2019)
411

512
* Ensure nested resources have the same client as their parent [PR](https://github.com/recurly/recurly-client-php/pull/409)

lib/recurly.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
require_once(dirname(__FILE__) . '/recurly/redemption_list.php');
5050
require_once(dirname(__FILE__) . '/recurly/shipping_address.php');
5151
require_once(dirname(__FILE__) . '/recurly/shipping_address_list.php');
52+
require_once(dirname(__FILE__) . '/recurly/shipping_fee.php');
53+
require_once(dirname(__FILE__) . '/recurly/shipping_method.php');
54+
require_once(dirname(__FILE__) . '/recurly/shipping_method_list.php');
5255
require_once(dirname(__FILE__) . '/recurly/subscription.php');
5356
require_once(dirname(__FILE__) . '/recurly/subscription_list.php');
5457
require_once(dirname(__FILE__) . '/recurly/subscription_addon.php');

lib/recurly/base.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,9 @@ public function getLinks() {
265265
'setup_fee_in_cents' => 'Recurly_CurrencyList',
266266
'shipping_address' => 'Recurly_ShippingAddress',
267267
'shipping_addresses' => 'Recurly_ShippingAddressList',
268+
'shipping_fee' => 'Recurly_ShippingFee',
269+
'shipping_method' => 'Recurly_ShippingMethod',
270+
'shipping_methods' => 'Recurly_ShippingMethodList',
268271
'subscription' => 'Recurly_Subscription',
269272
'subscriptions' => 'Recurly_SubscriptionList',
270273
'subscription_add_ons' => 'array',

lib/recurly/client.php

Lines changed: 3 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.19';
25+
public static $apiVersion = '2.20';
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.2';
53+
const API_CLIENT_VERSION = '2.12.3';
5454
const DEFAULT_ENCODING = 'UTF-8';
5555

5656
const GET = 'GET';
@@ -74,6 +74,7 @@ class Recurly_Client
7474
const PATH_INVOICES = '/invoices';
7575
const PATH_NOTES = '/notes';
7676
const PATH_PLANS = '/plans';
77+
const PATH_SHIPPING_METHOD = '/shipping_methods';
7778
const PATH_SUBSCRIPTIONS = '/subscriptions';
7879
const PATH_TRANSACTIONS = '/transactions';
7980
const PATH_MEASURED_UNITS = '/measured_units';

lib/recurly/purchase.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22
/**
33
* Class Recurly_Purchase
44
* @property Recurly_Account $account The account for the purchase. Can create an account or use existing.
5-
* @property Recurly_Adjustment[] $adjustments The array of adjustments for the purchase
6-
* @property string $collection_method The invoice collection method ('automatic' or 'manual')
7-
* @property string $currency The currency to use in this invoice
8-
* @property string $po_number The po number for the invoice
9-
* @property integer $net_terms The net terms of the invoice
10-
* @property string[] $coupon_codes An array of coupon codes to apply to the purchase
11-
* @property Recurly_Subscription[] $subscriptions An array of subscriptions to apply to the purchase
12-
* @property Recurly_GiftCard $gift_card A gift card to apply to the purchase
5+
* @property Recurly_Adjustment[] $adjustments The array of adjustments for the purchase.
6+
* @property string $collection_method The invoice collection method ('automatic' or 'manual').
7+
* @property string $currency The currency to use in this invoice.
8+
* @property string $po_number The po number for the invoice.
9+
* @property integer $net_terms The net terms of the invoice.
10+
* @property string[] $coupon_codes An array of coupon codes to apply to the purchase.
11+
* @property Recurly_Subscription[] $subscriptions An array of subscriptions to apply to the purchase.
12+
* @property Recurly_GiftCard $gift_card A gift card to apply to the purchase.
1313
* @property string $customer_notes Optional notes field. This will default to the Customer Notes text specified on the Invoice Settings page in your Recurly admin. Custom notes made on an invoice for a one time charge will not carry over to subsequent invoices.
1414
* @property string $terms_and_conditions Optional Terms and Conditions field. This will default to the Terms and Conditions text specified on the Invoice Settings page in your Recurly admin. Custom notes will stay with a subscription on all renewals.
1515
* @property string $vat_reverse_charge_notes Optional VAT Reverse Charge Notes only appear if you have EU VAT enabled or are using your own Avalara AvaTax account and the customer is in the EU, has a VAT number, and is in a different country than your own. This will default to the VAT Reverse Charge Notes text specified on the Tax Settings page in your Recurly admin, unless custom notes were created with the original subscription. Custom notes will stay with a subscription on all renewals.
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.
18+
* @property Recurly_ShippingFee[] $shipping_fees Optional array of shipping fees to apply to the purchase.
1819
*/
1920
class Recurly_Purchase extends Recurly_Resource
2021
{
@@ -115,7 +116,7 @@ protected function getWriteableAttributes() {
115116
'account', 'adjustments', 'collection_method', 'currency', 'po_number',
116117
'net_terms', 'subscriptions', 'gift_card', 'coupon_codes', 'customer_notes',
117118
'terms_and_conditions', 'vat_reverse_charge_notes', 'shipping_address_id',
118-
'gateway_code'
119+
'gateway_code', 'shipping_fees'
119120
);
120121
}
121122
}

lib/recurly/shipping_fee.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
/**
4+
* Class Recurly_ShippingFee
5+
* @property string $shipping_method_code Unique code to identify the shipping method.
6+
* @property integer $shipping_amount_in_cents The amount of this shipping fee.
7+
* @property Recurly_ShippingAddress $shipping_address Optional address this shipping fee is associated with.
8+
* @property string $shipping_address_id Optional id of the existing shipping address this fee is associated with.
9+
*/
10+
class Recurly_ShippingFee extends Recurly_Resource
11+
{
12+
protected function getNodeName() {
13+
return 'shipping_fee';
14+
}
15+
16+
protected function populateXmlDoc(&$doc, &$node, &$obj, $nested = false) {
17+
if ($this->isEmbedded($node, 'shipping_fees')) {
18+
$feeNode = $node->appendChild($doc->createElement($this->getNodeName()));
19+
parent::populateXmlDoc($doc, $feeNode, $obj, $nested);
20+
} else {
21+
parent::populateXmlDoc($doc, $node, $obj, $nested);
22+
}
23+
}
24+
25+
protected function getWriteableAttributes() {
26+
return array(
27+
'shipping_method_code', 'shipping_amount_in_cents', 'shipping_address',
28+
'shipping_address_id'
29+
);
30+
}
31+
}

lib/recurly/shipping_method.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
/**
4+
* Class Recurly_ShippingMethod
5+
* @property string $code Unique code to identify the shipping method.
6+
* @property string $name The name of the shipping method.
7+
* @property string $accounting_code The accounting code of the shipping method.
8+
* @property string $tax_code The tax code of the shipping method.
9+
* @property DateTime $created_at The date and time the shipping method was created.
10+
* @property DateTime $updated_at The date and time the shipping method was last updated.
11+
*/
12+
class Recurly_ShippingMethod extends Recurly_Resource
13+
{
14+
/**
15+
* @param string $code The shipping method code
16+
* @param Recurly_Client $client Optional client for the request, useful for mocking the client
17+
* @return object Recurly_Resource or null
18+
* @throws Recurly_Error
19+
*/
20+
public static function get($code, $client = null) {
21+
return Recurly_Base::_get(Recurly_ShippingMethod::uriForShippingMethod($code), $client);
22+
}
23+
24+
protected function uri() {
25+
if (!empty($this->_href))
26+
return $this->getHref();
27+
else
28+
return Recurly_ShippingMethod::uriForShippingMethod($this->code);
29+
}
30+
31+
protected static function uriForShippingMethod($code) {
32+
return Recurly_Client::PATH_SHIPPING_METHOD . '/' . rawurlencode($code);
33+
}
34+
35+
protected function getNodeName() {
36+
return 'shipping_method';
37+
}
38+
39+
protected function getWriteableAttributes() {
40+
return array();
41+
}
42+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
class Recurly_ShippingMethodList extends Recurly_Pager
4+
{
5+
public static function get($params = null, $client = null) {
6+
$uri = self::_uriWithParams(Recurly_Client::PATH_SHIPPING_METHOD, $params);
7+
return new self($uri, $client);
8+
}
9+
10+
protected function getNodeName() {
11+
return 'shipping_methods';
12+
}
13+
}

lib/recurly/subscription.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
* @property string $uuid Subscription's unique identifier.
4444
* @property string $timeframe now for immediate, renewal to perform when the subscription renews. Defaults to now.
4545
* @property string $gateway_code The unique identifier of a payment gateway used to specify which payment gateway you wish to process this subscriptions’ payments
46+
* @property string $shipping_method_code The unique identifier of the shipping method for this subscription.
47+
* @property integer $shipping_amount_in_cents The amount charged for shipping in cents.
4648
*/
4749
class Recurly_Subscription extends Recurly_Resource
4850
{
@@ -124,6 +126,15 @@ public function updateAtRenewal() {
124126
$this->_save(Recurly_Client::PUT, $this->uri());
125127
}
126128

129+
/**
130+
* Make an update that applies at the next bill date of the subscription.
131+
*
132+
* @throws Recurly_Error
133+
*/
134+
public function updateAtNextBillDate() {
135+
$this->timeframe = 'bill_date';
136+
$this->_save(Recurly_Client::PUT, $this->uri());
137+
}
127138

128139
/**
129140
* Terminate the subscription immediately and issue a full refund of the last renewal
@@ -267,7 +278,8 @@ protected function getWriteableAttributes() {
267278
'bank_account_authorized_at', 'revenue_schedule_type', 'gift_card',
268279
'shipping_address', 'shipping_address_id', 'imported_trial',
269280
'remaining_pause_cycles', 'custom_fields', 'auto_renew',
270-
'renewal_billing_cycles', 'gateway_code'
281+
'renewal_billing_cycles', 'gateway_code', 'shipping_method_code',
282+
'shipping_amount_in_cents'
271283
);
272284
}
273285
}

0 commit comments

Comments
 (0)