コード例 #1
0
 /**
  * @param \JMS\Payment\CoreBundle\Model\FinancialTransactionInterface $transaction
  * @param \JMS\Payment\PaypalBundle\Client\Response $response
  * @return null
  * @throws \JMS\Payment\CoreBundle\Plugin\Exception\FinancialException
  */
 protected function throwUnlessSuccessResponse(Response $response, FinancialTransactionInterface $transaction)
 {
     if ($response->isSuccess()) {
         return;
     }
     $transaction->setResponseCode($response->body->get('ACK'));
     $transaction->setReasonCode($response->body->get('L_ERRORCODE0'));
     $ex = new FinancialException('PayPal-Response was not successful: ' . $response);
     $ex->setFinancialTransaction($transaction);
     throw $ex;
 }
コード例 #2
0
 /**
  * @expectedException JMS\Payment\CoreBundle\Plugin\Exception\FinancialException
  * @expectedExceptionMessage PayPal-Response was not successful
  */
 public function testThrowFinancialExceptionOnRequestingPaymentDetailsWhileApproving()
 {
     $expectedToken = 'the_express_checkout_token';
     $notSuccessResponse = new Response(array());
     //guard
     $this->assertFalse($notSuccessResponse->isSuccess());
     $clientMock = $this->createClientMock($mockedMethods = array('requestGetExpressCheckoutDetails', 'requestSetExpressCheckout'));
     $clientMock->expects($this->never())->method('requestSetExpressCheckout');
     $clientMock->expects($this->once())->method('requestGetExpressCheckoutDetails')->with($this->equalTo($expectedToken))->will($this->returnValue($notSuccessResponse));
     $plugin = new ExpressCheckoutPlugin('return_url', 'cancel_url', $clientMock);
     $transaction = $this->createTransaction($amount = 100, 'EUR');
     $transaction->getExtendedData()->set('express_checkout_token', $expectedToken);
     $plugin->approve($transaction, false);
 }