public function testShouldAllowGetAuthenticateExpressCheckoutTokenUrlInProdMode() { $expectedUrl = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=foobar'; $token = 'foobar'; $client = new Client($this->createAuthenticationStrategyMock(), $debug = true); $this->assertEquals($expectedUrl, $client->getAuthenticateExpressCheckoutTokenUrl($token)); }
/** * @param \JMS\Payment\CoreBundle\Model\FinancialTransactionInterface $transaction * @param string $paymentAction * * @throws \JMS\Payment\CoreBundle\Plugin\Exception\ActionRequiredException if user has to authenticate the token * * @return string */ protected function obtainExpressCheckoutToken(FinancialTransactionInterface $transaction, $paymentAction) { $data = $transaction->getExtendedData(); if ($data->has('express_checkout_token')) { return $data->get('express_checkout_token'); } $opts = $data->has('checkout_params') ? $data->get('checkout_params') : array(); $opts['PAYMENTREQUEST_0_PAYMENTACTION'] = $paymentAction; $opts['PAYMENTREQUEST_0_CURRENCYCODE'] = $transaction->getPayment()->getPaymentInstruction()->getCurrency(); $response = $this->client->requestSetExpressCheckout($transaction->getRequestedAmount(), $this->getReturnUrl($data), $this->getCancelUrl($data), $opts); $this->throwUnlessSuccessResponse($response, $transaction); $data->set('express_checkout_token', $response->body->get('TOKEN')); $authenticateTokenUrl = $this->client->getAuthenticateExpressCheckoutTokenUrl($response->body->get('TOKEN')); $actionRequest = new ActionRequiredException('User must authorize the transaction.'); $actionRequest->setFinancialTransaction($transaction); $actionRequest->setAction(new VisitUrl($authenticateTokenUrl)); throw $actionRequest; }