/** * {@inheritDoc} */ public function execute($request) { /** @var $request Refund */ RequestNotSupportedException::assertSupports($this, $request); $details = ArrayObject::ensureArrayObject($request->getModel()); if (null === $details['RESULT']) { return; } $refundableTrxTypes = array(Api::TRXTYPE_SALE, Api::TRXTYPE_DELAYED_CAPUTER, Api::TRXTYPE_VOICE_AUTHORIZATION); if (false == in_array($details['TRXTYPE'], $refundableTrxTypes)) { throw new LogicException(sprintf('You cannot refund transaction with type %s. Only these types could be refunded: %s', $details['TRXTYPE'], implode(', ', $refundableTrxTypes))); } $details->validateNotEmpty(array('PNREF'), true); $details['PURCHASE_TRXTYPE'] = $details['TRXTYPE']; $details['TRXTYPE'] = null; $details['PURCHASE_RESULT'] = $details['RESULT']; $details['RESULT'] = null; $details['ORIGID'] = $details['PNREF']; $details->replace($this->api->doCredit($details->toUnsafeArray())); }
/** * @test */ public function shouldUseSandboxApiEndpointIfSandboxTrue() { $testCase = $this; $clientMock = $this->createHttpClientMock(); $clientMock->expects($this->once())->method('send')->will($this->returnCallback(function (RequestInterface $request) use($testCase) { $testCase->assertEquals('https://pilot-payflowpro.paypal.com/', $request->getUri()); return new Response(200, [], $request->getBody()); })); $api = new Api(array('username' => 'theUsername', 'password' => 'thePassword', 'partner' => 'thePartner', 'vendor' => 'theVendor', 'tender' => 'theTender', 'sandbox' => true), $clientMock); $api->doCredit(array()); }