doSale() public method

public doSale ( array $fields ) : array
$fields array
return array
Ejemplo n.º 1
0
    /**
     * {@inheritDoc}
     */
    public function execute($request)
    {
        /** @var $request Capture */
        RequestNotSupportedException::assertSupports($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'] = new SensitiveValue($card->getNumber());
                $model['CVV2'] = new SensitiveValue($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.');
            }
        }

        $model->replace($this->api->doSale($model->toUnsafeArray()));
    }
Ejemplo n.º 2
0
 /**
  * @test
  */
 public function shouldAddAuthorizeFieldsOnDoSaleCall()
 {
     $api = new Api(array('username' => 'theUsername', 'password' => 'thePassword', 'partner' => 'thePartner', 'vendor' => 'theVendor', 'tender' => 'theTender'), $this->createSuccessHttpClientStub());
     $result = $api->doSale(array());
     $this->assertArrayHasKey('USER', $result);
     $this->assertEquals('theUsername', $result['USER']);
     $this->assertArrayHasKey('PWD', $result);
     $this->assertEquals('thePassword', $result['PWD']);
     $this->assertArrayHasKey('PARTNER', $result);
     $this->assertEquals('thePartner', $result['PARTNER']);
     $this->assertArrayHasKey('VENDOR', $result);
     $this->assertEquals('theVendor', $result['VENDOR']);
     $this->assertArrayHasKey('TENDER', $result);
     $this->assertEquals('theTender', $result['TENDER']);
 }