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

Purchases endpoint #315

Merged
merged 1 commit into from
May 31, 2017
Merged

Purchases endpoint #315

merged 1 commit into from
May 31, 2017

Conversation

bhelx
Copy link
Contributor

@bhelx bhelx commented May 17, 2017

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->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->product_code = "abcd123";
$adjustment->unit_amount_in_cents = 1000;
$adjustment->currency = 'USD';
$adjustment->quantity = 1;
$adjustment->revenue_schedule_type = 'at_invoice';
$purchase->adjustments = array($adjustment);

// Create a preview invoice or a live invoice
try {
  $previewInvoice = Recurly_Purchase::preview($purchase);
  $invoice = Recurly_Purchase::invoice($purchase);
} catch (Recurly_ValidationError $e) {
  // You can get an idea why a purchase failed looking at these objects:
  var_dump($e->errors->transaction_error);  // Recurly_TransactionError
  var_dump($e->errors->transaction);   // Recurly_Transaction
} 

@bhelx bhelx added the WIP label May 17, 2017
"<?xml version=\"1.0\"?>\n<shipping_address><address1>123 Dolores St.</address1><city>San Francisco</city><state>CA</state><zip>94110</zip><country>US</country><phone>555-555-5555</phone><email>verena@example.com</email><nickname>Work</nickname><first_name>Verena</first_name><last_name>Example</last_name><company>Recurly Inc.</company></shipping_address>\n",
$shad->xml()
);
}
Copy link

Choose a reason for hiding this comment

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

👍 now i get a failing spec if i comment out the other branch in Recurly_ShippingAddress::populateXmlDoc()

@@ -30,7 +30,7 @@ public function mockPurchase() {
$adjustment->quantity = 1;
$adjustment->revenue_schedule_type = 'at_invoice';

$purchase->adjustments = array($adjustment);
$purchase->adjustments[] = $adjustment;
Copy link

Choose a reason for hiding this comment

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

Did we decide we needed this change?

$invoice = Recurly_Purchase::preview($purchase, $this->client);

$this->assertInstanceOf('Recurly_Invoice', $invoice);
}
Copy link

Choose a reason for hiding this comment

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

Should we assert a null uuid here?

@@ -134,7 +134,7 @@ protected function populateXmlDoc(&$doc, &$node, &$obj, $nested = false)
elseif (is_int($child)) {
if (is_object($childValue)) {
// e.g. "<subscription_add_ons><subscription_add_on>...</subscription_add_on></subscription_add_ons>"
$childValue->populateXmlDoc($doc, $attribute_node, $childValue);
$childValue->populateXmlDoc($doc, $attribute_node, $childValue, true);
Copy link

Choose a reason for hiding this comment

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

What's this change doing?

@bhelx bhelx removed the WIP label May 23, 2017
@drewish drewish merged commit 23cb67a into api_version_2_6 May 31, 2017
@drewish drewish deleted the purchases branch May 31, 2017 00:05
@bhelx bhelx mentioned this pull request Jun 2, 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