Skip to content

Commit

Permalink
Merge branch 'release/1.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviocopes committed Dec 22, 2016
2 parents 8f95f23 + 27630e7 commit 890aef3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v1.1.2
## 22-12-2016

1. [](#new)
* Allow PayPal to list the items in its transaction details

# v1.1.1
## 11-12-2016

Expand Down
2 changes: 1 addition & 1 deletion blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Shopping Cart PayPal Express Addon
version: 1.1.1
version: 1.1.2
description: "Add PayPal Express checkout to the Grav Shopping Cart Plugin. Requires a PayPal Premier / Business account."
icon: shopping-cart
author:
Expand Down
22 changes: 19 additions & 3 deletions gateways/paypal_express/gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,14 @@ public function onShoppingCartPreparePayment(Event $event)

$this->grav['session']->order = $order->toArray();

$items = [];
$items = new \Omnipay\PayPal\PayPalItemBag();

foreach ($order->products as $product) {
$items[] = ['name' => $product['product']['title'], 'quantity' => $product['quantity'], 'price' => $product['product']['price']];
$items->add(array(
'name' => $product['product']['title'],
'quantity' => $product['quantity'],
'price' => $product['product']['price'],
));
}

$params = [
Expand Down Expand Up @@ -123,12 +128,23 @@ public function onShoppingCartPay(Event $event)
$pluginConfig = $this->grav['config']->get('plugins.shoppingcart');
$currency = $pluginConfig['general']['currency'];

$items = new \Omnipay\PayPal\PayPalItemBag();

foreach ($order->products as $product) {
$items->add(array(
'name' => $product['product']['title'],
'quantity' => $product['quantity'],
'price' => $product['product']['price'],
));
}

$response = $gateway->completePurchase([
'payer_id' => $event['payer_id'],
'transactionReference' => $event['transactionReference'],
'amount' => $order->amount,
'shippingAmount' => $order->shipping['cost'],
'currency' => $currency,
])->send();
])->setItems($items)->send();

if ($response->isSuccessful()) {
// mark order as complete
Expand Down

0 comments on commit 890aef3

Please sign in to comment.