From 76e846771b9d04a81eebe55fde22f7f5a46d09fb Mon Sep 17 00:00:00 2001 From: Dave Onnen Date: Mon, 30 Sep 2019 17:12:56 -0500 Subject: [PATCH 1/2] AP-8971 - match attribute names to Apruve --- src/Apruve/Invoice.php | 3 ++- src/Apruve/InvoiceItem.php | 1 - src/Apruve/Order.php | 3 ++- src/Apruve/OrderItem.php | 4 ++-- src/Apruve/ShipmentItem.php | 3 --- tests/Apruve/InvoiceItemTest.php | 2 -- tests/Apruve/InvoiceTest.php | 13 ++++++------- tests/Apruve/OrderItemTest.php | 4 ++-- tests/Apruve/OrderTest.php | 22 ++++++++++++++-------- tests/Apruve/ShipmentItemTest.php | 5 +---- tests/Apruve/ShipmentTest.php | 1 - 11 files changed, 29 insertions(+), 32 deletions(-) diff --git a/src/Apruve/Invoice.php b/src/Apruve/Invoice.php index d29513e..85752da 100644 --- a/src/Apruve/Invoice.php +++ b/src/Apruve/Invoice.php @@ -13,12 +13,12 @@ class Invoice extends ApruveObject { 'currency', 'merchant_notes', 'invoice_items', + 'tax_cents' ]; var $id; var $order_id; var $status; var $amount_cents; - var $price_total_cents; var $currency; var $merchant_notes; var $api_url; @@ -26,6 +26,7 @@ class Invoice extends ApruveObject { var $created_at; var $updated_at; var $invoice_items = []; + var $tax_cents; public function __construct( $invoice = [], $client = null ) { if ( array_key_exists( 'invoice_items', $invoice ) ) { diff --git a/src/Apruve/InvoiceItem.php b/src/Apruve/InvoiceItem.php index da91c56..475baba 100644 --- a/src/Apruve/InvoiceItem.php +++ b/src/Apruve/InvoiceItem.php @@ -8,7 +8,6 @@ class InvoiceItem extends ApruveObject { protected static $json_fields = [ 'title', - 'amount_cents', 'price_total_cents', 'quantity', 'price_ea_cents', diff --git a/src/Apruve/Order.php b/src/Apruve/Order.php index 61946de..14c245d 100644 --- a/src/Apruve/Order.php +++ b/src/Apruve/Order.php @@ -57,6 +57,8 @@ class Order extends ApruveObject { var $view_url; var $created_at; var $updated_at; + var $shopper_id; + var $customer_id; public function __construct( $order = [], $client = null ) { if ( array_key_exists( 'order_items', $order ) ) { @@ -94,7 +96,6 @@ public static function getInvoices( $apruveOrderId ) { public static function cancel( $apruveOrderId ) { $client = new Client(); - echo sprintf( __( self::$CANCEL_PATH, $apruveOrderId ) ); $response = $client->post( sprintf( __( self::$CANCEL_PATH ), $apruveOrderId ), '' ); return $response[0] == 200; diff --git a/src/Apruve/OrderItem.php b/src/Apruve/OrderItem.php index 4d71639..2471538 100644 --- a/src/Apruve/OrderItem.php +++ b/src/Apruve/OrderItem.php @@ -8,7 +8,7 @@ class OrderItem extends ApruveObject { protected static $hash_order = [ 'title', - 'amount_cents', + 'price_total_cents', 'price_ea_cents', 'quantity', 'merchant_notes', @@ -20,7 +20,7 @@ class OrderItem extends ApruveObject { ]; protected static $json_fields = [ 'title', - 'amount_cents', + 'price_total_cents', 'price_ea_cents', 'quantity', 'merchant_notes', diff --git a/src/Apruve/ShipmentItem.php b/src/Apruve/ShipmentItem.php index 6070818..619a268 100644 --- a/src/Apruve/ShipmentItem.php +++ b/src/Apruve/ShipmentItem.php @@ -8,7 +8,6 @@ class ShipmentItem extends ApruveObject { protected static $hash_order = [ 'title', - 'amount_cents', 'price_total_cents', 'quantity', 'price_ea_cents', @@ -26,7 +25,6 @@ class ShipmentItem extends ApruveObject { ]; protected static $json_fields = [ 'title', - 'amount_cents', 'price_total_cents', 'quantity', 'price_ea_cents', @@ -43,7 +41,6 @@ class ShipmentItem extends ApruveObject { 'currency', ]; var $title; - var $amount_cents; var $quantity; var $price_ea_cents; var $merchant_notes; diff --git a/tests/Apruve/InvoiceItemTest.php b/tests/Apruve/InvoiceItemTest.php index 01e1454..476f225 100644 --- a/tests/Apruve/InvoiceItemTest.php +++ b/tests/Apruve/InvoiceItemTest.php @@ -28,7 +28,6 @@ public function testToJsonString() { $this->assertJsonStringEqualsJsonString( '{ "title": "A title", - "amount_cents": 3400, "price_total_cents": 3400, "quantity": 1, "price_ea_cents": 3400, @@ -45,7 +44,6 @@ public function testToJsonString() { protected function setUp() { $this->item = new InvoiceItem( [ 'title' => 'A title', - 'amount_cents' => 3400, 'price_total_cents' => 3400, 'quantity' => 1, 'price_ea_cents' => 3400, diff --git a/tests/Apruve/InvoiceTest.php b/tests/Apruve/InvoiceTest.php index 58c5472..720c866 100644 --- a/tests/Apruve/InvoiceTest.php +++ b/tests/Apruve/InvoiceTest.php @@ -17,7 +17,6 @@ public function testPropertiesAreDefined() { 'order_id', 'status', 'amount_cents', - 'price_total_cents', 'currency', 'merchant_notes', 'api_url', @@ -25,6 +24,7 @@ public function testPropertiesAreDefined() { 'created_at', 'updated_at', 'invoice_items', + 'tax_cents' ] ); $this->assertEquals( 12, count( $vars ) ); @@ -39,7 +39,7 @@ public function testToJson() { "invoice_items": [ { "title": "test", - "amount_cents": 100, + "price_total_cents": 100, "quantity" : 1, "price_ea_cents": 100, "merchant_notes": null, @@ -47,10 +47,10 @@ public function testToJson() { "variant_info": null, "sku": null, "vendor": null, - "view_product_url": null, - "price_total_cents": null + "view_product_url": null } - ] + ], + "tax_cents": null }', $this->invoice->toJson() ); @@ -122,10 +122,9 @@ protected function setUp() { "invoice_items" => [ [ 'title' => 'test', - 'amount_cents' => 100, + 'price_total_cents' => 100, 'quantity' => 1, 'price_ea_cents' => 100 - ] ] ] ); diff --git a/tests/Apruve/OrderItemTest.php b/tests/Apruve/OrderItemTest.php index e82f8b3..a8541da 100644 --- a/tests/Apruve/OrderItemTest.php +++ b/tests/Apruve/OrderItemTest.php @@ -37,7 +37,7 @@ public function testToJsonString() { $this->assertJsonStringEqualsJsonString( '{ "title": "A title", - "amount_cents": 3400, + "price_total_cents": 3400, "price_ea_cents": 3400, "quantity": 1, "merchant_notes": "some notes.", @@ -54,7 +54,7 @@ protected function setUp() { $this->item = new OrderItem( [ 'title' => 'A title', 'sku' => 'sku', - 'amount_cents' => 3400, + 'price_total_cents' => 3400, 'price_ea_cents' => 3400, 'quantity' => 1, 'merchant_notes' => 'some notes.', diff --git a/tests/Apruve/OrderTest.php b/tests/Apruve/OrderTest.php index 58f2fda..bd5c3c9 100644 --- a/tests/Apruve/OrderTest.php +++ b/tests/Apruve/OrderTest.php @@ -34,8 +34,10 @@ public function testPropertiesAreDefined() { 'view_url', 'created_at', 'updated_at', + 'shopper_id', + 'customer_id' ] ); - $this->assertEquals( 20, count( $vars ) ); + $this->assertEquals( 22, count( $vars ) ); } @@ -57,9 +59,9 @@ public function testToJson() { "payment_term": [], "order_items": [{ "title": "a title", - "amount_cents": 4500, - "price_ea_cents": null, - "quantity": null, + "price_total_cents": 4500, + "price_ea_cents": 4500, + "quantity": 1, "merchant_notes": null, "description": null, "variant_info": null, @@ -83,7 +85,7 @@ public function testToHashString() { public function testToSecureString() { $this->assertEquals( - 'asdf1234order12346000USD50010002014-07-15T10:12:27-05:00falsea title4500', + 'asdf1234order12346000USD50010002014-07-15T10:12:27-05:00falsea title450045001', $this->po->toSecureString() ); } @@ -91,7 +93,7 @@ public function testToSecureString() { public function testToSecureHash() { Apruve\Client::init( 'a key', Apruve\Environment::DEV() ); $this->assertEquals( - hash( 'sha256', 'a keyasdf1234order12346000USD50010002014-07-15T10:12:27-05:00falsea title4500' ), + hash( 'sha256', 'a keyasdf1234order12346000USD50010002014-07-15T10:12:27-05:00falsea title450045001' ), $this->po->toSecureHash() ); } @@ -158,8 +160,10 @@ public function testSave() { 'order_items' => [ [ 'title' => 'a title', - 'amount_cents' => 4500, + 'price_total_cents' => 4500, + 'price_ea_cents' => 4500, 'order_id' => 'id', + 'quantity' => 1 ] ] ], @@ -246,8 +250,10 @@ protected function setUp() { 'order_items' => [ [ 'title' => 'a title', - 'amount_cents' => 4500, + 'price_total_cents' => 4500, + 'price_ea_cents' => 4500, 'order_id' => 'id', + 'quantity' => 1 ] ], ] ); diff --git a/tests/Apruve/ShipmentItemTest.php b/tests/Apruve/ShipmentItemTest.php index af3c80e..35a7651 100644 --- a/tests/Apruve/ShipmentItemTest.php +++ b/tests/Apruve/ShipmentItemTest.php @@ -11,7 +11,6 @@ public function testPropertiesAreDefined() { $this->assertEquals( array_keys( $item_vars ), array( 'title', - 'amount_cents', 'quantity', 'price_ea_cents', 'merchant_notes', @@ -25,14 +24,13 @@ public function testPropertiesAreDefined() { 'price_total_cents', 'currency' ) ); - $this->assertEquals( 14, count( $item_vars ) ); + $this->assertEquals( 13, count( $item_vars ) ); } public function testToJsonString() { $this->assertJsonStringEqualsJsonString( '{ "title": "A title", - "amount_cents": 3400, "quantity": 1, "price_ea_cents": 3400, "merchant_notes": "some notes.", @@ -52,7 +50,6 @@ public function testToJsonString() { protected function setUp() { $this->shipmentItem = new ShipmentItem( [ 'title' => 'A title', - 'amount_cents' => 3400, 'quantity' => 1, 'price_ea_cents' => 3400, 'merchant_notes' => 'some notes.', diff --git a/tests/Apruve/ShipmentTest.php b/tests/Apruve/ShipmentTest.php index 72b59c4..a742adc 100644 --- a/tests/Apruve/ShipmentTest.php +++ b/tests/Apruve/ShipmentTest.php @@ -55,7 +55,6 @@ public function testToJsonString() { "shipment_items": [ { "title": "a title", - "amount_cents": 4500, "price_ea_cents": null, "quantity": null, "merchant_notes": null, From fc4b24eb2270a1f96331654ca5d073ce5595ea0d Mon Sep 17 00:00:00 2001 From: Dave Onnen Date: Fri, 4 Oct 2019 15:58:01 -0500 Subject: [PATCH 2/2] AP-8971 - bumping the version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7386d3b..9af6299 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Please use [Github issues](https://github.com/apruve/apruve-php/issues) to reque Add this require to your `composer.json`: "require": { - "apruve/apruve-php": "~1.4" + "apruve/apruve-php": "~1.4.1" } **NOTE**: Be sure to update the version as you update the version of apruve-php