コード例 #1
0
ファイル: CaptureActionTest.php プロジェクト: eamador/Payum
 /**
  * @test
  */
 public function shouldForcePaymentActionSale()
 {
     $action = new CaptureAction();
     $action->setGateway($this->createGatewayMock());
     $action->execute($request = new Capture(['PAYMENTREQUEST_0_PAYMENTACTION' => 'FooBarBaz']));
     $model = $request->getModel();
     $this->assertArrayHasKey('PAYMENTREQUEST_0_PAYMENTACTION', $model);
     $this->assertEquals(Api::PAYMENTACTION_SALE, $model['PAYMENTREQUEST_0_PAYMENTACTION']);
 }
コード例 #2
0
ファイル: CaptureActionTest.php プロジェクト: nksoo/Payum
 /**
  * @test
  */
 public function shouldSetZeroGatewayActionAsSell()
 {
     $action = new CaptureAction();
     $action->setGateway($this->createGatewayMock());
     $action->execute($request = new Capture(array()));
     $model = $request->getModel();
     $this->assertArrayHasKey('PAYMENTREQUEST_0_PAYMENTACTION', $model);
     $this->assertEquals(Api::PAYMENTACTION_SALE, $model['PAYMENTREQUEST_0_PAYMENTACTION']);
 }
コード例 #3
0
 /**
  * @param Capture $request
  *
  * @throws RequestNotSupportedException if the action dose not support the request.
  */
 public function execute($request)
 {
     /** @var Transaction $model */
     $model = $request->getModel();
     try {
         $invoice = $this->bitPayClient->createInvoice($model->getRequest()->jsonSerialize());
     } catch (\Exception $ex) {
         throw new RequestNotSupportedException($ex->getMessage());
     }
     $model->setResponse($invoice);
 }
コード例 #4
0
 function it_does_not_supports_capture(Capture $model, Capture $request)
 {
     $request->getModel()->willReturn($model);
     $this->supports($request)->shouldReturn(false);
 }
コード例 #5
0
 /**
  * @test
  */
 public function shouldSetDetailsBackToPaymentEvenIfExceptionThrown()
 {
     $expectedDetails = array('foo' => 'fooVal');
     $payment = new Payment();
     $payment->setDetails($expectedDetails);
     $gatewayMock = $this->createGatewayMock();
     $gatewayMock->expects($this->at(0))->method('execute')->with($this->isInstanceOf('Payum\\Core\\Request\\GetHumanStatus'))->will($this->returnCallback(function (GetHumanStatus $request) {
         $request->markPending();
     }));
     $gatewayMock->expects($this->at(1))->method('execute')->with($this->isInstanceOf('Payum\\Core\\Request\\Capture'))->will($this->returnCallback(function (Capture $request) {
         $details = $request->getModel();
         $details['bar'] = 'barVal';
         throw new \Exception();
     }));
     $action = new CapturePaymentAction();
     $action->setGateway($gatewayMock);
     $this->setExpectedException('Exception');
     $action->execute($capture = new Capture($payment));
     $this->assertSame($payment, $capture->getFirstModel());
     $this->assertInstanceOf('ArrayAccess', $capture->getModel());
     $this->assertEquals(array('foo' => 'fooVal', 'bar' => 'barVal'), $payment->getDetails());
 }
コード例 #6
0
 /**
  * @test
  */
 public function shouldKeepOrderEvenIfExceptionThrown()
 {
     $details = array('foo' => 'fooVal');
     $order = new Order();
     $order->setDetails($details);
     $paymentMock = $this->createPaymentMock();
     $paymentMock->expects($this->at(0))->method('execute')->with($this->isInstanceOf('Payum\\Core\\Request\\GetHumanStatus'))->will($this->returnCallback(function (GetHumanStatus $request) {
         $request->markPending();
     }));
     $paymentMock->expects($this->at(1))->method('execute')->with($this->isInstanceOf('Payum\\Core\\Request\\Capture'))->will($this->throwException(new \Exception()));
     $action = new CaptureOrderAction();
     $action->setPayment($paymentMock);
     $this->setExpectedException('Exception');
     $action->execute($capture = new Capture($order));
     $this->assertSame($order, $capture->getModel());
 }
コード例 #7
0
 public function testShouldDoNothingIfCustomerSetOnPreExecute()
 {
     $model = new \ArrayObject(['customer' => 'aCustomerId', 'card' => 'theTokenMustBeObtained', 'local' => ['save_card' => true]]);
     $request = new Capture($model);
     $gatewayMock = $this->createGatewayMock();
     $gatewayMock->expects($this->never())->method('execute');
     $context = new Context($gatewayMock, $request, []);
     $extension = new CreateCustomerExtension();
     $extension->onPreExecute($context);
     $this->assertEquals(['customer' => 'aCustomerId', 'card' => 'theTokenMustBeObtained', 'local' => ['save_card' => true]], (array) $request->getModel());
 }
コード例 #8
0
 function it_supports_capture(Transaction $model, Capture $request)
 {
     $request->getModel()->willReturn($model);
     $this->supports($request)->shouldReturn(true);
 }