Payum\Paypal\ProHosted\Nvp\Action\Api\GetTransactionDetailsAction::execute PHP Method

execute() public method

{@inheritDoc}
public execute ( $request )
    public function execute($request)
    {
        /** @var $request GetTransactionDetails */
        RequestNotSupportedException::assertSupports($this, $request);
        $model = ArrayObject::ensureArrayObject($request->getModel());
        if (null == $model['txn_id']) {
            throw new LogicException('TRANSACTIONID must be set.');
        }
        $fields = new ArrayObject([]);
        $fields['TRANSACTIONID'] = $model['txn_id'];
        $result = $this->api->getTransactionDetails((array) $fields);
        $model->replace($result);
    }

Usage Example

 /**
  * @test
  */
 public function shouldCallApiGetTransactionDetailsAndUpdateModelFromResponseOnSuccess()
 {
     $apiMock = $this->createApiMock();
     $apiMock->expects($this->once())->method('getTransactionDetails')->will($this->returnCallback(function () {
         return array('PAYMENTSTATUS' => 'theStatus');
     }));
     $action = new GetTransactionDetailsAction();
     $action->setApi($apiMock);
     $request = new GetTransactionDetails(array('txn_id' => 'aTransactionId'));
     $action->execute($request);
     $model = $request->getModel();
     $this->assertArrayHasKey('PAYMENTSTATUS', $model);
     $this->assertEquals('theStatus', $model['PAYMENTSTATUS']);
 }
GetTransactionDetailsAction