/** * @param array $data */ public function __construct(array $data) { $this->data = $data; for ($i = 0; isset($data['PAYMENTREQUEST_' . $i . '_AMT']); $i++) { $cart = new Cart(); $cart->unserialize($data, $i); if (!$cart->isEmpty()) { $this->carts[] = $cart; } } }
/** * Main payment function * * @param Cart $cart * @throws CheckoutRequestFailedException * @return RedirectResponse */ public function doExpressCheckout(Cart $cart) { $data = array('METHOD' => 'SetExpressCheckout', 'RETURNURL' => (string) $this->returnUrl, 'CANCELURL' => (string) $this->cancelUrl, 'REQCONFIRMSHIPPING' => $cart->shipping ? "1" : "0", 'NOSHIPPING' => $cart->shipping ? "0" : "1", 'ALLOWNOTE' => "1") + $cart->serialize($this->account, $this->currency, '0'); $return = $this->process($data); if ($return['ACK'] == 'Success') { return new RedirectResponse($return, $this->gate); } throw new CheckoutRequestFailedException($return, $data); }