From 8ed0d9974209960a647293ea65f65780c528549e Mon Sep 17 00:00:00 2001 From: Tymotheos Szulc Date: Fri, 19 Mar 2021 15:17:00 -0400 Subject: [PATCH 01/11] feat: add card payment with cvd verification --- src/Message/PurchaseRequest.php | 61 +++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/src/Message/PurchaseRequest.php b/src/Message/PurchaseRequest.php index 3f0b244..63b4dc1 100644 --- a/src/Message/PurchaseRequest.php +++ b/src/Message/PurchaseRequest.php @@ -6,11 +6,43 @@ class PurchaseRequest extends AbstractRequest { + /** + * CVD value is deliberately bypassed or is not provided by the merchant. + * + * @var int + * @see https://developer.moneris.com/en/Documentation/NA/E-Commerce%20Solutions/API/Purchase + */ + const CVD_BYPASSED = 0; + + /** + * CVD value is present. + * + * @var int + * @see https://developer.moneris.com/en/Documentation/NA/E-Commerce%20Solutions/API/Purchase + */ + const CVD_PRESENT = 1; + + /** + * CVD value is on the card, but is illegible. + * + * @var int + * @see https://developer.moneris.com/en/Documentation/NA/E-Commerce%20Solutions/API/Purchase + */ + const CVD_ILLEGIBLE = 2; + + /** + * Cardholder states that the card has no CVD imprint. + * + * @var int + * @see https://developer.moneris.com/en/Documentation/NA/E-Commerce%20Solutions/API/Purchase + */ + const NO_CVD = 9; + public function getData() { $data = null; - $this->validate('orderNumber', 'amount', 'paymentMethod'); + $this->validate('orderNumber', 'cryptType', 'amount', 'paymentMethod'); $paymentMethod = $this->getPaymentMethod(); @@ -32,7 +64,32 @@ public function getData() $data = $request->asXML(); break; - // Todo: card & token payment + case 'card': + $this->validate('card'); + + $request = new \SimpleXMLElement(''); + $request->addChild('store_id', $this->getMerchantId()); + $request->addChild('api_token', $this->getMerchantKey()); + + $card = $this->getCard(); + + $purchase = $request->addChild('purchase'); + $purchase->addChild('pan', $card->getNumber()); + $purchase->addChild('expdate', $card->getExpiryDate('ym')); + $purchase->addChild('order_id', $this->getOrderNumber()); + $purchase->addChild('cust_id', 'Transaction_'.$this->getOrderNumber()); + $purchase->addChild('amount', $this->getAmount()); + $purchase->addChild('crypt_type', $this->getCryptType()); + $purchase->addChild('dynamic_descriptor', $this->getDescription()); + + $cvd_info = $purchase->addChild('cvd_info'); + $cvd_info->addChild('cvd_indicator', self::CVD_PRESENT); + $cvd_info->addChild('cvd_value', $card->getCvv()); + + $data = $request->asXML(); + break; + + // Todo: token payment default: throw new InvalidRequestException('Invalid payment method'); From 24f77d2579aa046e6ca7390d9743e7035e1a4e60 Mon Sep 17 00:00:00 2001 From: Tymotheos Szulc Date: Fri, 19 Mar 2021 15:18:00 -0400 Subject: [PATCH 02/11] feat: custom validation --- src/Message/AbstractRequest.php | 73 +++++++++++++++++++++++++++++++++ src/Message/PurchaseRequest.php | 2 +- 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/src/Message/AbstractRequest.php b/src/Message/AbstractRequest.php index 886b634..43e570d 100644 --- a/src/Message/AbstractRequest.php +++ b/src/Message/AbstractRequest.php @@ -2,8 +2,34 @@ namespace Omnipay\Moneris\Message; +use Omnipay\Common\Exception\InvalidRequestException; + abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest { + const MAIL_ORDER_TELEPHONE_ORDER_SINGLE = 1; + const MAIL_ORDER_TELEPHONE_ORDER_RECURRING = 2; + const MAIL_ORDER_TELEPHONE_ORDER_INSTALMENT = 3; + const MAIL_ORDER_TELEPHONE_ORDER_UNKNOWN_CLASSIFICATION = 4; + const AUTHENTICATED_E_COMMERCE_TRANSACTION_VBV = 5; + const NON_AUTHENTICATED_E_COMMERCE_TRANSACTION_VBV = 6; + const SSL_ENABLED_MERCHANT = 7; + + /** + * Allowable values for the e-commerce transaction category being processed + * + * @var array + * @see https://developer.moneris.com/en/Documentation/NA/E-Commerce%20Solutions/API/Purchase + */ + const ECOMMERCE_INDICATORS = array( + self::MAIL_ORDER_TELEPHONE_ORDER_SINGLE, + self::MAIL_ORDER_TELEPHONE_ORDER_RECURRING, + self::MAIL_ORDER_TELEPHONE_ORDER_INSTALMENT, + self::MAIL_ORDER_TELEPHONE_ORDER_UNKNOWN_CLASSIFICATION, + self::AUTHENTICATED_E_COMMERCE_TRANSACTION_VBV, + self::NON_AUTHENTICATED_E_COMMERCE_TRANSACTION_VBV, + self::SSL_ENABLED_MERCHANT + ); + public $testEndpoint = 'https://esqa.moneris.com:443/gateway2/servlet/MpgRequest'; public $liveEndpoint = 'https://www3.moneris.com:443/gateway2/servlet/MpgRequest'; @@ -77,6 +103,53 @@ protected function getHttpMethod() return 'POST'; } + /** + * Validate the request. + * + * This method is called internally by gateways to avoid wasting time with an API call + * when the request is clearly invalid. + * + * @param string ... a variable length list of required parameters + * @throws InvalidRequestException + * @see Omnipay\Common\ParametersTrait::validate() + */ + public function validate(...$args) + { + foreach ($args as $key) { + $value = $this->parameters->get($key); + + switch ($key) { + case 'orderNumber': + if (! isset($value)) { + throw new InvalidRequestException("The $key parameter is required"); + } elseif (strlen($value) > 50) { + throw new InvalidRequestException("The $key parameter cannot be longer than 50 characters"); + } + break; + + case 'cryptType': + if (! isset($value)) { + throw new InvalidRequestException("The $key parameter is required"); + } elseif (! in_array($value, self::ECOMMERCE_INDICATORS)) { + throw new InvalidRequestException("The $key is invalid"); + } + break; + + case 'description': + if (strlen($value) > 20) { + throw new InvalidRequestException("The $key parameter cannot be longer than 20 characters"); + } + break; + + default: + if (! isset($value)) { + throw new InvalidRequestException("The $key parameter is required"); + } + break; + } + } + } + public function sendData($data) { $headers = [ diff --git a/src/Message/PurchaseRequest.php b/src/Message/PurchaseRequest.php index 63b4dc1..cb62756 100644 --- a/src/Message/PurchaseRequest.php +++ b/src/Message/PurchaseRequest.php @@ -42,7 +42,7 @@ public function getData() { $data = null; - $this->validate('orderNumber', 'cryptType', 'amount', 'paymentMethod'); + $this->validate('orderNumber', 'cryptType', 'amount', 'paymentMethod', 'description'); $paymentMethod = $this->getPaymentMethod(); From d4c3799fcca9e8fb29ae59db9d38a570b42ed08c Mon Sep 17 00:00:00 2001 From: Tymotheos Szulc Date: Fri, 19 Mar 2021 15:31:12 -0400 Subject: [PATCH 03/11] fix: can't pass up empty fields --- src/Message/PurchaseRequest.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Message/PurchaseRequest.php b/src/Message/PurchaseRequest.php index cb62756..da0ef70 100644 --- a/src/Message/PurchaseRequest.php +++ b/src/Message/PurchaseRequest.php @@ -61,6 +61,10 @@ public function getData() $res_purchase_cc->addChild('amount', $this->getAmount()); $res_purchase_cc->addChild('crypt_type', $this->getCryptType()); + if ($this->getDescription()) { + $res_purchase_cc->addChild('dynamic_descriptor', $this->getDescription()); + } + $data = $request->asXML(); break; @@ -80,7 +84,10 @@ public function getData() $purchase->addChild('cust_id', 'Transaction_'.$this->getOrderNumber()); $purchase->addChild('amount', $this->getAmount()); $purchase->addChild('crypt_type', $this->getCryptType()); - $purchase->addChild('dynamic_descriptor', $this->getDescription()); + + if ($this->getDescription()) { + $purchase->addChild('dynamic_descriptor', $this->getDescription()); + } $cvd_info = $purchase->addChild('cvd_info'); $cvd_info->addChild('cvd_indicator', self::CVD_PRESENT); From 9d48758e455be1b28deb29e3da6affd21673afb6 Mon Sep 17 00:00:00 2001 From: Tymotheos Szulc Date: Fri, 19 Mar 2021 15:33:05 -0400 Subject: [PATCH 04/11] chore: docblock --- src/Message/AbstractRequest.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Message/AbstractRequest.php b/src/Message/AbstractRequest.php index 43e570d..eb6cca4 100644 --- a/src/Message/AbstractRequest.php +++ b/src/Message/AbstractRequest.php @@ -106,9 +106,6 @@ protected function getHttpMethod() /** * Validate the request. * - * This method is called internally by gateways to avoid wasting time with an API call - * when the request is clearly invalid. - * * @param string ... a variable length list of required parameters * @throws InvalidRequestException * @see Omnipay\Common\ParametersTrait::validate() From a4bc1d6abe36a1817f6a4036d95e6e5fccfd122c Mon Sep 17 00:00:00 2001 From: Tymotheos Szulc Date: Mon, 22 Mar 2021 16:32:00 -0400 Subject: [PATCH 05/11] fix: make sure description is set & not more than 20 chars --- src/Message/AbstractRequest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Message/AbstractRequest.php b/src/Message/AbstractRequest.php index eb6cca4..ab2bd23 100644 --- a/src/Message/AbstractRequest.php +++ b/src/Message/AbstractRequest.php @@ -133,7 +133,7 @@ public function validate(...$args) break; case 'description': - if (strlen($value) > 20) { + if (isset($value) && strlen($value) > 20) { throw new InvalidRequestException("The $key parameter cannot be longer than 20 characters"); } break; From 3f7f2c205702596ea81ebbdc147be5c23c02c016 Mon Sep 17 00:00:00 2001 From: Tymotheos Szulc Date: Mon, 22 Mar 2021 16:33:20 -0400 Subject: [PATCH 06/11] feat: make sure orderNumber isn't empty --- src/Message/AbstractRequest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Message/AbstractRequest.php b/src/Message/AbstractRequest.php index ab2bd23..fc10114 100644 --- a/src/Message/AbstractRequest.php +++ b/src/Message/AbstractRequest.php @@ -119,6 +119,8 @@ public function validate(...$args) case 'orderNumber': if (! isset($value)) { throw new InvalidRequestException("The $key parameter is required"); + } elseif (empty($value)) { + throw new InvalidRequestException("The $key parameter cannot be empty"); } elseif (strlen($value) > 50) { throw new InvalidRequestException("The $key parameter cannot be longer than 50 characters"); } From 93095b280f0b33c01583d6b26d5652c24e20e5b7 Mon Sep 17 00:00:00 2001 From: Tymotheos Szulc Date: Mon, 22 Mar 2021 16:34:14 -0400 Subject: [PATCH 07/11] feat: use Omnipay CreditCard validation --- src/Message/PurchaseRequest.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Message/PurchaseRequest.php b/src/Message/PurchaseRequest.php index da0ef70..f003cb9 100644 --- a/src/Message/PurchaseRequest.php +++ b/src/Message/PurchaseRequest.php @@ -42,7 +42,7 @@ public function getData() { $data = null; - $this->validate('orderNumber', 'cryptType', 'amount', 'paymentMethod', 'description'); + $this->validate('paymentMethod', 'orderNumber', 'cryptType', 'amount', 'description'); $paymentMethod = $this->getPaymentMethod(); @@ -71,12 +71,13 @@ public function getData() case 'card': $this->validate('card'); + $card = $this->getCard(); + $card->validate(); + $request = new \SimpleXMLElement(''); $request->addChild('store_id', $this->getMerchantId()); $request->addChild('api_token', $this->getMerchantKey()); - $card = $this->getCard(); - $purchase = $request->addChild('purchase'); $purchase->addChild('pan', $card->getNumber()); $purchase->addChild('expdate', $card->getExpiryDate('ym')); From 2e5d269f39e5fa58f44d4d3fb1befd93b416acd3 Mon Sep 17 00:00:00 2001 From: Tymotheos Szulc Date: Mon, 22 Mar 2021 16:34:35 -0400 Subject: [PATCH 08/11] feat: tests --- tests/Message/PurchaseRequestTest.php | 172 +++++++++++++++++++++++++- 1 file changed, 171 insertions(+), 1 deletion(-) diff --git a/tests/Message/PurchaseRequestTest.php b/tests/Message/PurchaseRequestTest.php index d0ee3cb..3e7d0f4 100644 --- a/tests/Message/PurchaseRequestTest.php +++ b/tests/Message/PurchaseRequestTest.php @@ -2,6 +2,7 @@ namespace Omnipay\Moneris\Tests\Message; +use Omnipay\Common\Exception\InvalidCreditCardException; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Moneris\Message\PurchaseRequest; use Omnipay\Tests\TestCase; @@ -17,11 +18,25 @@ protected function setUp() $this->request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); } - public function test_an_invalid_payment_method_should_throw_an_exception_for_the_purchase_request() + public function test_missing_payment_method_should_throw_an_exception_for_the_purchase_request() { $this->request->initialize([ 'orderNumber' => 'XXXX-XXXX', + 'cryptType' => 1, + 'cardReference' => 'FAKE_CARD_REFERENCE', + 'amount' => 5.00, + ]); + + $this->expectException(InvalidRequestException::class); + $this->request->send(); + } + + public function test_an_invalid_payment_method_should_throw_an_exception_for_the_purchase_request() + { + $this->request->initialize([ 'paymentMethod' => 'test', + 'orderNumber' => 'XXXX-XXXX', + 'cryptType' => 1, 'cardReference' => 'FAKE_CARD_REFERENCE', 'amount' => 5.00, ]); @@ -36,4 +51,159 @@ public function test_an_invalid_payment_method_should_throw_an_exception_for_the $this->fail('Purchase with an invalid payment method did not throw an InvalidRequestException.'); } + + public function test_missing_order_number_should_throw_an_exception_for_the_purchase_request() + { + $this->request->initialize([ + 'paymentMethod' => 'payment_profile', + 'cryptType' => 1, + 'cardReference' => 'FAKE_CARD_REFERENCE', + 'amount' => 5.00, + ]); + + $this->expectException(InvalidRequestException::class); + $this->request->send(); + } + + public function test_an_invalid_order_number_should_throw_an_exception_for_the_purchase_request() + { + $this->request->initialize([ + 'paymentMethod' => 'payment_profile', + 'orderNumber' => '', + 'cryptType' => 1, + 'cardReference' => 'FAKE_CARD_REFERENCE', + 'amount' => 5.00, + ]); + + try { + $this->request->send(); + } catch (InvalidRequestException $e) { + $this->assertEquals('', $this->request->getOrderNumber()); + + return; + } + $this->fail('Purchase with an invalid order number did not throw an InvalidRequestException.'); + } + + public function test_missing_crypt_type_should_throw_an_exception_for_the_purchase_request() + { + $this->request->initialize([ + 'paymentMethod' => 'payment_profile', + 'orderNumber' => 'XXXX-XXXX', + 'cardReference' => 'FAKE_CARD_REFERENCE', + 'amount' => 5.00, + ]); + + $this->expectException(InvalidRequestException::class); + $this->request->send(); + } + + public function test_an_invalid_crypt_type_should_throw_an_exception_for_the_purchase_request() + { + $this->request->initialize([ + 'paymentMethod' => 'payment_profile', + 'orderNumber' => 'XXXX-XXXX', + 'cryptType' => 0, + 'cardReference' => 'FAKE_CARD_REFERENCE', + 'amount' => 5.00, + ]); + + try { + $this->request->send(); + } catch (InvalidRequestException $e) { + $this->assertEquals(0, $this->request->getCryptType()); + + return; + } + + $this->fail('Purchase with an invalid crypt type did not throw an InvalidRequestException.'); + } + + public function test_missing_amount_should_throw_an_exception_for_the_purchase_request() + { + $this->request->initialize([ + 'paymentMethod' => 'payment_profile', + 'orderNumber' => 'XXXX-XXXX', + 'cryptType' => 1, + 'cardReference' => 'FAKE_CARD_REFERENCE', + ]); + + $this->expectException(InvalidRequestException::class); + $this->request->send(); + } + + public function test_an_invalid_amount_should_throw_an_exception_for_the_purchase_request() + { + $this->request->initialize([ + 'paymentMethod' => 'payment_profile', + 'orderNumber' => 'XXXX-XXXX', + 'cryptType' => 1, + 'cardReference' => 'FAKE_CARD_REFERENCE', + 'amount' => -5, + ]); + + $this->expectException(InvalidRequestException::class); + $this->request->send(); + } + + public function test_an_invalid_description_should_throw_an_exception_for_the_purchase_request() + { + $this->request->initialize([ + 'paymentMethod' => 'payment_profile', + 'orderNumber' => 'XXXX-XXXX', + 'cryptType' => 1, + 'cardReference' => 'FAKE_CARD_REFERENCE', + 'amount' => 5.00, + 'description' => "ZGL5Dp0htqaKRzfeIOiVJm", // randomly generated 22 character string + ]); + + $this->expectException(InvalidRequestException::class); + $this->request->send(); + } + + public function test_missing_a_card_reference_should_throw_an_exception_for_the_purchase_request() + { + $this->request->initialize([ + 'paymentMethod' => 'payment_profile', + 'orderNumber' => 'XXXX-XXXX', + 'cryptType' => 1, + 'amount' => 5.00, + ]); + + $this->expectException(InvalidRequestException::class); + $this->request->send(); + } + + public function test_missing_a_card_should_throw_an_exception_for_the_purchase_request() + { + $this->request->initialize([ + 'paymentMethod' => 'card', + 'orderNumber' => 'XXXX-XXXX', + 'cryptType' => 1, + 'amount' => 5.00, + ]); + + + $this->expectException(InvalidRequestException::class); + $this->request->send(); + } + + public function test_an_expired_card_should_throw_an_exception_for_the_purchase_request() + { + $this->request->initialize([ + 'paymentMethod' => 'card', + 'orderNumber' => 'XXXX-XXXX', + 'cryptType' => 1, + 'amount' => 5.00, + 'card' => [ + 'number' => '4242424242424242', + 'expiryMonth' => date('m'), + 'expiryYear' => date('Y') - 1, + 'cvv' => 123, + ], + ]); + + $this->expectException(InvalidCreditCardException::class); + $this->request->send(); + } } From 7effae7d3abff8f86f32cf90f7d9b511ef6956ad Mon Sep 17 00:00:00 2001 From: Tymotheos Szulc Date: Mon, 22 Mar 2021 16:49:50 -0400 Subject: [PATCH 09/11] chore: docblocks --- src/Message/AbstractRequest.php | 2 +- src/Message/PurchaseRequest.php | 84 +++++++++++++++++++++++++++++++-- 2 files changed, 81 insertions(+), 5 deletions(-) diff --git a/src/Message/AbstractRequest.php b/src/Message/AbstractRequest.php index fc10114..c668790 100644 --- a/src/Message/AbstractRequest.php +++ b/src/Message/AbstractRequest.php @@ -18,7 +18,7 @@ abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest * Allowable values for the e-commerce transaction category being processed * * @var array - * @see https://developer.moneris.com/en/Documentation/NA/E-Commerce%20Solutions/API/Purchase + * @link https://developer.moneris.com/en/Documentation/NA/E-Commerce%20Solutions/API/Purchase */ const ECOMMERCE_INDICATORS = array( self::MAIL_ORDER_TELEPHONE_ORDER_SINGLE, diff --git a/src/Message/PurchaseRequest.php b/src/Message/PurchaseRequest.php index f003cb9..35e3f83 100644 --- a/src/Message/PurchaseRequest.php +++ b/src/Message/PurchaseRequest.php @@ -1,16 +1,92 @@ + * // Create a gateway for the Moneris Gateway + * // (routes to GatewayFactory::create) + * $gateway = Omnipay::create('Moneris'); + * + * // Initialise the gateway + * $gateway->initialize(array( + * 'merchantId' => 'MyMonerisStoreId', + * 'merchantSecret' => 'MyMonerisAPIToken', + * 'cryptType' => 7, + * 'testMode' => true, // Or false when you are ready for live transactions + * )); + * + * + * #### Direct Credit Card Payment + * + * This is for the use case where a customer has presented their + * credit card details and you intend to use the Moneris gateway + * for processing a transaction using that credit card data. + * + * + * // Create a credit card object + * // DO NOT USE THESE CARD VALUES -- substitute your own + * // see the documentation in the class header. + * $card = new CreditCard(array( + * 'firstName' => 'Example', + * 'lastName' => 'User', + * 'number' => '4111111111111111', + * 'expiryMonth' => '01', + * 'expiryYear' => '2020', + * 'cvv' => '123', + * 'billingAddress1' => '1 Scrubby Creek Road', + * 'billingCountry' => 'AU', + * 'billingCity' => 'Scrubby Creek', + * 'billingPostcode' => '4999', + * 'billingState' => 'QLD', + * )); + * + * // Do a purchase transaction on the gateway + * try { + * $transaction = $gateway->purchase(array( + * 'orderNumber' => 'XXXX-XXXX', + * 'amount' => '10.00', + * 'description' => 'This is a test purchase transaction.', + * 'card' => $card, + * )); + * $response = $transaction->send(); + * $data = $response->getData(); + * echo "Gateway purchase response data == " . print_r($data, true) . "\n"; + * + * if ($response->isSuccessful()) { + * echo "Purchase transaction was successful!\n"; + * } + * } catch (\Exception $e) { + * echo "Exception caught while attempting authorize.\n"; + * echo "Exception type == " . get_class($e) . "\n"; + * echo "Message == " . $e->getMessage() . "\n"; + * } + * + * + * @link https://developer.moneris.com/en/Documentation/NA/E-Commerce%20Solutions/API/Purchase + */ class PurchaseRequest extends AbstractRequest { /** * CVD value is deliberately bypassed or is not provided by the merchant. * * @var int - * @see https://developer.moneris.com/en/Documentation/NA/E-Commerce%20Solutions/API/Purchase + * @link https://developer.moneris.com/en/Documentation/NA/E-Commerce%20Solutions/API/Purchase */ const CVD_BYPASSED = 0; @@ -18,7 +94,7 @@ class PurchaseRequest extends AbstractRequest * CVD value is present. * * @var int - * @see https://developer.moneris.com/en/Documentation/NA/E-Commerce%20Solutions/API/Purchase + * @link https://developer.moneris.com/en/Documentation/NA/E-Commerce%20Solutions/API/Purchase */ const CVD_PRESENT = 1; @@ -26,7 +102,7 @@ class PurchaseRequest extends AbstractRequest * CVD value is on the card, but is illegible. * * @var int - * @see https://developer.moneris.com/en/Documentation/NA/E-Commerce%20Solutions/API/Purchase + * @link https://developer.moneris.com/en/Documentation/NA/E-Commerce%20Solutions/API/Purchase */ const CVD_ILLEGIBLE = 2; @@ -34,7 +110,7 @@ class PurchaseRequest extends AbstractRequest * Cardholder states that the card has no CVD imprint. * * @var int - * @see https://developer.moneris.com/en/Documentation/NA/E-Commerce%20Solutions/API/Purchase + * @link https://developer.moneris.com/en/Documentation/NA/E-Commerce%20Solutions/API/Purchase */ const NO_CVD = 9; From 853151fe331550024fc0c905a9fe1d57ef53c3e4 Mon Sep 17 00:00:00 2001 From: Tymotheos Szulc Date: Mon, 22 Mar 2021 16:58:36 -0400 Subject: [PATCH 10/11] chore: styleci --- src/Message/AbstractRequest.php | 8 ++++---- src/Message/PurchaseRequest.php | 4 ++-- tests/Message/PurchaseRequestTest.php | 3 +-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Message/AbstractRequest.php b/src/Message/AbstractRequest.php index c668790..6685357 100644 --- a/src/Message/AbstractRequest.php +++ b/src/Message/AbstractRequest.php @@ -15,20 +15,20 @@ abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest const SSL_ENABLED_MERCHANT = 7; /** - * Allowable values for the e-commerce transaction category being processed + * Allowable values for the e-commerce transaction category being processed. * * @var array * @link https://developer.moneris.com/en/Documentation/NA/E-Commerce%20Solutions/API/Purchase */ - const ECOMMERCE_INDICATORS = array( + const ECOMMERCE_INDICATORS = [ self::MAIL_ORDER_TELEPHONE_ORDER_SINGLE, self::MAIL_ORDER_TELEPHONE_ORDER_RECURRING, self::MAIL_ORDER_TELEPHONE_ORDER_INSTALMENT, self::MAIL_ORDER_TELEPHONE_ORDER_UNKNOWN_CLASSIFICATION, self::AUTHENTICATED_E_COMMERCE_TRANSACTION_VBV, self::NON_AUTHENTICATED_E_COMMERCE_TRANSACTION_VBV, - self::SSL_ENABLED_MERCHANT - ); + self::SSL_ENABLED_MERCHANT, + ]; public $testEndpoint = 'https://esqa.moneris.com:443/gateway2/servlet/MpgRequest'; public $liveEndpoint = 'https://www3.moneris.com:443/gateway2/servlet/MpgRequest'; diff --git a/src/Message/PurchaseRequest.php b/src/Message/PurchaseRequest.php index 35e3f83..c532a9b 100644 --- a/src/Message/PurchaseRequest.php +++ b/src/Message/PurchaseRequest.php @@ -1,6 +1,6 @@ 1, 'cardReference' => 'FAKE_CARD_REFERENCE', 'amount' => 5.00, - 'description' => "ZGL5Dp0htqaKRzfeIOiVJm", // randomly generated 22 character string + 'description' => "ZGL5Dp0htqaKRzfeIOiVJm", ]); $this->expectException(InvalidRequestException::class); @@ -183,7 +183,6 @@ public function test_missing_a_card_should_throw_an_exception_for_the_purchase_r 'amount' => 5.00, ]); - $this->expectException(InvalidRequestException::class); $this->request->send(); } From 0c2e7921991fcf4f431a471c272c5a741014d94c Mon Sep 17 00:00:00 2001 From: Tymotheos Szulc Date: Mon, 22 Mar 2021 17:00:23 -0400 Subject: [PATCH 11/11] chore: styleci - use single-quote --- tests/Message/PurchaseRequestTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Message/PurchaseRequestTest.php b/tests/Message/PurchaseRequestTest.php index 514d5cf..0a954b0 100644 --- a/tests/Message/PurchaseRequestTest.php +++ b/tests/Message/PurchaseRequestTest.php @@ -154,7 +154,7 @@ public function test_an_invalid_description_should_throw_an_exception_for_the_pu 'cryptType' => 1, 'cardReference' => 'FAKE_CARD_REFERENCE', 'amount' => 5.00, - 'description' => "ZGL5Dp0htqaKRzfeIOiVJm", + 'description' => 'ZGL5Dp0htqaKRzfeIOiVJm', ]); $this->expectException(InvalidRequestException::class);