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)); }
public function testRequestGetExpressCheckoutDetails() { $response = $this->client->requestSetExpressCheckout('123', 'http://www.foo.com/', 'http://www.foo.com/'); //guard $this->assertInstanceOf('JMS\\Payment\\PaypalBundle\\Client\\Response', $response); $this->assertTrue($response->body->has('TOKEN')); $response = $this->client->requestGetExpressCheckoutDetails($response->body->get('TOKEN')); $this->assertTrue($response->body->has('TOKEN')); $this->assertTrue($response->body->has('CHECKOUTSTATUS')); $this->assertEquals('PaymentActionNotInitiated', $response->body->get('CHECKOUTSTATUS')); $this->assertEquals('Success', $response->body->get('ACK')); }
/** * @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; }