/** * {@inheritDoc} * * @param Capture $request */ public function execute($request) { RequestNotSupportedException::assertSupports($this, $request); $model = ArrayObject::ensureArrayObject($request->getModel()); $httpRequest = new GetHttpRequest(); $this->gateway->execute($httpRequest); //we are back from be2bill site so we have to just update model. if (isset($httpRequest->query['EXECCODE'])) { $model->replace($httpRequest->query); } else { throw new HttpPostRedirect($this->api->getOffsiteUrl(), $this->api->prepareOffsitePayment($model->toUnsafeArray())); } }
/** * @test */ public function shouldKeepSupportedOnPrepareOffsitePayment() { $api = new Api(array('identifier' => 'anId', 'password' => 'aPass', 'sandbox' => true), $this->createHttpClientMock(), $this->createHttpMessageFactory()); $post = $api->prepareOffsitePayment(array('AMOUNT' => 100, 'DESCRIPTION' => 'a desc')); $this->assertInternalType('array', $post); $this->assertArrayHasKey('AMOUNT', $post); $this->assertEquals(100, $post['AMOUNT']); $this->assertArrayHasKey('DESCRIPTION', $post); $this->assertEquals('a desc', $post['DESCRIPTION']); }
/** * {@inheritDoc} * * @param Capture $request */ public function execute($request) { RequestNotSupportedException::assertSupports($this, $request); $model = ArrayObject::ensureArrayObject($request->getModel()); $httpRequest = new GetHttpRequest(); $this->gateway->execute($httpRequest); //we are back from be2bill site so we have to just update model. if (isset($httpRequest->query['EXECCODE'])) { $model->replace($httpRequest->query); } else { $extradata = $model['EXTRADATA'] ? json_decode($model['EXTRADATA'], true) : []; if (false == isset($extradata['capture_token']) && $request->getToken()) { $extradata['capture_token'] = $request->getToken()->getHash(); } if (false == isset($extradata['notify_token']) && $request->getToken() && $this->tokenFactory) { $notifyToken = $this->tokenFactory->createNotifyToken($request->getToken()->getGatewayName(), $request->getToken()->getDetails()); $extradata['notify_token'] = $notifyToken->getHash(); } $model['EXTRADATA'] = json_encode($extradata); throw new HttpPostRedirect($this->api->getOffsiteUrl(), $this->api->prepareOffsitePayment($model->toUnsafeArray())); } }