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

Shipping Address Support #269

Merged
merged 1 commit into from
Sep 12, 2016
Merged

Shipping Address Support #269

merged 1 commit into from
Sep 12, 2016

Conversation

bhelx
Copy link
Contributor

@bhelx bhelx commented Aug 31, 2016

Adding shipping address support. Allows adding and removing multiple shipping addresses to/from an account. You can also add/remove a shipping address on a subscription.

Usage

// work shipping address
$shad1 = new Recurly_ShippingAddress();
$shad1->nickname = "Work";
$shad1->first_name = "Verena";
$shad1->last_name = "Example";
$shad1->company = "Recurly Inc.";
$shad1->phone = "555-555-5555";
$shad1->email = "verena@example.com";
$shad1->address1 = "123 Main St.";
$shad1->city = "San Francisco";
$shad1->state = "CA";
$shad1->zip = "94110";
$shad1->country = "US";

// home shipping address
$shad2 = new Recurly_ShippingAddress();
$shad2->nickname = "Home";
$shad2->first_name = "Verena";
$shad2->last_name = "Example";
$shad2->phone = "555-555-5555";
$shad2->email = "verena@example.com";
$shad2->address1 = "123 Dolores St.";
$shad2->city = "San Francisco";
$shad2->state = "CA";
$shad2->zip = "94110";
$shad2->country = "US";

// some random billing info for the account
$billing_info = new Recurly_BillingInfo();
$billing_info->first_name = 'Verena';
$billing_info->last_name = 'Example';
$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';

$account_code = uniqid();
$account = new Recurly_Account();
$account->account_code = $account_code;
$account->billing_info = $billing_info;
$account->shipping_addresses = array($shad1, $shad2);

$account->create();

$shads = $account->shipping_addresses;

foreach ($shads->get() as $s) {
  print $s->nickname . "\n";
}

// or get shipping addresses from the account code
foreach (Recurly_ShippingAddressList::get($account_code) as $s) {
  print $s->nickname . "\n";
}

// Mom's shipping address
$shad3 = new Recurly_ShippingAddress();
$shad3->nickname = "Mom";
$shad3->first_name = "Mom";
$shad3->last_name = "Example";
$shad3->phone = "555-555-5555";
$shad3->email = "mom@example.com";
$shad3->address1 = "123 Home St.";
$shad3->city = "San Francisco";
$shad3->state = "CA";
$shad3->zip = "94110";
$shad3->country = "US";

$subscription = new Recurly_Subscription();
$subscription->plan_code = 'gold';
$subscription->currency = 'USD';

$account_code = uniqid();
$account = new Recurly_Account();
$account->account_code = $account_code;
$account->billing_info = $billing_info;

$subscription->account = $account;

// using our mom shipping address
$subscription->shipping_address = $shad3;

$subscription->create();

@bhelx bhelx added the WIP label Aug 31, 2016
@bhelx bhelx force-pushed the shipping_address_support branch from 36554cd to 131e0d6 Compare September 1, 2016 00:47
@@ -67,6 +67,7 @@ class Recurly_Client
const PATH_INVOICES = '/invoices';
const PATH_NOTES = '/notes';
const PATH_PLANS = '/plans';
const PATH_SHIPPING_ADDRESSES = '/shipping_addresses';
Copy link

Choose a reason for hiding this comment

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

I'd love to just skip these constants.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, removing them.

@bhelx bhelx removed the WIP label Sep 6, 2016
}
// protected function getRequiredAttributes() {
// return array();
// }
Copy link

Choose a reason for hiding this comment

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

Let's just drop this?

@drewish
Copy link

drewish commented Sep 9, 2016

Tested this out and it's looking good. Let's whack the comment, add a CHANGELOG message and squash it down.

@bhelx bhelx force-pushed the shipping_address_support branch from 510260c to e66d37a Compare September 9, 2016 16:06
@bhelx
Copy link
Contributor Author

bhelx commented Sep 9, 2016

@drewish thanks. Updated and squashed.

@drewish
Copy link

drewish commented Sep 12, 2016

+1

@drewish drewish merged commit 1f6ebb5 into api-2.4 Sep 12, 2016
@drewish drewish deleted the shipping_address_support branch September 12, 2016 15:00
@drewish drewish mentioned this pull request Sep 15, 2016
@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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants