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.12 #348

Merged
merged 3 commits into from
May 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Tests/Recurly/Purchase_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function defaultResponses() {
array('POST', '/purchases', 'purchases/create-201.xml'),
array('POST', '/purchases/preview', 'purchases/preview-200.xml'),
array('POST', '/purchases/authorize', 'purchases/authorize-200.xml'),
array('POST', '/purchases/pending', 'purchases/pending-200.xml'),
);
}

Expand Down Expand Up @@ -91,6 +92,17 @@ public function testAuthorizePurchase() {
$this->assertNull($collection->charge_invoice->uuid);
}

public function testPendingPurchase() {
$purchase = $this->mockPurchase();
$purchase->account->email = 'benjamin.dumonde@example.com';
$purchase->account->billing_info->external_hpp_type = 'adyen';
$collection = Recurly_Purchase::pending($purchase, $this->client);

$this->assertInstanceOf('Recurly_InvoiceCollection', $collection);
$this->assertInstanceOf('Recurly_Invoice', $collection->charge_invoice);
$this->assertNull($collection->charge_invoice->uuid);
}

public function testTransactionError() {
$this->client->addResponse('POST', '/purchases', 'purchases/create-422.xml');
$purchase = $this->mockPurchase();
Expand Down
66 changes: 66 additions & 0 deletions Tests/fixtures/purchases/pending-200.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
HTTP/1.1 200 OK
Content-Type: application/xml; charset=utf-8
Location: https://api.recurly.com/v2/invoices

<?xml version="1.0" encoding="UTF-8"?>
<invoice_collection>
<charge_invoice href="">
<account href="https://api.recurly.com/v2/accounts/c442b36c-c64f-41d7-b8e1-9c04e7a6ff82"/>
<address>
<address1>400 Alabama St</address1>
<address2 nil="nil"></address2>
<city>San Francisco</city>
<state>CA</state>
<zip>94110</zip>
<country>US</country>
<phone nil="nil"></phone>
</address>
<uuid nil="nil"></uuid>
<state>pending</state>
<invoice_number_prefix></invoice_number_prefix>
<invoice_number nil="nil"></invoice_number>
<po_number nil="nil"></po_number>
<vat_number nil="nil"></vat_number>
<subtotal_in_cents type="integer">1000</subtotal_in_cents>
<tax_in_cents type="integer">0</tax_in_cents>
<total_in_cents type="integer">1000</total_in_cents>
<subtotal_after_discount_in_cents type="integer">1000</subtotal_after_discount_in_cents>
<currency>USD</currency>
<created_at nil="nil"></created_at>
<updated_at nil="nil"></updated_at>
<attempt_next_collection_at type="datetime">2017-05-17T16:36:56Z</attempt_next_collection_at>
<closed_at nil="nil"></closed_at>
<terms_and_conditions nil="nil"></terms_and_conditions>
<customer_notes nil="nil"></customer_notes>
<recovery_reason nil="nil"></recovery_reason>
<net_terms type="integer">0</net_terms>
<collection_method>automatic</collection_method>
<line_items type="array">
<adjustment href="" type="charge">
<account href="https://api.recurly.com/v2/accounts/c442b36c-c64f-41d7-b8e1-9c04e7a6ff82"/>
<uuid>3d86103d63f614d7aeee8341c98b2655</uuid>
<state>pending</state>
<description nil="nil"></description>
<accounting_code nil="nil"></accounting_code>
<product_code>4549449c-5870-4845-b672-1d07f15e87dd</product_code>
<origin>debit</origin>
<unit_amount_in_cents type="integer">1000</unit_amount_in_cents>
<quantity type="integer">1</quantity>
<discount_in_cents type="integer">0</discount_in_cents>
<tax_in_cents type="integer">0</tax_in_cents>
<total_in_cents type="integer">1000</total_in_cents>
<currency>USD</currency>
<taxable type="boolean">false</taxable>
<tax_exempt type="boolean">false</tax_exempt>
<tax_code nil="nil"></tax_code>
<start_date type="datetime">2017-05-17T16:36:56Z</start_date>
<end_date nil="nil"></end_date>
<created_at nil="nil"></created_at>
<updated_at nil="nil"></updated_at>
<revenue_schedule_type>at_invoice</revenue_schedule_type>
</adjustment>
</line_items>
<transactions type="array">
</transactions>
</charge_invoice>
</invoice_collection>
2 changes: 1 addition & 1 deletion lib/recurly/client.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Recurly_Client
/**
* API Version
*/
public static $apiVersion = '2.11';
public static $apiVersion = '2.12';

/**
* The path to your CA certs. Use only if needed (if you can't fix libcurl/php).
Expand Down
2 changes: 2 additions & 0 deletions lib/recurly/gift_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @property Recurly_Stub $gifter_account The URL of the Recurly_Account for the giver of the gift.
* @property Recurly_Stub $recipient_account The URL of the Recurly_Account for the recipient of the gift.
* @property Recurly_Stub $invoice The URL of the Recurly_Invoice for the invoice of the gift card.
* @property Recurly_Stub $purchase_invoice The URL of the charge invoice for the gift card redemption.
* @property Recurly_Stub $redemption_invoice The URL of the credit invoice for the gift card purchase.
* @property int $id The unique identifier of the gift card.
* @property string $redemption_code The unique redemption code for the gift card, generated by Recurly. Will be 16 characters, alphanumeric, displayed uppercase, but accepted in any case at redemption. Used by the recipient_account to create a credit in the amount of the unit_amount_in_cents on their account.
* @property int $balance_in_cents The remaining credit on the recipient_account associated with this gift card. Only shows once the gift card has been redeemed. Can be used to create gift card balance displays for your customers.
Expand Down
12 changes: 12 additions & 0 deletions lib/recurly/purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ public static function authorize($purchase, $client = null) {
return Recurly_Base::_post('/purchases/authorize', $purchase->xml(), $client);
}

/**
* Use for Adyen HPP transaction requests. This runs
* the validations but not the transactions.
*
* @param Recurly_Purchase Our purchase data.
* @param RecurlyClient Optional client for the request, useful for mocking the client
* @return Recurly_InvoiceCollection
*/
public static function pending($purchase, $client = null) {
return Recurly_Base::_post('/purchases/pending', $purchase->xml(), $client);
}

public function __construct($href = null, $client = null) {
parent::__construct($href, $client);
$this->adjustments = array();
Expand Down