See also: https://www.x.com/sites/default/files/payflowgateway_guide.pdf
Author: Ton Sharp (Forma-PRO@66ton99.org.ua)
Example #1
0
 /**
  * {@inheritDoc}
  */
 public function execute($request)
 {
     /** @var $request Capture */
     if (false == $this->supports($request)) {
         throw RequestNotSupportedException::createActionNotSupported($this, $request);
     }
     $model = new ArrayObject($request->getModel());
     if (is_numeric($model['RESULT'])) {
         return;
     }
     $cardFields = array('ACCT', 'CVV2', 'EXPDATE');
     if (false == $model->validateNotEmpty($cardFields, false)) {
         try {
             $this->payment->execute($obtainCreditCard = new ObtainCreditCard());
             $card = $obtainCreditCard->obtain();
             $model['EXPDATE'] = new SensitiveValue($card->getExpireAt()->format('my'));
             $model['ACCT'] = $card->getNumber();
             $model['CVV2'] = $card->getSecurityCode();
         } catch (RequestNotSupportedException $e) {
             throw new LogicException('Credit card details has to be set explicitly or there has to be an action that supports ObtainCreditCard request.');
         }
     }
     $buzzRequest = new Request();
     $buzzRequest->setFields($model->toUnsafeArray());
     $response = $this->api->doPayment($buzzRequest);
     $model->replace($response);
 }
Example #2
0
 /**
  * {@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()));
 }
Example #3
0
 /**
  * @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());
 }