Payum\Paypal\ExpressCheckout\Nvp\Action\Api\DoVoidAction::execute PHP Method

execute() public method

public execute ( $request )
$request DoVoid
    public function execute($request)
    {
        RequestNotSupportedException::assertSupports($this, $request);
        $model = ArrayObject::ensureArrayObject($request->getModel());
        if (null === $model['AUTHORIZATIONID']) {
            throw new LogicException('AUTHORIZATIONID must be set. Has user not authorized this transaction?');
        }
        $model->replace($this->api->doVoid((array) $model));
    }

Usage Example

Beispiel #1
0
 /**
  * @test
  */
 public function shouldCallApiDoVoidMethodAndUpdateModelFromResponseOnSuccess()
 {
     $apiMock = $this->createApiMock();
     $apiMock->expects($this->once())->method('DoVoid')->will($this->returnCallback(function () {
         return array('AUTHORIZATIONID' => 'theTransactionId', 'MSGSUBID' => 'aMessageId');
     }));
     $action = new DoVoidAction();
     $action->setApi($apiMock);
     $request = new DoVoid(array('AUTHORIZATIONID' => 'theTransactionId'));
     $action->execute($request);
     $model = $request->getModel();
     $this->assertArrayHasKey('AUTHORIZATIONID', $model);
     $this->assertEquals('theTransactionId', $model['AUTHORIZATIONID']);
     $this->assertArrayHasKey('MSGSUBID', $model);
     $this->assertEquals('aMessageId', $model['MSGSUBID']);
 }