public function testSendError() { $this->setMockHttpResponse('CaptureFailure.txt'); $response = $this->request->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('Failure', $response->getMessage()); }
/** * @dataProvider tokenSetterProvider */ public function testStoreTokenCanOnlyBeOneOrZeroIfSetInRequest($parameter, $expectation) { $this->request->setToken('{ABCDEF}'); $this->request->setStoreToken($parameter); $data = $this->request->getData(); $this->assertSame($expectation, $data['StoreToken']); }
/** * Set the items in this order * * @param ItemBag|array $items An array of items in this order * @return AbstractRequest */ public function setItems($items) { if (!empty($items) && !$items instanceof ItemBag) { foreach ($items as &$item) { $item = new Item($item); } } parent::setItems($items); }
public function testMixedBasketWithSpecialChars() { $items = new \Omnipay\Common\ItemBag(array(new \Omnipay\Common\Item(array('name' => "Denisé's Odd & Wierd £name? #12345678901234567890123456789012345678901234567890123456789012345678901234567890", 'description' => 'Description', 'quantity' => 2, 'price' => 4.23)), array('name' => "Denisé's \"Odd\" & Wierd £discount? #", 'description' => 'My Offer', 'quantity' => 2, 'price' => -0.1), array('name' => '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901', 'description' => 'My 2nd Offer', 'quantity' => 1, 'price' => -1.6))); // Names/descriptions should be max 100 characters in length, once invalid characters have been removed. $expected = '<basket><item>' . '<description>Denis\'s Odd & Wierd name 123456789012345678901234567890123456789012345678901234567890123456789012345</description><quantity>2</quantity>' . '<unitNetAmount>4.23</unitNetAmount><unitTaxAmount>0.00</unitTaxAmount>' . '<unitGrossAmount>4.23</unitGrossAmount><totalGrossAmount>8.46</totalGrossAmount>' . '</item><discounts>' . '<discount><fixed>0.2</fixed><description>Denis\'s "Odd" Wierd discount? #</description></discount>' . '<discount><fixed>1.6</fixed><description>1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890</description></discount>' . '</discounts></basket>'; $this->request->setItems($items); $data = $this->request->getData(); $this->assertArrayHasKey('BasketXML', $data); $this->assertContains($expected, $data['BasketXML'], 'Basket XML does not match the expected output'); }
/** * Set the correct configuration sending * * @return \Omnipay\Common\Message\ResponseInterface */ public function send() { $this->configure(); return parent::send(); }
/** * Set items for request * * Cast the items to instances of \Omnipay\BarclaysEpdq\Item * * @param array|\Omnipay\Common\ItemBag|\Omnipay\Common\Item[] $items * @return AbstractRequest */ public function setItems($items) { $newItems = new ItemBag(); foreach ($items as $item) { $newItems->add(new Item($item->getParameters())); } return parent::setItems($newItems); }
/** * @param bool $serialize Determines whether the return value will be a string or object * @return string|CardReference */ public function getCardReference($serialize = true) { $value = parent::getCardReference(); if ($serialize) { $value = (string) $value; } return $value; }
public function testData() { $data = $this->request->getData(); $this->assertSame('123456', $data['TransactionID']); }
/** * Create a new Request * * @param ClientInterface $httpClient A Guzzle client to make API calls with * @param HttpRequest $httpRequest A Symfony HTTP request object * @param SoapClient $soapClient */ public function __construct(ClientInterface $httpClient, HttpRequest $httpRequest, SoapClient $soapClient = null) { parent::__construct($httpClient, $httpRequest); $this->soapClient = $soapClient; }
public function testGetDataDinersClub() { $this->request->getCard()->setNumber('30569309025904'); $data = $this->request->getData(); $this->assertSame('dc', $data['CardType']); }
/** * Send a payment request to the gateway, and redirect appropriately * * @param AbstractRequest $request * @param Market_TransactionModel $transaction * * @return string */ private function sendPaymentRequest(AbstractRequest $request, Market_TransactionModel $transaction) { // try { /** @var ResponseInterface $response */ $response = $request->send(); $this->updateTransaction($transaction, $response); if ($response->isRedirect()) { // redirect to off-site gateway return $response->redirect(); } $order = $transaction->order; if ($response->isSuccessful()) { return $order->returnUrl; } else { craft()->userSession->setError(Craft::t("Payment error: " . $transaction->message)); return $order->cancelUrl; } }
/** * Create a new Request * * @param ClientInterface $httpClient A Guzzle client to make API calls with * @param HttpRequest $httpRequest A Symfony HTTP request object */ public function __construct(ClientInterface $httpClient, HttpRequest $httpRequest) { parent::__construct($httpClient, $httpRequest); $this->request = $this->createRequest(); }
/** * Create a new Request * * @param SoapClient $soapClient A SoapClient to make calls with * @param ClientInterface $httpClient A Guzzle client to make API calls with * @param HttpRequest $httpRequest A Symfony HTTP request object */ public function __construct(SoapClient $soapClient, ClientInterface $httpClient = null, HttpRequest $httpRequest = null) { parent::__construct($httpClient, $httpRequest); $this->soapClient = $soapClient; $this->initialize(); }
/** * Override the abstract method to add requirement that it must start with 4 numeric characters * * @param string|int $value The transaction ID (merchant order) to set for the transaction */ public function setTransactionId($value) { $start = substr($value, 0, 4); $numerics = 0; foreach (str_split($start) as $char) { if (is_numeric($char)) { $numerics++; } else { break; } } $value = str_pad(substr($start, 0, $numerics), 4, 0, STR_PAD_LEFT) . substr($value, $numerics); parent::setTransactionId($value); }
/** * Sets the card information. * * @param CreditCard $value * @return AbstractRequest Provides a fluent interface */ public function setCard($value) { if ($value && is_array($value)) { $value = new CreditCard($value); } return parent::setCard($value); }
/** * Workaround for https://github.com/thephpleague/omnipay-common/issues/13 */ public function setAmount($value) { if (is_float($value) && $value === 0.0) { $value = '0.00'; } parent::setAmount($value); }