Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API version 2.7 #319

Merged
merged 2 commits into from
Jul 14, 2017
Merged

API version 2.7 #319

merged 2 commits into from
Jul 14, 2017

Conversation

bhelx
Copy link
Contributor

@bhelx bhelx commented Jun 27, 2017

API v2.7 only has 1 feature, the updates to the purchases endpoint.

$purchase = new Recurly_Purchase();
$purchase->currency = 'USD';
$purchase->collection_method = 'automatic';
$purchase->account = new Recurly_Account();
$purchase->account->account_code = 'aba9209a-aa61-4790-8e61-0a2692435fee';
$purchase->account->first_name = "Benjamin";
$purchase->account->last_name = "Du Monde";
$purchase->account->address->phone = "555-555-5555";
$purchase->account->address->email = "verena@example.com";
$purchase->account->address->address1 = "123 Main St.";
$purchase->account->address->city = "San Francisco";
$purchase->account->address->state = "CA";
$purchase->account->address->zip = "94110";
$purchase->account->address->country = "US";

$billing_info = new Recurly_BillingInfo();
$billing_info->number = '4111-1111-1111-1111';
$billing_info->month = 12;
$billing_info->year = 2019;
$billing_info->verification_value = '123';
$billing_info->address1 = '400 Alabama St';
$billing_info->city = 'San Francisco';
$billing_info->state = 'CA';
$billing_info->country = 'US';
$billing_info->zip = '94110';

$purchase->account->billing_info = $billing_info;

$adjustment = new Recurly_Adjustment();
$adjustment->unit_amount_in_cents = 1000;
$adjustment->quantity = 1;

$purchase->adjustments = array($adjustment);

$subscription = new Recurly_Subscription();
$subscription->plan_code = 'pp';

$purchase->subscriptions = array($subscription);

$purchase->coupon_codes = array('couponcode', 'rqw311ofo6');

$gift_card = new Recurly_GiftCard();
$gift_card->redemption_code = "FCJ7GEY4HO8WR16Q";
$purchase->gift_card = $gift_card;

try {
  $invoice = Recurly_Purchase::invoice($purchase);
  print($invoice);
} catch (Recurly_ValidationError $e) {
  print($e);
} catch (Recurly_Error $e) {
  print($e);
}

@bhelx bhelx added the WIP label Jun 27, 2017
@@ -7,6 +7,9 @@
* @property string $currency The currency to use in this invoice
* @property string $po_number The po number for the invoice
* @property integer $net_terms The net terms of the invoice
* @property array $coupon_codes An array of coupon codes to apply to the purchase
* @property array $subscriptions An array of subscriptions to apply to the purchase
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the PHPDoc docs for types, it seems like we can document the types in the array using:

 * @property string[] $coupon_codes An array of coupon codes to apply to the purchase
 * @property Recurly_Subscription[] $subscriptions An array of subscriptions to apply to the purchase

Also, I'm not sure apply is the right verb to use for subscriptions.

@@ -7,6 +7,9 @@
* @property string $currency The currency to use in this invoice
* @property string $po_number The po number for the invoice
* @property integer $net_terms The net terms of the invoice
* @property array $coupon_codes An array of coupon codes to apply to the purchase
* @property array $subscriptions An array of subscriptions to apply to the purchase
* @property Recurly_GiftCard $gift_card A GiftCard to apply to the purchase
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's change A GiftCard to A gift card

@@ -136,4 +143,9 @@ protected function getWriteableAttributes() {
'shipping_address', 'shipping_address_id'
);
}
private function isEmbedded($node) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'd talked about moving this up the inheritance tree at one point since there's a few classes using it. What do you think about doing that as part of this PR?

@bhelx bhelx removed the WIP label Jun 30, 2017
@@ -4,7 +4,6 @@ class Recurly_Subscription extends Recurly_Resource
{
public function __construct($href = null, $client = null) {
parent::__construct($href, $client);
$this->subscription_add_ons = array();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bhelx and I discovered that we can't remove this or it'll break the serialization for the subscription creation endpoint. it was being removed because the purchases endpoint doesn't allow an empty array. we need to get get a fix into the purchases endpoint before we can merge this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it works for purchases if we remove this line here, but breaks the library in other places.

@bhelx bhelx added the WIP label Jul 10, 2017
@bhelx bhelx force-pushed the update_purchases_endpoint_for_2_7 branch from a70c759 to 2f3bbb0 Compare July 13, 2017 18:26
@bhelx bhelx removed the WIP label Jul 13, 2017
@bhelx bhelx force-pushed the update_purchases_endpoint_for_2_7 branch from 2f3bbb0 to 98e61fc Compare July 13, 2017 21:09
@bhelx bhelx force-pushed the update_purchases_endpoint_for_2_7 branch from 98e61fc to 10fd024 Compare July 13, 2017 21:14
@drewish drewish merged commit be463fd into master Jul 14, 2017
@drewish drewish deleted the update_purchases_endpoint_for_2_7 branch July 14, 2017 15:55
@bhelx bhelx mentioned this pull request Jul 14, 2017
@bhelx bhelx added the V2 V2 Client label Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
V2 V2 Client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants