diff --git a/src/Controller/Component/PayPalComponent.php b/src/Controller/Component/PayPalComponent.php index 2927c12..8fb84ee 100644 --- a/src/Controller/Component/PayPalComponent.php +++ b/src/Controller/Component/PayPalComponent.php @@ -109,7 +109,7 @@ public function PaymentRedirect($remittanceIdentifier, $okUrl, $cancelUrl, $desc $payment = new Payment(); $payment->setPayer($payer); - $payment->setTransactions(array($transaction)); + $payment->setTransactions([$transaction]); $payment->setIntent('sale'); $this->PayPalPayments->createPayment($remittanceIdentifier, $payment, $okUrl, $cancelUrl); diff --git a/tests/TestCase/Controller/Component/PayPalComponentTest.php b/tests/TestCase/Controller/Component/PayPalComponentTest.php index d95e649..83bf541 100644 --- a/tests/TestCase/Controller/Component/PayPalComponentTest.php +++ b/tests/TestCase/Controller/Component/PayPalComponentTest.php @@ -87,10 +87,17 @@ public function testPaymentRedirectCreatePaymentFails() public function testPaymentRedirect() { + $this->PayPal->AddArticle('foo', 2, 1234, 'bar'); + $this->PayPal->Shipping = 100; + $this->PayPal->PayPalPayments = $this->getMockForModel('PayPal.PayPalPayments'); + $this->PayPal->PayPalPayments->expects($this->once()) ->method('createPayment') - ->with('ri', $this->anything(), 'https://ok', 'https://cancel') + ->with('ri', $this->callback(function($payment) { + $this->assertEquals(29.62 + 1, $payment->getTransactions()[0]->getAmount()->getTotal()); + return true; + }), 'https://ok', 'https://cancel') ->will($this->returnCallback(function($remittanceIdentifier, $payment, $okUrl, $cancelUrl){ $links = new \PayPal\Api\Links(); $links