Skip to content

Commit

Permalink
bug #101 Temporarily remove 'items' from order creation API call (Zal…
Browse files Browse the repository at this point in the history
…es0123)

This PR was merged into the 1.0-dev branch.

Discussion
----------

They make it impossible to update the order with e.g. different taxes

Commits
-------

7b82561 Temporarily remove 'items' from order creation API call
2d57e7b Remove items from spec
  • Loading branch information
SirDomin authored Sep 14, 2020
2 parents 69b779e + 2d57e7b commit 36548b0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 52 deletions.
60 changes: 9 additions & 51 deletions spec/Api/CreateOrderApiSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,8 @@ function it_creates_pay_pal_order_based_on_given_payment(
$data['purchase_units'][0]['amount']['value'] === 100 &&
$data['purchase_units'][0]['amount']['currency_code'] === 'PLN' &&
$data['purchase_units'][0]['amount']['breakdown']['shipping']['currency_code'] === 'PLN' &&
$data['purchase_units'][0]['amount']['breakdown']['shipping']['value'] === 10 &&
$data['purchase_units'][0]['items'][0]['name'] === 'PRODUCT_ONE' &&
$data['purchase_units'][0]['items'][0]['quantity'] === 1 &&
$data['purchase_units'][0]['items'][0]['unit_amount']['value'] === 90 &&
$data['purchase_units'][0]['items'][0]['unit_amount']['currency_code'] === 'PLN';
$data['purchase_units'][0]['amount']['breakdown']['shipping']['value'] === 10
;
})
)->willReturn(['status' => 'CREATED', 'id' => 123]);

Expand Down Expand Up @@ -169,11 +166,8 @@ function it_creates_pay_pal_order_with_shipping_address_based_on_given_payment(
$data['purchase_units'][0]['shipping']['address']['address_line_1'] === 'Hobbit St. 123' &&
$data['purchase_units'][0]['shipping']['address']['admin_area_2'] === 'Minas Tirith' &&
$data['purchase_units'][0]['shipping']['address']['postal_code'] === '000' &&
$data['purchase_units'][0]['shipping']['address']['country_code'] === 'US' &&
$data['purchase_units'][0]['items'][0]['name'] === 'PRODUCT_ONE' &&
$data['purchase_units'][0]['items'][0]['quantity'] === 1 &&
$data['purchase_units'][0]['items'][0]['unit_amount']['value'] === 90 &&
$data['purchase_units'][0]['items'][0]['unit_amount']['currency_code'] === 'PLN';
$data['purchase_units'][0]['shipping']['address']['country_code'] === 'US'
;
})
)->willReturn(['status' => 'CREATED', 'id' => 123]);

Expand Down Expand Up @@ -255,15 +249,8 @@ function it_creates_pay_pal_order_with_more_than_one_product(
$data['purchase_units'][0]['shipping']['address']['address_line_1'] === 'Hobbit St. 123' &&
$data['purchase_units'][0]['shipping']['address']['admin_area_2'] === 'Minas Tirith' &&
$data['purchase_units'][0]['shipping']['address']['postal_code'] === '000' &&
$data['purchase_units'][0]['shipping']['address']['country_code'] === 'US' &&
$data['purchase_units'][0]['items'][0]['name'] === 'PRODUCT_ONE' &&
$data['purchase_units'][0]['items'][0]['quantity'] === 1 &&
$data['purchase_units'][0]['items'][0]['unit_amount']['value'] === 90 &&
$data['purchase_units'][0]['items'][0]['unit_amount']['currency_code'] === 'PLN' &&
$data['purchase_units'][0]['items'][1]['name'] === 'PRODUCT_TWO' &&
$data['purchase_units'][0]['items'][1]['quantity'] === 2 &&
$data['purchase_units'][0]['items'][1]['unit_amount']['value'] === 40 &&
$data['purchase_units'][0]['items'][1]['unit_amount']['currency_code'] === 'PLN';
$data['purchase_units'][0]['shipping']['address']['country_code'] === 'US'
;
})
)->willReturn(['status' => 'CREATED', 'id' => 123]);

Expand Down Expand Up @@ -345,19 +332,8 @@ function it_creates_pay_pal_order_with_non_neutral_tax_and_changed_quantity(
$data['purchase_units'][0]['shipping']['address']['address_line_1'] === 'Hobbit St. 123' &&
$data['purchase_units'][0]['shipping']['address']['admin_area_2'] === 'Minas Tirith' &&
$data['purchase_units'][0]['shipping']['address']['postal_code'] === '000' &&
$data['purchase_units'][0]['shipping']['address']['country_code'] === 'US' &&
$data['purchase_units'][0]['items'][0]['name'] === 'PRODUCT_ONE' &&
$data['purchase_units'][0]['items'][0]['quantity'] === 1 &&
$data['purchase_units'][0]['items'][0]['unit_amount']['value'] === 50 &&
$data['purchase_units'][0]['items'][0]['unit_amount']['currency_code'] === 'PLN' &&
$data['purchase_units'][0]['items'][0]['tax']['value'] === 10 &&
$data['purchase_units'][0]['items'][0]['tax']['currency_code'] === 'PLN' &&
$data['purchase_units'][0]['items'][1]['name'] === 'PRODUCT_ONE' &&
$data['purchase_units'][0]['items'][1]['quantity'] === 1 &&
$data['purchase_units'][0]['items'][1]['unit_amount']['value'] === 50 &&
$data['purchase_units'][0]['items'][1]['unit_amount']['currency_code'] === 'PLN' &&
$data['purchase_units'][0]['items'][1]['tax']['value'] === 10 &&
$data['purchase_units'][0]['items'][1]['tax']['currency_code'] === 'PLN';
$data['purchase_units'][0]['shipping']['address']['country_code'] === 'US'
;
})
)->willReturn(['status' => 'CREATED', 'id' => 123]);

Expand Down Expand Up @@ -451,25 +427,7 @@ function it_creates_pay_pal_order_with_more_than_one_product_with_different_tax_
$data['purchase_units'][0]['shipping']['address']['address_line_1'] === 'Hobbit St. 123' &&
$data['purchase_units'][0]['shipping']['address']['admin_area_2'] === 'Minas Tirith' &&
$data['purchase_units'][0]['shipping']['address']['postal_code'] === '000' &&
$data['purchase_units'][0]['shipping']['address']['country_code'] === 'US' &&
$data['purchase_units'][0]['items'][0]['name'] === 'PRODUCT_ONE' &&
$data['purchase_units'][0]['items'][0]['quantity'] === 1 &&
$data['purchase_units'][0]['items'][0]['unit_amount']['value'] === 90 &&
$data['purchase_units'][0]['items'][0]['unit_amount']['currency_code'] === 'PLN' &&
$data['purchase_units'][0]['items'][0]['tax']['value'] === 2 &&
$data['purchase_units'][0]['items'][0]['tax']['currency_code'] === 'PLN' &&
$data['purchase_units'][0]['items'][1]['name'] === 'PRODUCT_TWO' &&
$data['purchase_units'][0]['items'][1]['quantity'] === 1 &&
$data['purchase_units'][0]['items'][1]['unit_amount']['value'] === 40 &&
$data['purchase_units'][0]['items'][1]['unit_amount']['currency_code'] === 'PLN' &&
$data['purchase_units'][0]['items'][1]['tax']['value'] === 1 &&
$data['purchase_units'][0]['items'][1]['tax']['currency_code'] === 'PLN' &&
$data['purchase_units'][0]['items'][2]['name'] === 'PRODUCT_TWO' &&
$data['purchase_units'][0]['items'][2]['quantity'] === 1 &&
$data['purchase_units'][0]['items'][2]['unit_amount']['value'] === 40 &&
$data['purchase_units'][0]['items'][2]['unit_amount']['currency_code'] === 'PLN' &&
$data['purchase_units'][0]['items'][2]['tax']['value'] === 1 &&
$data['purchase_units'][0]['items'][2]['tax']['currency_code'] === 'PLN'
$data['purchase_units'][0]['shipping']['address']['country_code'] === 'US'
;
})
)->willReturn(['status' => 'CREATED', 'id' => 123]);
Expand Down
3 changes: 2 additions & 1 deletion src/Api/CreateOrderApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ public function create(string $token, PaymentInterface $payment, string $referen
],
],
'soft_descriptor' => 'Sylius PayPal Payment',
'items' => $payPalItemData['items'],
// TODO: figure out how to update items while updating PayPal order
// 'items' => $payPalItemData['items'],
],
],
'application_context' => [
Expand Down

0 comments on commit 36548b0

Please sign in to comment.