From 56e09b4b9aff23e3b8b6d510a14c4c7645b5a2d7 Mon Sep 17 00:00:00 2001 From: MSmedal Date: Thu, 15 Oct 2020 08:35:03 -0400 Subject: [PATCH] 20201015 deployment --- src/AcceptorConfig.php | 98 + src/Builders/AuthorizationBuilder.php | 67 +- src/Builders/ManagementBuilder.php | 60 + src/Builders/TransactionBuilder.php | 21 + src/Entities/AdditionalTaxDetails.php | 41 + src/Entities/AutoSubstantiation.php | 87 + src/Entities/BatchSummary.php | 3 + src/Entities/CommercialData.php | 148 ++ src/Entities/CommercialLineItem.php | 109 + src/Entities/DiscountDetails.php | 69 + .../Enums/CardDataInputCapability.php | 24 + .../Enums/CardDataOutputCapability.php | 13 + src/Entities/Enums/CardDataSource.php | 19 + .../CardHolderAuthenticationCapability.php | 16 + .../Enums/CardHolderAuthenticationEntity.php | 15 + src/Entities/Enums/CardType.php | 15 + src/Entities/Enums/CommercialIndicator.php | 11 + src/Entities/Enums/CreditDebitIndicator.php | 11 + src/Entities/Enums/GatewayProvider.php | 13 + .../Enums/MobilePaymentMethodType.php | 11 + src/Entities/Enums/NetGrossIndicator.php | 11 + src/Entities/Enums/OperatingEnvironment.php | 23 + src/Entities/Enums/PinCaptureCapability.php | 20 + src/Entities/Enums/ServiceEndpoints.php | 4 + src/Entities/Enums/TaxCategory.php | 15 + .../Enums/TerminalOutputCapability.php | 14 + src/Entities/Enums/TrackNumber.php | 13 + src/Entities/Enums/TransactionType.php | 1 + src/Entities/Enums/UcafIndicator.php | 15 + src/Entities/StoredCredential.php | 5 + src/Entities/ThreeDSecure.php | 10 + src/Entities/Transaction.php | 28 +- src/Gateways/Gateway.php | 1 + src/Gateways/MerchantwareConnector.php | 404 ++++ src/Gateways/PorticoConnector.php | 49 +- src/Gateways/TransITConnector.php | 628 ++++++ src/PaymentMethods/Credit.php | 8 +- src/PaymentMethods/CreditTrackData.php | 21 + src/PaymentMethods/DebitTrackData.php | 20 + src/PaymentMethods/GiftCard.php | 4 +- src/Services/BatchService.php | 2 +- src/ServicesConfig.php | 180 +- src/ServicesContainer.php | 70 +- .../Builders/TerminalReportBuilder.php | 106 +- .../Builders/TerminalSearchBuilder.php | 72 +- src/Terminals/Enums/SAFReportType.php | 48 +- src/Terminals/Enums/SafDelete.php | 28 +- src/Terminals/Enums/SafMode.php | 32 +- src/Terminals/Enums/SafReportSummary.php | 28 +- src/Terminals/Enums/SafUpload.php | 28 +- src/Terminals/Enums/TerminalCardType.php | 54 +- .../HPA/Entities/Enums/HpaSendFileType.php | 10 +- src/Terminals/HPA/Entities/HpaResponse.php | 2 +- src/Terminals/Interfaces/ILogManagement.php | 24 +- src/Terminals/Interfaces/IRequestSubGroup.php | 20 +- .../Interfaces/IResponseSubGroup.php | 18 +- .../PAX/Entities/Enums/PaxEntryMode.php | 32 +- .../PAX/Entities/Enums/PaxExtData.php | 102 +- .../PAX/Entities/Enums/PaxMessageId.php | 208 +- .../PAX/Entities/Enums/PaxSearchCriteria.php | 36 +- .../PAX/Entities/Enums/PaxTxnType.php | 88 +- .../PAX/Entities/Enums/TerminalReportType.php | 22 +- .../Enums/TerminalTransactionType.php | 88 +- src/Terminals/PAX/Entities/PaxResponse.php | 48 +- .../PAX/Interfaces/PaxHttpInterface.php | 212 +- .../PAX/Interfaces/PaxTcpInterface.php | 506 ++--- src/Terminals/PAX/PaxController.php | 834 ++++---- src/Terminals/PAX/PaxInterface.php | 638 +++--- src/Terminals/PAX/Responses/BatchResponse.php | 82 +- .../PAX/Responses/InitializeResponse.php | 60 +- .../PAX/Responses/PaxBaseResponse.php | 130 +- .../PAX/Responses/PaxCreditResponse.php | 42 +- .../PAX/Responses/PaxDebitResponse.php | 42 +- .../PAX/Responses/PaxDeviceResponse.php | 580 ++--- .../PAX/Responses/PaxEBTResponse.php | 42 +- .../PAX/Responses/PaxGiftResponse.php | 44 +- .../PAX/Responses/PaxLocalReportResponse.php | 52 +- .../PAX/Responses/SafDeleteResponse.php | 52 +- .../PAX/Responses/SafSummaryReport.php | 58 +- .../PAX/Responses/SafUploadResponse.php | 98 +- .../PAX/Responses/SignatureResponse.php | 180 +- .../PAX/SubGroups/AccountRequest.php | 62 +- .../PAX/SubGroups/AccountResponse.php | 140 +- src/Terminals/PAX/SubGroups/AmountRequest.php | 62 +- .../PAX/SubGroups/AmountResponse.php | 104 +- src/Terminals/PAX/SubGroups/AvsRequest.php | 52 +- src/Terminals/PAX/SubGroups/AvsResponse.php | 50 +- .../PAX/SubGroups/CashierResponse.php | 50 +- .../PAX/SubGroups/CashierSubGroup.php | 52 +- src/Terminals/PAX/SubGroups/CheckResponse.php | 110 +- .../PAX/SubGroups/CommercialRequest.php | 56 +- .../PAX/SubGroups/CommercialResponse.php | 58 +- src/Terminals/PAX/SubGroups/EcomSubGroup.php | 62 +- .../PAX/SubGroups/EcomSubGroupResponse.php | 84 +- .../PAX/SubGroups/ExtDataSubGroup.php | 46 +- .../PAX/SubGroups/ExtDataSubGroupResponse.php | 66 +- src/Terminals/PAX/SubGroups/HostResponse.php | 86 +- src/Terminals/PAX/SubGroups/TraceRequest.php | 64 +- src/Terminals/PAX/SubGroups/TraceResponse.php | 54 +- src/Utils/AmountUtils.php | 19 + src/Utils/CardUtils.php | 136 ++ src/Utils/EnumUtils.php | 44 +- src/Utils/MessageReader.php | 218 +- src/Utils/ReverseEnumMap.php | 46 +- src/Utils/StringUtils.php | 41 + .../GeniusConnector/MerchantwareGiftTests.php | 134 ++ .../GeniusConnector/MerchantwareTests.php | 330 +++ .../AutoSubstantiationTest.php | 45 + .../PorticoConnector/CommercialCardTest.php | 45 + .../PorticoTokenManagementTest.php | 3 +- .../Gateways/RealexConnector/AcsResponse.php | 14 +- .../Gateways/RealexConnector/ApiTestCase.php | 40 +- .../Certifications/SdkTest.php | 2 +- .../Gateways/RealexConnector/HppTest.php | 8 +- .../RealexConnector/RealexApmTest.php | 35 +- .../Gateways/Terminals/LogManagement.php | 42 +- .../Gateways/Terminals/PAX/PaxAdminTests.php | 196 +- .../Gateways/Terminals/PAX/PaxBatchTests.php | 148 +- .../Gateways/Terminals/PAX/PaxCreditTests.php | 678 +++--- .../Gateways/Terminals/PAX/PaxDebitTests.php | 156 +- .../Gateways/Terminals/PAX/PaxEBTTests.php | 298 +-- .../Gateways/Terminals/PAX/PaxGiftTests.php | 348 +-- .../Gateways/Terminals/PAX/PaxLevel2Tests.php | 210 +- .../Gateways/Terminals/PAX/PaxReportTests.php | 310 +-- .../PAX/vrf/PaxVerificationTests.php | 1892 ++++++++--------- .../Certification/DirectMarketingMOTO_3.php | 721 +++++++ .../Certification/Ecommerce_3.php | 784 +++++++ .../Certification/Token_Request_Only.php | 276 +++ .../TransITConnector/CommercialCardTest.php | 220 ++ .../TransITConnector/TransITAdminTest.php | 93 + .../TransITConnector/TransITDebitTest.php | 54 + .../TransITConnector/TransITTests.php | 323 +++ 132 files changed, 10873 insertions(+), 5437 deletions(-) create mode 100644 src/AcceptorConfig.php create mode 100644 src/Entities/AdditionalTaxDetails.php create mode 100644 src/Entities/AutoSubstantiation.php create mode 100644 src/Entities/CommercialData.php create mode 100644 src/Entities/CommercialLineItem.php create mode 100644 src/Entities/DiscountDetails.php create mode 100644 src/Entities/Enums/CardDataInputCapability.php create mode 100644 src/Entities/Enums/CardDataOutputCapability.php create mode 100644 src/Entities/Enums/CardDataSource.php create mode 100644 src/Entities/Enums/CardHolderAuthenticationCapability.php create mode 100644 src/Entities/Enums/CardHolderAuthenticationEntity.php create mode 100644 src/Entities/Enums/CardType.php create mode 100644 src/Entities/Enums/CommercialIndicator.php create mode 100644 src/Entities/Enums/CreditDebitIndicator.php create mode 100644 src/Entities/Enums/GatewayProvider.php create mode 100644 src/Entities/Enums/MobilePaymentMethodType.php create mode 100644 src/Entities/Enums/NetGrossIndicator.php create mode 100644 src/Entities/Enums/OperatingEnvironment.php create mode 100644 src/Entities/Enums/PinCaptureCapability.php create mode 100644 src/Entities/Enums/TaxCategory.php create mode 100644 src/Entities/Enums/TerminalOutputCapability.php create mode 100644 src/Entities/Enums/TrackNumber.php create mode 100644 src/Entities/Enums/UcafIndicator.php create mode 100644 src/Gateways/MerchantwareConnector.php create mode 100644 src/Gateways/TransITConnector.php create mode 100644 src/Utils/AmountUtils.php create mode 100644 src/Utils/CardUtils.php create mode 100644 src/Utils/StringUtils.php create mode 100644 test/Integration/Gateways/GeniusConnector/MerchantwareGiftTests.php create mode 100644 test/Integration/Gateways/GeniusConnector/MerchantwareTests.php create mode 100644 test/Integration/Gateways/PorticoConnector/AutoSubstantiationTest.php create mode 100644 test/Integration/Gateways/PorticoConnector/CommercialCardTest.php create mode 100644 test/Integration/Gateways/TransITConnector/Certification/DirectMarketingMOTO_3.php create mode 100644 test/Integration/Gateways/TransITConnector/Certification/Ecommerce_3.php create mode 100644 test/Integration/Gateways/TransITConnector/Certification/Token_Request_Only.php create mode 100644 test/Integration/Gateways/TransITConnector/CommercialCardTest.php create mode 100644 test/Integration/Gateways/TransITConnector/TransITAdminTest.php create mode 100644 test/Integration/Gateways/TransITConnector/TransITDebitTest.php create mode 100644 test/Integration/Gateways/TransITConnector/TransITTests.php diff --git a/src/AcceptorConfig.php b/src/AcceptorConfig.php new file mode 100644 index 00000000..c0e65f3f --- /dev/null +++ b/src/AcceptorConfig.php @@ -0,0 +1,98 @@ +cardCaptureCapability = $cardCaptureCapability; + $this->cardDataInputCapability = $cardDataInputCapability; + $this->cardDataOutputCapability = $cardDataOutputCapability; + $this->cardHolderAuthenticationCapability = $cardHolderAuthenticationCapability; + $this->cardHolderAuthenticationEntity = $cardHolderAuthenticationEntity; + $this->operatingEnvironment = $operatingEnvironment; + $this->pinCaptureCapability = $pinCaptureCapability; + $this->terminalOutputCapability = $terminalOutputCapability; + } +} diff --git a/src/Builders/AuthorizationBuilder.php b/src/Builders/AuthorizationBuilder.php index 55eafcba..b20e4549 100644 --- a/src/Builders/AuthorizationBuilder.php +++ b/src/Builders/AuthorizationBuilder.php @@ -98,6 +98,14 @@ class AuthorizationBuilder extends TransactionBuilder */ public $billingAddress; + /** + * Indicates Card On File transaction + * + * @internal + * @var bool + */ + public $cardOnFile; + /** * Request cashback amount * @@ -114,6 +122,14 @@ class AuthorizationBuilder extends TransactionBuilder */ public $clientTransactionId; + /** + * Request commercial data + * + * @internal + * @var CommercialData + */ + public $commercialData; + /** * Request currency * @@ -316,6 +332,15 @@ class AuthorizationBuilder extends TransactionBuilder */ public $requestMultiUseToken; + /** + * To attach registration most recent change date value + * For use w/Discover cards on TransIT gateway + * + * @internal + * @var Date + */ + public $lastRegisteredDate; + /** * Request replacement gift card * @@ -421,7 +446,7 @@ class AuthorizationBuilder extends TransactionBuilder /* * Card on File field * @var string - * + * */ public $cardBrandTransactionId; @@ -661,6 +686,19 @@ public function withAutoSubstantiation($autoSubstantiation) return $this; } + /** + * Sets the commercial data values for use w/ lvl2 & lvl3 transactions + * + * @param CommercialData + * + * @return AuthorizationBuilder + */ + public function withCommercialData($commercialData) + { + $this->commercialData = $commercialData; + return $this; + } + /** * Set the request's balance inquiry type * @@ -674,6 +712,19 @@ public function withBalanceInquiryType($balanceInquiryType) return $this; } + /** + * Set Card On File Indicator + * + * @param bool $cardOnFile + * + * @return AuthorizationBuilder + */ + public function withCardOnFile($cardOnFile) + { + $this->cardOnFile = $cardOnFile; + return $this; + } + /** * Set the request cashback amount * @@ -1204,4 +1255,18 @@ public function withCardBrandStorage($transactionInitiator, $value = '') $this->cardBrandTransactionId = $value; return $this; } + + /** + * Set lastRegisteredDate - DD/MM/YYYY + * Used w/TransIT gateway + * + * @param bool $isRegistered + * + * @return AuthorizationBuilder + */ + public function withLastRegisteredDate($date) + { + $this->lastRegisteredDate = $date; + return $this; + } } diff --git a/src/Builders/ManagementBuilder.php b/src/Builders/ManagementBuilder.php index e61f5a76..c5516812 100644 --- a/src/Builders/ManagementBuilder.php +++ b/src/Builders/ManagementBuilder.php @@ -47,6 +47,14 @@ class ManagementBuilder extends TransactionBuilder */ public $currency; + /** + * Request customer ID + * + * @internal + * @var string|float + */ + public $customerId; + /** * @internal * @var string @@ -61,6 +69,14 @@ class ManagementBuilder extends TransactionBuilder */ public $gratuity; + /** + * Request invoice number + * + * @internal + * @var string|float + */ + public $invoiceNumber; + /** * Request purchase order number * @@ -255,6 +271,19 @@ public function withCurrency($currency) return $this; } + /** + * Set the request customer ID + * + * @param string|float $customerId Request customer ID + * + * @return AuthorizationBuilder + */ + public function withCustomerId($customerId) + { + $this->customerId = $customerId; + return $this; + } + /** * Sets the transaction's description. * @@ -287,6 +316,19 @@ public function withGratuity($gratuity) return $this; } + /** + * Set the request invoice number + * + * @param string|float $invoiceNumber Request invoice number + * + * @return ManagementBuilder + */ + public function withInvoiceNumber($invoiceNumber) + { + $this->invoiceNumber = $invoiceNumber; + return $this; + } + /** * @return ManagementBuilder */ @@ -354,6 +396,24 @@ public function withTaxAmount($taxAmount) return $this; } + /** + * Sets Multi-Capture values + * used w/TransIT gateway + * + * @param int $sequence + * @param int $paymentCount + * + * @return ManagementBuilder + */ + public function withMultiCapture($sequence = 1, $paymentCount = 1) + { + $this->multiCapture = true; + $this->multiCaptureSequence = $sequence; + $this->multiCapturePaymentCount = $paymentCount; + + return $this; + } + /** * Sets the tax type. * diff --git a/src/Builders/TransactionBuilder.php b/src/Builders/TransactionBuilder.php index 6b2a43a9..efa409aa 100644 --- a/src/Builders/TransactionBuilder.php +++ b/src/Builders/TransactionBuilder.php @@ -25,6 +25,27 @@ abstract class TransactionBuilder extends BaseBuilder */ public $paymentMethod; + /** + * used w/TransIT gateway + * + * @var bool + */ + public $multiCapture; + + /** + * used w/TransIT gateway + * + * @var int + */ + public $multiCaptureSequence; + + /** + * used w/TransIT gateway + * + * @var int + */ + public $multiCapturePaymentCount; + /** * Request transaction modifier * diff --git a/src/Entities/AdditionalTaxDetails.php b/src/Entities/AdditionalTaxDetails.php new file mode 100644 index 00000000..b06523a1 --- /dev/null +++ b/src/Entities/AdditionalTaxDetails.php @@ -0,0 +1,41 @@ +taxAmount = $taxAmount; + $this->taxCategory = $taxCategory; + $this->taxRate = $taxRate; + $this->taxType = $taxType; + } +} diff --git a/src/Entities/AutoSubstantiation.php b/src/Entities/AutoSubstantiation.php new file mode 100644 index 00000000..588e1203 --- /dev/null +++ b/src/Entities/AutoSubstantiation.php @@ -0,0 +1,87 @@ +amounts['SUBTOTAL_CLINIC_OR_OTHER_AMT']; + } + + public function setClinicSubTotal($value) + { + $this->amounts['SUBTOTAL_CLINIC_OR_OTHER_AMT'] = $value; + $this->amounts['TOTAL_HEALTHCARE_AMT'] += $value; + } + + public function getCopaySubTotal() + { + return $this->amounts['SUBTOTAL_COPAY_AMT']; + } + + public function setCopaySubTotal($value) + { + $this->amounts['SUBTOTAL_COPAY_AMT'] = $value; + $this->amounts['TOTAL_HEALTHCARE_AMT'] += $value; + } + + public function getDentalSubTotal() + { + return $this->amounts['SUBTOTAL_DENTAL_AMT']; + } + + public function setDentalSubTotal($value) + { + $this->amounts['SUBTOTAL_DENTAL_AMT'] = $value; + $this->amounts['TOTAL_HEALTHCARE_AMT'] += $value; + } + + public $merchantVerificationValue; + + public function getPrescriptionSubTotal() + { + return $this->amounts['SUBTOTAL_PRESCRIPTION_AMT']; + } + + public function setPrescriptionSubTotal($value) + { + $this->amounts['SUBTOTAL_PRESCRIPTION_AMT'] = $value; + $this->amounts['TOTAL_HEALTHCARE_AMT'] += $value; + } + + /** + * Indicates if real time substantiation was used + * + * @var bool + */ + public $realTimeSubstantiation; + + public function getTotalHealthcareAmount() + { + return $this->amounts['TOTAL_HEALTHCARE_AMT']; + } + + public function getVisionSubTotal() + { + return $this->amounts['SUBTOTAL_VISION__OPTICAL_AMT']; + } + + public function setVisionSubTotal($value) + { + $this->amounts['SUBTOTAL_VISION__OPTICAL_AMT'] = $value; + $this->amounts['TOTAL_HEALTHCARE_AMT'] += $value; + } + + public function __construct() + { + $this->amounts['TOTAL_HEALTHCARE_AMT'] = 0; + $this->amounts['SUBTOTAL_PRESCRIPTION_AMT'] = 0; + $this->amounts['SUBTOTAL_VISION__OPTICAL_AMT'] = 0; + $this->amounts['SUBTOTAL_CLINIC_OR_OTHER_AMT'] = 0; + $this->amounts['SUBTOTAL_DENTAL_AMT'] = 0; + $this->amounts['SUBTOTAL_COPAY_AMT'] = 0; + } +} diff --git a/src/Entities/BatchSummary.php b/src/Entities/BatchSummary.php index 583c05ef..652e1d8a 100644 --- a/src/Entities/BatchSummary.php +++ b/src/Entities/BatchSummary.php @@ -34,4 +34,7 @@ class BatchSummary * @var string */ public $sequenceNumber; + + /** @var string */ + public $status; } diff --git a/src/Entities/CommercialData.php b/src/Entities/CommercialData.php new file mode 100644 index 00000000..52695481 --- /dev/null +++ b/src/Entities/CommercialData.php @@ -0,0 +1,148 @@ +taxType = $taxType; + $this->commercialIndicator = $commercialIndicator; + $this->lineItems = array(); + } + + /** + * can be used to send additional tax details for Level 2 and Level 3 transactions + * + * @var AdditionalTaxDetails + */ + public $additionalTaxDetails; + + /** + * to indicate LEVEL2 or LEVEL3 + * + * @var CommercialIndicator + */ + public $commercialIndicator; + + /** + * The reference identifier supplied by the Commercial Card cardholder + * + * @var string + */ + public $customerReferenceId; + + /** + * Indicates the customer's government assigned tax identification number + * + * @var string + */ + public $customerVatNumber; + + /** + * The value of the Transaction Advice Addendum field, displays descriptive information about a transactions on a customer's AMEX card statement. + * + * @var string + */ + public $description; // needed for AMEX w/TransIT + + /** + * + * @var string + */ + public $destinationCountryCode; + + /** + * + * @var string + */ + public $destinationPostalCode; + + public $discountAmount; // needed w/Genius + + /** + * + * @var float + */ + public $dutyAmount; // needed for Visa w/TransIT + + /** + * + * @var float + */ + public $freightAmount; // optional w/TransIT + + public $lineItems = array(); + + /** + * MM/DD/YYYY + * + * @var string + */ + public $orderDate; + + /** + * + * @var string + */ + public $originPostalCode; + + /** + * Used by the customer to identify an order. Issued by the buyer. + * + * @var string + */ + public $poNumber; + + /** + * This field contains a reference number that is used by American Express to obtain supporting information on a charge from a merchant. + * + * @var string + */ + public $supplierReferenceNumber; + + /** + * The international description code of the overall goods or services being supplied. + * + * @var string + */ + public $summaryCommodityCode; + + /** + * Tax amount; typically sales tax + * + * @var string|float + */ + public $taxAmount; + + /** + * The type of tax. For example, VAT, NATIONAL, SALESTAX. + * + * @var TaxType|string + */ + public $taxType; + + /** + * The Value Added Tax (VAT) invoice number associated with the transaction. + * + * @var string + */ + public $vatInvoiceNumber; + + /** + * + * @var CommercialLineItem + */ + public function addLineItems() + { + foreach (func_get_args() as $lineItem) { + array_push($this->lineItems, $lineItem); + } + } +} diff --git a/src/Entities/CommercialLineItem.php b/src/Entities/CommercialLineItem.php new file mode 100644 index 00000000..974a3a88 --- /dev/null +++ b/src/Entities/CommercialLineItem.php @@ -0,0 +1,109 @@ +discountAmount = $discountAmount; + $this->discountName = $discountName; + $this->discountPercentage = $discountPercentage; + $this->discountType = $discountType; + $this->priority = $priority; + $this->stackable = $stackable; + } +} diff --git a/src/Entities/Enums/CardDataInputCapability.php b/src/Entities/Enums/CardDataInputCapability.php new file mode 100644 index 00000000..0218b4c3 --- /dev/null +++ b/src/Entities/Enums/CardDataInputCapability.php @@ -0,0 +1,24 @@ +withPaymentMethod($this->transactionReference) ->withAmount($amount); + + if ($this->multiCapture) { + $builder->withMultiCapture($this->multiCaptureSequence, $this->multiCapturePaymentCount); + } + + return $builder; } /** @@ -399,10 +420,11 @@ public function reverse($amount = null) * * @return ManagementBuilder */ - public function void() + public function void($amount = null) { return (new ManagementBuilder(TransactionType::VOID)) - ->withPaymentMethod($this->transactionReference); + ->withPaymentMethod($this->transactionReference) + ->withAmount($amount); } public function __get($name) diff --git a/src/Gateways/Gateway.php b/src/Gateways/Gateway.php index ce53f339..e7b7cd57 100644 --- a/src/Gateways/Gateway.php +++ b/src/Gateways/Gateway.php @@ -103,6 +103,7 @@ protected function sendRequest( $response = new GatewayResponse(); $response->statusCode = $curlInfo['http_code']; $response->rawResponse = $curlResponse; + return $response; } catch (\Exception $e) { throw new \Exception( diff --git a/src/Gateways/MerchantwareConnector.php b/src/Gateways/MerchantwareConnector.php new file mode 100644 index 00000000..200409e3 --- /dev/null +++ b/src/Gateways/MerchantwareConnector.php @@ -0,0 +1,404 @@ +paymentMethod; + + $this->setGatewayParams($paymentMethod); + + $transaction = $xml->createElement($this->mapRequestType($builder)); + $transaction->setAttribute('xmlns', $this->xmlNamespace); + + // Credentials + $credentials = $xml->createElement('Credentials'); + $credentials->appendChild($xml->createElement('MerchantName', $this->merchantName)); + $credentials->appendChild($xml->createElement('MerchantSiteId', $this->merchantSiteId)); + $credentials->appendChild($xml->createElement('MerchantKey', $this->merchantKey)); + + $transaction->appendChild($credentials); + + // Payment Data + $paymentData = $xml->createElement('PaymentData'); + $this->hydratePaymentData($xml, $paymentData, $paymentMethod); + + // AVS + if (!empty($builder->billingAddress)) { + $paymentData->appendChild($xml->createElement( + 'AvsStreetAddress', + $builder->billingAddress->streetAddress1 + )); + $paymentData->appendChild($xml->createElement('AvsZipCode', $builder->billingAddress->postalCode)); + } + + $transaction->appendChild($paymentData); + + // Request + $request = $xml->createElement('Request'); + if ($paymentMethod->paymentMethodType === PaymentMethodType::GIFT && !empty($builder->currency)) { + $request->appendChild($xml->createElement('AmountType', $builder->currency)); + } + $request->appendChild($xml->createElement('Amount', $builder->amount)); + $request->appendChild($xml->createElement('CashbackAmount', $builder->cashBackAmount)); + $request->appendChild($xml->createElement('SurchargeAmount', $builder->convenienceAmount)); + $request->appendChild($xml->createElement('AuthorizationCode', $builder->offlineAuthCode)); + + if ($builder->autoSubstantiation != null) { + $healthcare = $xml->createElement('HealthCareAmountDetails'); + + $auto = $builder->autoSubstantiation; + $healthcare->appendChild($xml->createElement('CopayAmount', $auto->getCopaySubTotal())); + $healthcare->appendChild($xml->createElement('ClinicalAmount', $auto->getClinicSubTotal())); + $healthcare->appendChild($xml->createElement('DentalAmount', $auto->getDentalSubTotal())); + $healthcare->appendChild($xml->createElement('HealthCareTotalAmount', $auto->getTotalHealthcareAmount())); + $healthcare->appendChild($xml->createElement('PrescriptionAmount', $auto->getPrescriptionSubTotal())); + $healthcare->appendChild($xml->createElement('VisionAmount', $auto->getVisionSubTotal())); + + $request->appendChild($healthcare); + } + + $request->appendChild($xml->createElement('InvoiceNumber', $builder->invoiceNumber)); + $request->appendChild($xml->createElement('RegisterNumber', $this->registerNumber)); + $request->appendChild($xml->createElement('MerchantTransactionId', $builder->clientTransactionId)); + $request->appendChild($xml->createElement('CardAcceptorTerminalId', $this->terminalId)); + // invoice object + $request->appendChild($xml->createElement('EnablePartialAuthorization', $builder->allowPartialAuth)); + $request->appendChild($xml->createElement('ForceDuplicate', $builder->allowDuplicates)); + + $transaction->appendChild($request); + $response = $this->doTransaction($this->buildEnvelope($xml, $transaction)); + return $this->mapResponse($builder, $response); + } + + public function manageTransaction($builder) + { + $xml = new DOMDocument(); + $transactionType = $builder->transactionType; + $this->setGatewayParams($builder->paymentMethod); + + $transaction = $xml->createElement($this->mapRequestType($builder)); + $transaction->setAttribute('xmlns', $this->xmlNamespace); + + // Credentials + $credentials = $xml->createElement('Credentials'); + $credentials->appendChild($xml->createElement('MerchantName', $this->merchantName)); + $credentials->appendChild($xml->createElement('MerchantSiteId', $this->merchantSiteId)); + $credentials->appendChild($xml->createElement('MerchantKey', $this->merchantKey)); + + $transaction->appendChild($credentials); + + // Payment Data + if ($transactionType === TransactionType::REFUND) { + $paymentData = $xml->createElement('PaymentData'); + + $paymentData->appendChild($xml->createElement('Source', 'PreviousTransaction')); + $paymentData->appendChild($xml->createElement('Token', $builder->transactionId)); + + $transaction->appendChild($paymentData); + } + + // Request + $request = $xml->createElement('Request'); + if ($transactionType !== TransactionType::REFUND) { + $request->appendChild($xml->createElement('Token', $builder->transactionId)); + } + $request->appendChild($xml->createElement('Amount', $builder->amount + $builder->gratuity)); + if (!empty($builder->invoiceNumber)) { + $request->appendChild($xml->createElement('InvoiceNumber', $builder->invoiceNumber)); + } + if (!empty($builder->registerNumber)) { + $request->appendChild($xml->createElement('RegisterNumber', $this->registerNumber)); + } + if (!empty($builder->clientTransactionId)) { + $request->appendChild($xml->createElement('MerchantTransactionId', $builder->clientTransactionId)); + } + if (!empty($builder->terminalId)) { + $request->appendChild($xml->createElement('CardAcceptorTerminalId', $this->terminalId)); + } + + if ($transactionType === TransactionType::TOKEN_DELETE || $transactionType === TransactionType::TOKEN_UPDATE) { + $card = $builder->paymentMethod; + + $request->appendChild($xml->createElement('VaultToken', $card->token)); + if ($transactionType === TransactionType::TOKEN_UPDATE) { + $request->appendChild($xml->createElement('ExpirationDate', $card->getShortExpiry())); + } + } + + $transaction->appendChild($request); + + $response = $this->doTransaction($this->buildEnvelope($xml, $transaction)); + return $this->mapResponse($builder, $response); + } + + public function serializeRequest($builder) + { + throw new UnsupportedTransactionException(); + } + + public function buildEnvelope(DOMDocument $xml, DOMElement $transaction) + { + $soapEnvelope = $xml->createElement('soapenv:Envelope'); + $soapEnvelope->setAttribute( + 'xmlns:soapenv', + 'http://schemas.xmlsoap.org/soap/envelope/' + ); + $soapEnvelope->setAttribute('xmlns', $this->xmlNamespace); + + $soapBody = $xml->createElement('soapenv:Body'); + + $soapBody->appendChild($transaction); + $soapEnvelope->appendChild($soapBody); + $xml->appendChild($soapEnvelope); + + return $xml->saveXML(); + } + + public function mapRequestType(TransactionBuilder $builder) + { + switch ($builder->transactionType) { + case TransactionType::AUTH: + if ($builder->transactionModifier === TransactionModifier::OFFLINE) { + return 'ForceCapture'; + } + return 'Authorize'; + case TransactionType::BATCH_CLOSE: + return 'SettleBatch'; + case TransactionType::CAPTURE: + return 'Capture'; + case TransactionType::EDIT: + return 'AdjustTip'; + case TransactionType::REFUND: + return 'Refund'; + case TransactionType::SALE: + return 'Sale'; + case TransactionType::TOKEN_DELETE: + return 'UnboardCard'; + case TransactionType::TOKEN_UPDATE: + return 'UpdateBoardedCard'; + case TransactionType::VERIFY: + return 'BoardCard'; + case TransactionType::VOID: + return 'Void'; + case TransactionType::BALANCE: + return 'BalanceInquiry'; + case TransactionType::ADD_VALUE: + return 'AddValue'; + case TransactionType::ACTIVATE: + return 'ActivateCard'; + case TransactionType::REWARD: + return 'AddPoints'; + default: + throw new UnsupportedTransactionException(); + } + } + + public function mapWalletId($mobileType) + { + switch ($mobileType) { + case 'apple-pay': + return 'ApplePay'; + default: + return 'Unknown'; + } + } + + public function mapResponse($builder, $rawResponse) + { + $root = $this->xml2object($rawResponse); + + $item = $root->{$this->mapRequestType($builder).'Result'}; + + $errorCode = (string) $item->ErrorCode; + $errorMessage = (string) $item->ErrorMessage; + + if (!empty($errorMessage)) { + throw new GatewayException( + sprintf( + 'Unexpected Gateway Response: %s - %s. ', + $errorCode, + $errorMessage + ) + ); + } + + $response = new Transaction(); + + $response->responseCode = '00'; + $response->responseMessage = (string)$item->ApprovalStatus; + $response->transactionId = (string)$item->Token; + $response->authorizationCode = (string)$item->AuthorizationCode; + $response->hostResponseDate = (string)$item->TransactionDate; + $response->authorizedAmount = (string)$item->Amount; + $response->availableBalance = (string)$item->RemainingCardBalance; + $response->cardType = (string)$item->CardType; + $response->avsResponseCode = (string)$item->AvsResponse; + $response->cvnResponseCode = (string)$item->CvResponse; + $response->token = (string)$item->VaultToken; + + if (isset($item->BatchStatus)) { + $response->batchSummary = new BatchSummary(); + $response->batchSummary->status = (string)$item->BatchStatus; + $response->batchSummary->totalAmount = (string)$item->BatchAmount; + $response->batchSummary->transactionCount = (string)$item->TransactionCount; + } + + if (isset($item->Gift)) { + $response->authorizedAmount = (string)$item->Gift->ApprovedAmount; + $response->balanceAmount = (string)$item->Gift->RedeemableBalance; + } + + if (isset($item->Loyalty)) { + $response->pointsBalanceAmount = (string)$item->Loyalty->PointsBalance; + } + + return $response; + } + + /** + * Converts a XML string to a simple object for use, + * removing extra nodes that are not necessary for + * handling the response + * + * @param string $xml Response XML from the gateway + * + * @return SimpleXMLElement + */ + protected function xml2object($xml) + { + $envelope = simplexml_load_string( + $xml, + 'SimpleXMLElement', + 0, + 'http://schemas.xmlsoap.org/soap/envelope/' + ); + + foreach ($envelope->Body as $response) { + $children = $response->children($this->xmlNamespace); + foreach ($children as $item) { + return $item; + } + } + + throw new Exception('XML from gateway could not be parsed'); + } + + public function processReport($builder) + { + } + + private function setGatewayParams($paymentMethod) + { + if (!empty($paymentMethod->paymentMethodType) && + $paymentMethod->paymentMethodType === PaymentMethodType::GIFT) { + $this->xmlNamespace = 'http://schemas.merchantwarehouse.com/merchantware/46/Giftcard'; + $this->serviceUrl .= self::GIFT_SERVICE_END_POINT; + } else { + $this->serviceUrl .= self::CREDIT_SERVICE_END_POINT; + } + } + + private function hydratePaymentData($xml, $paymentData, $paymentMethod) + { + if ($paymentMethod->paymentMethodType === PaymentMethodType::GIFT) { + $card = $paymentMethod; + if ($card->valueType === 'CardNbr') { + $paymentData->appendChild($xml->createElement('Source', 'Keyed')); + $paymentData->appendChild($xml->createElement('CardNumber', $card->number)); + $paymentData->appendChild($xml->createElement('GiftCardPin', $card->pin)); + } elseif ($card->valueType === 'TrackData') { + $paymentData->appendChild($xml->createElement('Source', 'READER')); + $paymentData->appendChild($xml->createElement('TrackData', $card->value)); + } + } else { + if ($paymentMethod instanceof CreditCardData) { + $card = $paymentMethod; + + if (!empty($card->token)) { + if (!empty($card->mobileType)) { + $paymentData->appendChild($xml->createElement('Source', 'Wallet')); + $paymentData->appendChild($xml->createElement( + 'WalletId', + $this->mapWalletId($card->mobileType) + )); + $paymentData->appendChild($xml->createElement('EncryptedPaymentData', $card->token)); + } else { + $paymentData->appendChild($xml->createElement('Source', 'Vault')); + $paymentData->appendChild($xml->createElement('VaultToken', $card->token)); + } + } else { + $paymentData->appendChild($xml->createElement('Source', 'Keyed')); + $paymentData->appendChild($xml->createElement('CardNumber', $card->number)); + $paymentData->appendChild($xml->createElement('ExpirationDate', $card->getShortExpiry())); + $paymentData->appendChild($xml->createElement('CardHolder', $card->cardHolderName)); + $paymentData->appendChild($xml->createElement('CardVerificationValue', $card->cvn)); + } + } elseif ($paymentMethod instanceof CreditTrackData) { + $paymentData->appendChild($xml->createElement('Source', 'READER')); + + $track = $paymentMethod; + $paymentData->appendChild($xml->createElement('TrackData', $track->value)); + } + } + } +} diff --git a/src/Gateways/PorticoConnector.php b/src/Gateways/PorticoConnector.php index d61719a7..420f80f3 100644 --- a/src/Gateways/PorticoConnector.php +++ b/src/Gateways/PorticoConnector.php @@ -39,6 +39,7 @@ use GlobalPayments\Api\Entities\Reporting\SearchCriteriaBuilder; use GlobalPayments\Api\Services\ReportingService; use GlobalPayments\Api\Entities\Enums\StoredCredentialInitiator; +use GlobalPayments\Api\Entities\Exceptions\BuilderException; class PorticoConnector extends XmlGateway implements IPaymentGateway { @@ -450,7 +451,7 @@ public function processAuthorization(AuthorizationBuilder $builder) $block1->appendChild($xml->createElement('BalanceInquiryType', $builder->balanceInquiryType)); } - if ($builder->level2Request === true) { + if ($builder->level2Request === true || $builder->commercialData !== null) { $block1->appendChild($xml->createElement('CPCReq', 'Y')); } @@ -515,6 +516,48 @@ public function processAuthorization(AuthorizationBuilder $builder) $xml->createElement('TxnDescriptor', $builder->dynamicDescriptor) ); } + + if ($builder->commercialData !== null) { + $commercialDataNode = $xml->createElement('CPCData'); + + $commercialDataNode->appendChild($xml->createElement('CardHolderPONbr', $builder->commercialData->poNumber)); + $commercialDataNode->appendChild($xml->createElement('TaxType', $builder->commercialData->taxType)); + $commercialDataNode->appendChild($xml->createElement('TaxAmt', $builder->commercialData->taxAmount)); + + $block1->appendChild($commercialDataNode); + } + + // auto substantiation + if ($builder->autoSubstantiation !== null) { + $autoSubstantiationNode = $xml->createElement('AutoSubstantiation'); + + $fieldNames = ["First", "Second", "Third", "Fourth"]; + $i = 0; + $hasAdditionalAmount = false; + + foreach ($builder->autoSubstantiation->amounts as $amtType => $amount) { + if ($amount !== 0) { + $hasAdditionalAmount = true; + if ($i > 3) { // Portico Gateway limits to 3 subtotals + throw new BuilderException("You may only specify three different subtotals in a single transaction."); + } + $additionalAmountNode = $xml->createElement($fieldNames[$i] . "AdditionalAmtInfo"); + $additionalAmountNode->appendChild($xml->createElement("AmtType", $amtType)); + $additionalAmountNode->appendChild($xml->createElement("Amt", $amount)); + $autoSubstantiationNode->appendChild($additionalAmountNode); + $i++; + } + } + + $autoSubstantiationNode->appendChild($xml->createElement("MerchantVerificationValue", $builder->autoSubstantiation->merchantVerificationValue)); + $autoSubstantiationNode->appendChild($xml->createElement("RealTimeSubstantiation", $builder->autoSubstantiation->realTimeSubstantiation ? "Y" : "N")); + + if ($hasAdditionalAmount) { // Portico Gateway requires at least one healthcare amount subtotal + $block1->appendChild($autoSubstantiationNode); + } else { + throw new BuilderException("You must provide at least one healthcare amount w/autoSubstantiation requests"); + } + } $transaction->appendChild($block1); @@ -626,11 +669,11 @@ public function manageTransaction(ManagementBuilder $builder) $setElement = $tokenActions->appendChild($xml->createElement('Set')); $expMonth = $setElement->appendChild($xml->createElement('Attribute')); - $expMonth->appendChild($xml->createElement('Name', 'expmonth')); + $expMonth->appendChild($xml->createElement('Name', 'ExpMonth')); $expMonth->appendChild($xml->createElement('Value', $token->expMonth)); $expYear = $setElement->appendChild($xml->createElement('Attribute')); - $expYear->appendChild($xml->createElement('Name', 'expyear')); + $expYear->appendChild($xml->createElement('Name', 'ExpYear')); $expYear->appendChild($xml->createElement('Value', $token->expYear)); } else { $tokenActions->appendChild($xml->createElement('Delete')); diff --git a/src/Gateways/TransITConnector.php b/src/Gateways/TransITConnector.php new file mode 100644 index 00000000..4aa86ab6 --- /dev/null +++ b/src/Gateways/TransITConnector.php @@ -0,0 +1,628 @@ +transactionKey) && empty($this->manifest)) { + throw new ConfigurationException('transactionKey/manifest is required for this transaction.'); + } + + $xml = new DOMDocument(); + $paymentMethod = $builder->paymentMethod; + $commercialDataSubmitted = !empty($builder->commercialData); + + if ($paymentMethod->cardType === CardType::AMEX && !empty($paymentMethod->cvn)) { + $cardDataInputMode = 'MANUALLY_ENTERED_WITH_KEYED_CID_AMEX_JCB'; + } else { + if ($this->acceptorConfig->operatingEnvironment === OperatingEnvironment::ON_MERCHANT_PREMISES_ATTENDED) { + $cardDataInputMode = 'KEY_ENTERED_INPUT'; + } else { + $cardDataInputMode = 'ELECTRONIC_COMMERCE_NO_SECURITY_CHANNEL_ENCRYPTED_SET_WITHOUT_CARDHOLDER_CERTIFICATE'; + } + } + + $transaction = $xml->createElement($this->mapRequestType($builder)); + $transaction->appendChild($xml->createElement('deviceID', $this->deviceId)); + $transaction->appendChild($xml->createElement('transactionKey', $this->transactionKey)); + + if ($paymentMethod instanceof CreditCardData) { + if (!empty($this->acceptorConfig->cardDataSource)) { + $transaction->appendChild($xml->createElement('cardDataSource', $this->acceptorConfig->cardDataSource)); + } else { + if ($paymentMethod->readerPresent) { + $transaction->appendChild($xml->createElement('cardDataSource', $paymentMethod->cardPresent ? "MANUAL" : "PHONE")); + } else { + $transaction->appendChild($xml->createElement('cardDataSource', $paymentMethod->cardPresent ? "MANUAL" : "INTERNET")); + } + } + } elseif ($paymentMethod instanceof ITrackData) { + $transaction->appendChild($xml->createElement('cardDataSource', 'SWIPE')); + $cardDataInputMode = 'MAGNETIC_STRIPE_READER_INPUT'; + } + + if (!empty($builder->amount)) { + $transaction->appendChild($xml->createElement('transactionAmount', AmountUtils::transitFormat($builder->amount))); + } + + if ($commercialDataSubmitted) { // has to come before card info + $transaction->appendChild($xml->createElement('salesTax', AmountUtils::transitFormat($builder->commercialData->taxAmount))); + + $additionalTaxDetailsNode = $xml->createElement('additionalTaxDetails'); + + if (!empty($builder->commercialData->additionalTaxDetails->taxType)) { + $additionalTaxDetailsNode->appendChild($xml->createElement('taxType', $builder->commercialData->additionalTaxDetails->taxType)); + } else { + $additionalTaxDetailsNode->appendChild($xml->createElement('taxType', $builder->commercialData->taxType)); + } + + if (!empty($builder->commercialData->additionalTaxDetails->taxAmount)) { + $additionalTaxDetailsNode->appendChild($xml->createElement('taxAmount', AmountUtils::transitFormat($builder->commercialData->additionalTaxDetails->taxAmount))); + } else { + $additionalTaxDetailsNode->appendChild($xml->createElement('taxAmount', AmountUtils::transitFormat($builder->commercialData->taxAmount))); + } + + if (!empty($builder->commercialData->additionalTaxDetails->taxRate)) { + $additionalTaxDetailsNode->appendChild($xml->createElement('taxRate', $builder->commercialData->additionalTaxDetails->taxRate)); + } + + if (!empty($builder->commercialData->additionalTaxDetails->taxCategory)) { + $additionalTaxDetailsNode->appendChild($xml->createElement('taxCategory', $builder->commercialData->additionalTaxDetails->taxCategory)); + } + + $transaction->appendChild($additionalTaxDetailsNode); + + if ($builder->commercialData->freightAmount) { + $transaction->appendChild($xml->createElement('shippingCharges', AmountUtils::transitFormat($builder->commercialData->freightAmount))); + } + + if ($builder->commercialData->dutyAmount) { + $transaction->appendChild($xml->createElement('dutyCharges', AmountUtils::transitFormat($builder->commercialData->dutyAmount))); + } + } + + if ($paymentMethod instanceof CreditCardData) { + $transaction->appendChild($xml->createElement('cardNumber', $paymentMethod->token != null ? $paymentMethod->token : $paymentMethod->number)); + + if ($transaction->tagName != 'GetOnusToken') { + $transaction->appendChild($xml->createElement('expirationDate', $paymentMethod->getShortExpiry())); + + if (!empty($paymentMethod->cvn)) { + $transaction->appendChild($xml->createElement('cvv2', $paymentMethod->cvn)); + } + } + } elseif ($paymentMethod instanceof ITrackData) { + $trackField = ($paymentMethod->trackNumber == TrackNumber::TRACK_TWO) ? 'track2Data' : 'track1Data'; + $transaction->appendChild($xml->createElement($trackField, $paymentMethod->trackData)); + + if ($paymentMethod->paymentMethodType === PaymentMethodType::DEBIT) { + $transaction->appendChild($xml->createElement('pin', $paymentMethod->pinBlock)); + $transaction->appendChild($xml->createElement('pinKsn', $paymentMethod->encryptionData->ksn)); + } + } + + if (!empty($builder->paymentMethod->threeDSecure)) { + $treeDeeInfo = $builder->paymentMethod->threeDSecure; + + if (!empty($treeDeeInfo->secureCode)) { + $transaction->appendChild($xml->createElement('secureCode', $treeDeeInfo->secureCode)); + } + + if (!empty($treeDeeInfo->authenticationType)) { + $transaction->appendChild($xml->createElement('securityProtocol', $treeDeeInfo->authenticationType)); + } + + if (!empty($treeDeeInfo->ucafIndicator)) { + $transaction->appendChild($xml->createElement('ucafCollectionIndicator', $treeDeeInfo->ucafIndicator)); + } + + if (!empty($treeDeeInfo->authenticationValue)) { + $transaction->appendChild($xml->createElement('digitalPaymentCryptogram', $treeDeeInfo->authenticationValue)); + } + + if ($treeDeeInfo->getVersion() === Secure3dVersion::ONE) { + $transaction->appendChild($xml->createElement('programProtocol', '1')); + } elseif ($treeDeeInfo->getVersion() === Secure3dVersion::TWO) { + $transaction->appendChild($xml->createElement('programProtocol', '2')); + + if (!empty($treeDeeInfo->directoryServerTransactionId)) { + $transaction->appendChild($xml->createElement('directoryServerTransactionID', $treeDeeInfo->directoryServerTransactionId)); + } + } + + if (!empty($treeDeeInfo->eci)) { + $transaction->appendChild($xml->createElement('eciIndicator', $treeDeeInfo->eci)); + } + } + + if (!empty($builder->storedCredential->cardBrandTransactionId)) { + $transaction->appendChild(($xml->createElement('cardOnFileTransactionIdentifier', $builder->storedCredential->cardBrandTransactionId))); + } + + if ($transaction->tagName === 'GetOnusToken') { // bypass most of the fields used below since they don't apply to GetOnusToken + $transaction->appendChild($xml->createElement('cardVerification', 'YES')); + $transaction->appendChild($xml->createElement('developerID', $this->developerId)); + $response = $this->doTransaction($xml->saveXML($transaction)); + return $this->mapResponse($builder, $response); + } + + if (!empty($builder->commercialData->lineItems)) { + foreach ($builder->commercialData->lineItems as $lineItem) { + $productDetailsNode = $xml->createElement('productDetails'); + + if (!empty($lineItem->productCode)) { + $productDetailsNode->appendChild($xml->createElement('productCode', $lineItem->productCode)); + } + + if (!empty($lineItem->name)) { + $productDetailsNode->appendChild($xml->createElement('productName', $lineItem->name)); + } + + if (!empty($lineItem->unitCost)) { + $productDetailsNode->appendChild($xml->createElement('price', AmountUtils::transitFormat($lineItem->unitCost))); + } + + if (!empty($lineItem->quantity)) { + $productDetailsNode->appendChild($xml->createElement('quantity', $lineItem->quantity)); + } + + if (!empty($lineItem->unitOfMeasure)) { + $productDetailsNode->appendChild($xml->createElement('measurementUnit', $lineItem->unitOfMeasure)); + } + + if (!empty($lineItem->discountDetails)) { + $productDiscountDetailsNode = $xml->createElement('productDiscountDetails'); + + if (!empty($lineItem->discountDetails->discountName)) { + $productDiscountDetailsNode->appendChild($xml->createElement('productDiscountName', $lineItem->discountDetails->discountName)); + } + + $productDiscountDetailsNode->appendChild($xml->createElement('productDiscountAmount', AmountUtils::transitFormat($lineItem->discountDetails->discountAmount))); + + if (!empty($lineItem->discountDetails->discountPercentage)) { + $productDiscountDetailsNode->appendChild($xml->createElement('productDiscountPercentage', $lineItem->discountDetails->discountPercentage)); + } + + if (!empty($lineItem->discountDetails->discountType)) { + $productDiscountDetailsNode->appendChild($xml->createElement('productDiscountType', $lineItem->discountDetails->discountType)); + } + + if (!empty($lineItem->discountDetails->priority)) { + $productDiscountDetailsNode->appendChild($xml->createElement('priority', $lineItem->discountDetails->priority)); + } + + if (!empty($lineItem->discountDetails->stackable)) { + $productDiscountDetailsNode->appendChild($xml->createElement('stackable', $lineItem->discountDetails->stackable ? 'YES' : 'NO')); + } + + $productDetailsNode->appendChild($productDiscountDetailsNode); + } + + if ($lineItem->taxAmount !== null) { + $productTaxDetailsNode = $xml->createElement('productTaxDetails'); + + $productTaxDetailsNode->appendChild($xml->createElement('productTaxName', $lineItem->taxName)); + $productTaxDetailsNode->appendChild($xml->createElement('productTaxAmount', AmountUtils::transitFormat($lineItem->taxAmount))); + + if (!empty($lineItem->taxPercentage)) { + $productTaxDetailsNode->appendChild($xml->createElement('productTaxPercentage', $lineItem->taxPercentage)); + } + + if (!empty($lineItem->taxType)) { + $productTaxDetailsNode->appendChild($xml->createElement('productTaxType')); + } + + $productDetailsNode->appendChild($productTaxDetailsNode); + } + + if (!empty($lineItem->description)) { + $productDetailsNode->appendChild($xml->createElement('productNotes', $lineItem->description)); + } + + if (!empty($lineItem->commodityCode)) { + $productDetailsNode->appendChild($xml->createElement('productCommodityCode', $lineItem->commodityCode)); + } + + if (!empty($lineItem->alternateTaxId)) { + $productDetailsNode->appendChild($xml->createElement('alternateTaxID', $lineItem->alternateTaxId)); + } + + if ($lineItem->creditDebitIndicator === CreditDebitIndicator::CREDIT) { + $productDetailsNode->appendChild($xml->createElement('creditIndicator', 'YES')); + } + + $transaction->appendChild($productDetailsNode); + } + } + + if ($commercialDataSubmitted) { + if ($builder->commercialData->commercialIndicator === CommercialIndicator::LEVEL_II) { + $transaction->appendChild($xml->createElement('commercialCardLevel', 'LEVEL2')); + } elseif ($builder->commercialData->commercialIndicator === CommercialIndicator::LEVEL_III) { + $transaction->appendChild($xml->createElement('commercialCardLevel', 'LEVEL3')); + } + + if (!empty($builder->commercialData->poNumber)) { + $transaction->appendChild($xml->createElement('purchaseOrder', $builder->commercialData->poNumber)); + } + + if (!empty($builder->commercialData->description)) { // Amex only + $transaction->appendChild($xml->createElement('chargeDescriptor', $builder->commercialData->description)); + } + + if (!empty($builder->commercialData->customerVatNumber)) { + $transaction->appendChild($xml->createElement('customerVATNumber', $builder->commercialData->customerVatNumber)); + } + + if (!empty($builder->commercialData->customerReferenceId)) { + $transaction->appendChild($xml->createElement('customerRefID', $builder->commercialData->customerReferenceId)); + } + + if (!empty($builder->commercialData->orderDate)) { + $transaction->appendChild($xml->createElement('orderDate', $builder->commercialData->orderDate)); + } + + if (!empty($builder->commercialData->summaryCommodityCode)) { + $transaction->appendChild($xml->createElement('summaryCommodityCode', $builder->commercialData->summaryCommodityCode)); + } + + if (!empty($builder->commercialData->vatInvoiceNumber)) { + $transaction->appendChild($xml->createElement('vatInvoice', $builder->commercialData->vatInvoiceNumber)); + } + + if (!empty($builder->commercialData->supplierReferenceNumber)) { + $transaction->appendChild($xml->createElement('supplierReferenceNumber', $builder->commercialData->supplierReferenceNumber)); + } + + if (!empty($builder->commercialData->originPostalCode)) { + $transaction->appendChild($xml->createElement('shipFromZip', $builder->commercialData->originPostalCode)); + } + + if (!empty($builder->commercialData->destinationPostalCode)) { + $transaction->appendChild($xml->createElement('shipToZip', $builder->commercialData->destinationPostalCode)); + } + + if (!empty($builder->commercialData->destinationCountryCode)) { + $transaction->appendChild($xml->createElement('destinationCountryCode', $builder->commercialData->destinationCountryCode)); + } + } + + if (!empty($builder->billingAddress) && !$commercialDataSubmitted) { // addy and commercial data are mutually exclusive + $transaction->appendChild($xml->createElement('addressLine1', $builder->billingAddress->streetAddress1)); + $transaction->appendChild($xml->createElement('zip', $builder->billingAddress->postalCode)); + } + + if (!empty($builder->clientTransactionId)) { + $transaction->appendChild($xml->createElement('externalReferenceID', $builder->clientTransactionId)); // required for all non Lvl2/Lvl3 trans + } + + if ($builder->cardOnFile) { + $transaction->appendChild($xml->createElement('cardOnFile', 'Y')); + } + + if ($builder->requestMultiUseToken) { + $transaction->appendChild($xml->createElement('tokenRequired', 'Y')); + } + + if ($transaction->tagName === "CardVerification") { + $transaction->appendChild($xml->createElement('developerID', $this->developerId)); + } + + if (!empty($builder->cashTendered)) { + $transaction->appendChild($xml->createElement('cashTendered', AmountUtils::transitFormat($builder->cashTendered))); + } + + $transaction->appendChild($xml->createElement('terminalCapability', $this->acceptorConfig->cardDataInputCapability)); + $transaction->appendChild($xml->createElement('terminalOperatingEnvironment', $this->acceptorConfig->operatingEnvironment)); + $transaction->appendChild($xml->createElement('cardholderAuthenticationMethod', 'NOT_AUTHENTICATED')); + $transaction->appendChild($xml->createElement('terminalAuthenticationCapability', $this->acceptorConfig->cardHolderAuthenticationCapability)); + $transaction->appendChild($xml->createElement('terminalOutputCapability', $this->acceptorConfig->terminalOutputCapability)); + $transaction->appendChild($xml->createElement('maxPinLength', $this->acceptorConfig->pinCaptureCapability)); + $transaction->appendChild($xml->createElement('terminalCardCaptureCapability', $this->acceptorConfig->cardCaptureCapability ? 'CARD_CAPTURE_CAPABILITY' : 'NO_CAPABILITY')); + + if ($paymentMethod->cardPresent) { + $cardHolderPresentDetailValue = 'CARDHOLDER_PRESENT'; + } else { + if ($this->acceptorConfig->cardDataSource === CardDataSource::MAIL) { + $cardHolderPresentDetailValue = 'CARDHOLDER_NOT_PRESENT_MAIL_TRANSACTION'; + } elseif ($this->acceptorConfig->cardDataSource === CardDataSource::PHONE) { + $cardHolderPresentDetailValue = 'CARDHOLDER_NOT_PRESENT_PHONE_TRANSACTION'; + } else { + $cardHolderPresentDetailValue = 'CARDHOLDER_NOT_PRESENT_ELECTRONIC_COMMERCE'; + } + } + + $transaction->appendChild($xml->createElement('cardholderPresentDetail', $cardHolderPresentDetailValue)); + + if ($paymentMethod instanceof ITrackData || $paymentMethod->cardPresent) { + $transaction->appendChild($xml->createElement('cardPresentDetail', 'CARD_PRESENT')); + } else { + $transaction->appendChild($xml->createElement('cardPresentDetail', 'CARD_NOT_PRESENT')); + } + + if (!empty($builder->storedCredential)) { + if ($builder->storedCredential->initiator === StoredCredentialInitiator::MERCHANT) { + $transaction->appendChild($xml->createElement('cardDataInputMode', 'MERCHANT_INITIATED_TRANSACTION_CARD_CREDENTIAL_STORED_ON_FILE')); + } + } else { + $transaction->appendChild($xml->createElement('cardDataInputMode', $cardDataInputMode)); + } + + $transaction->appendChild($xml->createElement('cardholderAuthenticationEntity', $this->acceptorConfig->cardHolderAuthenticationEntity)); + $transaction->appendChild($xml->createElement('cardDataOutputCapability', $this->acceptorConfig->cardDataOutputCapability)); + + if ($transaction->tagName != "CardVerification") { + $transaction->appendChild($xml->createElement('developerID', $this->developerId)); + } + + if ($paymentMethod->cardType === CardType::DISCOVER && ($this->acceptorConfig->cardDataSource === CardDataSource::INTERNET || empty($this->acceptorConfig->cardDataSource))) { + if (!empty($builder->lastRegisteredDate)) { + $transaction->appendChild($xml->createElement('registeredUserIndicator', 'YES')); + $transaction->appendChild($xml->createElement('lastRegisteredChangeDate', $builder->lastRegisteredDate)); + } else { + $transaction->appendChild($xml->createElement('registeredUserIndicator', 'NO')); + $transaction->appendChild($xml->createElement('lastRegisteredChangeDate', '00/00/0000')); + } + } + + if ($paymentMethod->cardType === CardType::MASTERCARD && $transaction->tagName != "CardVerification") { + if (!empty($builder->AmountEstimated)) { + $transaction->appendChild($xml->createElement('authorizationIndicator', $builder->AmountEstimated ? "PREAUTH" : "FINAL")); + } else { + $transaction->appendChild($xml->createElement('authorizationIndicator', 'FINAL')); + } + } + + $response = $this->doTransaction($xml->saveXML($transaction)); + return $this->mapResponse($builder, $response); + } + + public function manageTransaction(ManagementBuilder $builder) + { + if (empty($this->transactionKey) && empty($this->manifest)) { + throw new ConfigurationException('transactionKey/manifest is required for this transaction.'); + } + + $xml = new DOMDocument(); + + $paymentMethod = $builder->paymentMethod; + + $transaction = $xml->createElement($this->mapRequestType($builder)); + $transaction->appendChild($xml->createElement('deviceID', $this->deviceId)); + $transaction->appendChild($xml->createElement('transactionKey', $this->transactionKey)); + + if (!empty($builder->amount)) { + $transaction->appendChild($xml->createElement('transactionAmount', AmountUtils::transitFormat($builder->amount))); + } + + if (!empty($builder->gratuity)) { + $transaction->appendChild($xml->createElement('tip', AmountUtils::transitFormat($builder->gratuity))); + } + + if (!empty($paymentMethod->transactionId)) { + $transaction->appendChild($xml->createElement('transactionID', $paymentMethod->transactionId)); + } + + if ($builder->multiCapture) { + $transaction->appendChild($xml->createElement('isPartialShipment', 'Y')); + + $partialShipmentDataNode = $xml->createElement('partialShipmentData'); + + if ($builder->multiCaptureSequence < 10) { + $builder->multiCaptureSequence = '0' . strval($builder->multiCaptureSequence); + } + + if ($builder->multiCapturePaymentCount < 10) { + $builder->multiCapturePaymentCount = '0' . strval($builder->multiCapturePaymentCount); + } + + $partialShipmentDataNode->appendChild($xml->createElement('currentPaymentSequenceNumber', $builder->multiCaptureSequence)); + $partialShipmentDataNode->appendChild($xml->createElement('totalPaymentCount', $builder->multiCapturePaymentCount)); + + $transaction->appendChild($partialShipmentDataNode); + } + + if ($builder->transactionType === TransactionType::BATCH_CLOSE) { + $transaction->appendChild($xml->createElement('operatingUserID', $this->userId)); + } else { + $transaction->appendChild($xml->createElement('developerID', $this->developerId)); + } + + if (!empty($builder->description) && $builder->transactionType == TransactionType::VOID) { + $transaction->appendChild($xml->createElement('voidReason', $builder->description)); + } + + $response = $this->doTransaction($xml->saveXML($transaction)); + return $this->mapResponse($builder, $response); + } + + public function serializeRequest(AuthorizationBuilder $builder) + { + throw new UnsupportedTransactionException(); + } + + public function mapRequestType(TransactionBuilder $builder) + { + switch ($builder->transactionType) { + case TransactionType::AUTH: + return 'Auth'; + case TransactionType::CAPTURE: + return 'Capture'; + case TransactionType::SALE: + if ($builder->paymentMethod->paymentMethodType === PaymentMethodType::DEBIT) { + return 'DebitSale'; + } elseif ($builder->paymentMethod->paymentMethodType === PaymentMethodType::CASH) { + return 'CashSale'; + } + return 'Sale'; + case TransactionType::BALANCE: + return 'BalanceInquiry'; + case TransactionType::VERIFY: + if ($builder->requestMultiUseToken === true) { + return 'GetOnusToken'; + } else { + return 'CardVerification'; + } + case TransactionType::EDIT: + return 'TipAdjustment'; + case TransactionType::VOID: + return 'Void'; + case TransactionType::BATCH_CLOSE: + return 'BatchClose'; + case TransactionType::REFUND: + return 'Return'; + default: + throw new UnsupportedTransactionException(); + } + } + + public function mapResponse($builder, $rawResponse) + { + $root = $this->xml2object($rawResponse); + + $this->checkResponse($root); + + $response = new Transaction(); + $response->responseCode = '00'; + $response->responseMessage = (string) $root->responseMessage; + $response->transactionId = (string) $root->transactionID; + $response->hostResponseDate = (string) $root->transactionTimestamp; + $response->authorizedAmount = (string) $root->transactionAmount; + $response->avsResponseCode = (string) $root->addressVerificationCode; + $response->cardType = (string) $root->cardType; + $response->cardLast4 = (string) $root->maskedCardNumber; + $response->commercialIndicator = (string) $root->commercialCard; + $response->customerReceipt = (string) $root->customerReceipt; + $response->merchantReceipt = (string) $root->merchantReceipt; + $response->token = (string)$root->token; + $response->authorizationCode = (string)$root->authCode; + $response->transactionKey = (string)$root->transactionKey; + $response->cardBrandTransactionId = (string)$root->cardTransactionIdentifier; + + if (!empty($builder) && $builder->transactionType === TransactionType::BATCH_CLOSE) { + $response->batchSummary = new BatchSummary(); + $response->batchSummary->totalAmount = (string)$root->batchInfo->saleAmount; + $response->batchSummary->transactionCount = (string)$root->batchInfo->saleCount; + } + + return $response; + } + + /** + * Converts a XML string to a simple object for use, + * removing extra nodes that are not necessary for + * handling the response + * + * @param string $xml Response XML from the gateway + * + * @return SimpleXMLElement + */ + protected function xml2object($xml) + { + $envelope = simplexml_load_string( + $xml, + 'SimpleXMLElement' + ); + + return $envelope; + } + + public function processReport(ReportBuilder $builder) + { + } + + protected function checkResponse($root) + { + $acceptedCodes = [ '00', 'A0000' ]; + + $responseCode = (string)$root->hostResponseCode; + $responseMessage = (string)$root->responseMessage; + $status = (string)$root->status; + + if (!in_array($responseCode, $acceptedCodes) && $status !== 'PASS') { + throw new GatewayException( + sprintf('Unexpected Gateway Response: %s - %s', $responseCode, $responseMessage), + $responseCode, + $responseMessage + ); + } + } + + public function getTransactionKey() + { + $xml = new DOMDocument(); + + $transaction = $xml->createElement('GenerateKey'); + $transaction->appendChild($xml->createElement('mid', $this->merchantId)); + $transaction->appendChild($xml->createElement('userID', $this->userId)); + $transaction->appendChild($xml->createElement('password', $this->password)); + + if (!empty($this->transactionKey)) { + $transaction->appendChild($xml->createElement('transactionKey', $this->transactionKey)); + } + + $response = $this->doTransaction($xml->saveXML($transaction)); + return $this->mapResponse(null, $response); + } + + public function createManifest() + { + $sEncryptedData = ""; + $now = new \DateTime(); + $dateFormatString = $now->format('mdY'); + $plainText = StringUtils::asPaddedAtEndString($this->merchantId, 20, ' ') + . StringUtils::asPaddedAtEndString($this->deviceId, 24, ' ') + . '000000000000' + . StringUtils::asPaddedAtEndString($dateFormatString, 8, ' '); + $tempTransactionKey = substr($this->transactionKey, 0, 16); + $encrypted = openssl_encrypt( + $plainText, + 'aes-128-cbc', + $tempTransactionKey, + OPENSSL_ZERO_PADDING, + $tempTransactionKey + ); + $sEncryptedData = bin2hex(base64_decode($encrypted)); + $hashKey = hash_hmac('md5', $this->transactionKey, $this->transactionKey); + return substr($hashKey, 0, 4) . $sEncryptedData . substr($hashKey, -4, 4); + } +} diff --git a/src/PaymentMethods/Credit.php b/src/PaymentMethods/Credit.php index eaf844cd..342fd263 100644 --- a/src/PaymentMethods/Credit.php +++ b/src/PaymentMethods/Credit.php @@ -90,6 +90,7 @@ public function authorize($amount = null, $isEstimated = false) */ public function charge($amount = null) { + return (new AuthorizationBuilder(TransactionType::SALE, $this)) ->withAmount($amount != null ? $amount : ($this->threeDSecure != null ? $this->threeDSecure->getAmount() : null)) ->withCurrency($this->threeDSecure != null ? $this->threeDSecure->getCurrency() : null) @@ -171,7 +172,7 @@ public function tokenize() /** * Updates the token expiry date with the values proced to the card object - * + * * @return bool value indicating success/failure */ public function updateTokenExpiry() @@ -192,10 +193,11 @@ public function updateTokenExpiry() /** * Deletes the token associated with the current card object - * + * * @return bool value indicating success/failure */ - public function deleteToken() { + public function deleteToken() + { if (empty($this->token)) { throw new BuilderException('Token cannot be null'); } diff --git a/src/PaymentMethods/CreditTrackData.php b/src/PaymentMethods/CreditTrackData.php index f15eb354..395d8472 100644 --- a/src/PaymentMethods/CreditTrackData.php +++ b/src/PaymentMethods/CreditTrackData.php @@ -3,9 +3,30 @@ namespace GlobalPayments\Api\PaymentMethods; use GlobalPayments\Api\PaymentMethods\Interfaces\ITrackData; +use GlobalPayments\Api\Utils\CardUtils; class CreditTrackData extends Credit implements ITrackData { + public $entryMethod; public $value; + public $discretionaryData; + public $expiry; + public $pan; + public $purchaseDeviceSequenceNumber; + public $trackNumber; + public $trackData; + + public function setValue($value) + { + $this->value = $value; + CardUtils::parseTrackData($this); + $this->cardType = CardUtils::getCardType($this->pan); + $this->isFleet = CardUtils::isFleet($this->cardType, $this->pan); + + if ($this->cardType == 'WexFleet' && $this->discretionaryData != null && + strlen($this->discretionaryData) >= 8) { + $this->purchaseDeviceSequenceNumber = substr($this->discretionaryData, 3, 8); + } + } } diff --git a/src/PaymentMethods/DebitTrackData.php b/src/PaymentMethods/DebitTrackData.php index 553a705e..e49bc447 100644 --- a/src/PaymentMethods/DebitTrackData.php +++ b/src/PaymentMethods/DebitTrackData.php @@ -3,9 +3,29 @@ namespace GlobalPayments\Api\PaymentMethods; use GlobalPayments\Api\PaymentMethods\Interfaces\ITrackData; +use GlobalPayments\Api\Utils\CardUtils; class DebitTrackData extends Debit implements ITrackData { public $entryMethod; public $value; + public $discretionaryData; + public $expiry; + public $pan; + public $purchaseDeviceSequenceNumber; + public $trackNumber; + public $trackData; + + public function setValue($value) + { + $this->value = $value; + CardUtils::parseTrackData($this); + $this->cardType = CardUtils::getCardType($this->pan); + $this->isFleet = CardUtils::isFleet($this->cardType, $this->pan); + + if ($this->cardType == 'WexFleet' && $this->discretionaryData != null && + strlen($this->discretionaryData) >= 8) { + $this->purchaseDeviceSequenceNumber = substr($this->discretionaryData, 3, 8); + } + } } diff --git a/src/PaymentMethods/GiftCard.php b/src/PaymentMethods/GiftCard.php index 9ac78f2b..bf12f0c1 100644 --- a/src/PaymentMethods/GiftCard.php +++ b/src/PaymentMethods/GiftCard.php @@ -183,7 +183,7 @@ public function reverse($amount = null) } /** - * Rewards the payment method + * Rewards/Add Points to the payment method * * @param string|float $amount Amount to reward * @@ -252,5 +252,5 @@ public function __set($name, $value) $this->valueType = 'TrackData'; return; } - } + } } diff --git a/src/Services/BatchService.php b/src/Services/BatchService.php index d8a097d8..23184bac 100644 --- a/src/Services/BatchService.php +++ b/src/Services/BatchService.php @@ -11,6 +11,6 @@ class BatchService public static function closeBatch() { $response = (new ManagementBuilder(TransactionType::BATCH_CLOSE))->execute(); - return new BatchSummary(); + return $response; } } diff --git a/src/ServicesConfig.php b/src/ServicesConfig.php index 32248aee..586f8fb7 100644 --- a/src/ServicesConfig.php +++ b/src/ServicesConfig.php @@ -4,10 +4,15 @@ use GlobalPayments\Api\Entities\Exceptions\ConfigurationException; use GlobalPayments\Api\Entities\Enums\Environment; +use GlobalPayments\Api\Entities\Enums\GatewayProvider; use GlobalPayments\Api\Entities\Enums\Secure3dVersion; +use GlobalPayments\Api\Gateways\Gateway; class ServicesConfig { + /** @var GatewayProvider */ + public $gatewayProvider; + // Portico public $siteId; public $licenseId; @@ -17,6 +22,15 @@ class ServicesConfig public $developerId; public $versionNumber; public $secretApiKey; + public $uniqueDeviceId; + + public function getPayPlanEndpoint() + { + if (empty($this->secretApiKey) || strpos(strtolower($this->secretApiKey), 'cert') !== false) { + return '/Portico.PayPlan.v2/'; + } + return '/PayPlan.v2/'; + } // Realex public $accountId; @@ -27,33 +41,41 @@ class ServicesConfig public $channel; public $hostedPaymentConfig; - /** - * @var string - */ + // GP Data Services + public $dataClientId; + public $dataClientSecret; + public $dataClientUserId; + public $dataClientServiceUrl; + + // Secure 3d + /** @var string */ public $challengeNotificationUrl; - /** - * @var string - */ + /** @var string */ public $merchantContactUrl; - /** - * @var string - */ + /** @var string */ public $methodNotificationUrl; - /** - * @var Secure3dVersion - */ + /** @var Secure3dVersion */ public $secure3dVersion; + // Genius + public $merchantName; + public $merchantSiteId; + public $merchantKey; + public $registerNumber; + public $terminalId; + + //TransIT + public $transactionKey; + public $manifest; + public $acceptorConfig; + // Common public $curlOptions; - /** - * @var Environment - */ - + /** @var Environment */ public $environment; public $serviceUrl; public $timeout; @@ -62,68 +84,84 @@ public function __construct() { $this->timeout = 65000; $this->environment = Environment::TEST; + $this->gatewayProvider = GatewayProvider::PORTICO; } public function validate() { - // Portico API key - if (!empty($this->secretApiKey) - && ( - !empty($this->siteId) - || !empty($this->licenseId) - || !empty($this->deviceId) - || !empty($this->username) - || !empty($this->password) - ) - ) { - throw new ConfigurationException( - "Configuration contains both secret API key and legacy credentials. These are mutually exclusive." - ); - } - - // Portico legacy - if (( - !empty($this->siteId) - || !empty($this->licenseId) - || !empty($this->deviceId) - || !empty($this->username) - || !empty($this->password) - ) - && ( - empty($this->siteId) - || empty($this->licenseId) - || empty($this->deviceId) - || empty($this->username) - || empty($this->password) - ) - ) { - throw new ConfigurationException( - "Site, License, Device, Username, and Password should all have values for this configuration." - ); - } + switch ($this->gatewayProvider) { + case GatewayProvider::GP_ECOM: + // realex + if (empty($this->merchantId)) { + throw new ConfigurationException('merchantId is required for this configuration.'); + } elseif (empty($this->sharedSecret)) { + throw new ConfigurationException('sharedSecret is required for this configuration.'); + } + break; + case GatewayProvider::GENIUS: + // Genius + if (empty($this->merchantSiteId)) { + throw new ConfigurationException('merchantSiteId is required for this configuration.'); + } elseif (empty($this->merchantName)) { + throw new ConfigurationException('merchantName is required for this configuration.'); + } elseif (empty($this->merchantKey)) { + throw new ConfigurationException('merchantKey is required for this configuration.'); + } + break; + case GatewayProvider::PORTICO: + // Portico API key + if (!empty($this->secretApiKey) + && ( + !empty($this->siteId) + || !empty($this->licenseId) + || !empty($this->deviceId) + || !empty($this->username) + || !empty($this->password) + ) + ) { + throw new ConfigurationException( + "Configuration contains both secret API key and legacy credentials. These are mutually exclusive." + ); + } - // Realex - if ((empty($this->secretApiKey) - && ( - empty($this->siteId) - && empty($this->licenseId) - && empty($this->deviceId) - && empty($this->username) - && empty($this->password) - )) - && empty($this->merchantId) - ) { - throw new ConfigurationException( - "MerchantId should not be empty for this configuration." - ); + // Portico legacy + if (( + !empty($this->siteId) + || !empty($this->licenseId) + || !empty($this->deviceId) + || !empty($this->username) + || !empty($this->password) + ) + && ( + empty($this->siteId) + || empty($this->licenseId) + || empty($this->deviceId) + || empty($this->username) + || empty($this->password) + ) + ) { + throw new ConfigurationException( + "Site, License, Device, Username, and Password should all have values for this configuration." + ); + } + break; + case GatewayProvider::TRANSIT: + // TransIT + if (empty($this->deviceId)) { + throw new ConfigurationException('deviceID is required for this configuration.'); + } + if (empty($this->acceptorConfig)) { + throw new ConfigurationException('You must provide a valid AcceptorConfig.'); + } + break; } - // Service URL - if (empty($this->serviceUrl) && $this->secure3dVersion == null) { - throw new ConfigurationException( - "Service URL could not be determined from the credentials provided. Please specify an endpoint." - ); - } + // // Service URL + // if (empty($this->serviceUrl) && $this->secure3dVersion != null) { + // throw new ConfigurationException( + // "Service URL could not be determined from the credentials provided. Please specify an endpoint." + // ); + // } // secure 3d if ($this->secure3dVersion != null) { diff --git a/src/ServicesContainer.php b/src/ServicesContainer.php index c36c7025..b6f58839 100644 --- a/src/ServicesContainer.php +++ b/src/ServicesContainer.php @@ -10,9 +10,12 @@ use GlobalPayments\Api\Gateways\RealexConnector; use GlobalPayments\Api\Gateways\ISecure3dProvider; use GlobalPayments\Api\Entities\Enums\Environment; +use GlobalPayments\Api\Entities\Enums\GatewayProvider; use GlobalPayments\Api\Entities\Enums\Secure3dVersion; use GlobalPayments\Api\Entities\Enums\ServiceEndpoints; use GlobalPayments\Api\Entities\Exceptions\ConfigurationException; +use GlobalPayments\Api\Gateways\MerchantwareConnector; +use GlobalPayments\Api\Gateways\TransITConnector; class ServicesContainer { @@ -84,7 +87,9 @@ public static function configure(ServicesConfig $config) $config->validate(); $gateway = null; - if (!empty($config->merchantId)) { + + // GP ECOM + if ($config->gatewayProvider === GatewayProvider::GP_ECOM) { if (empty($config->serviceUrl)) { if ($config->environment === Environment::TEST) { $config->serviceUrl = ServiceEndpoints::GLOBAL_ECOM_TEST; @@ -129,6 +134,49 @@ public static function configure(ServicesConfig $config) static::$instance->setSecure3dProvider(Secure3dVersion::TWO, $secure3d2); } + // Genius + } elseif ($config->gatewayProvider === GatewayProvider::GENIUS) { + if (empty($config->serviceUrl)) { + if ($config->environment === Environment::TEST) { + $config->serviceUrl = ServiceEndpoints::MERCHANTWARE_TEST; + } else { + $config->serviceUrl = ServiceEndpoints::MERCHANTWARE_PRODUCTION; + } + } + + $gateway = new MerchantwareConnector(); + $gateway->merchantName = $config->merchantName; + $gateway->merchantSiteId = $config->merchantSiteId; + $gateway->merchantKey = $config->merchantKey; + $gateway->registerNumber = $config->registerNumber; + $gateway->terminalId = $config->terminalId; + $gateway->timeout = $config->timeout; + $gateway->serviceUrl = $config->serviceUrl; + + static::$instance = new static($gateway); + // TransIT + } elseif ($config->gatewayProvider === GatewayProvider::TRANSIT) { + if (empty($config->serviceUrl)) { + if ($config->environment === Environment::TEST) { + $config->serviceUrl = ServiceEndpoints::TRANSIT_TEST; + } else { + $config->serviceUrl = ServiceEndpoints::TRANSIT_PRODUCTION; + } + } + + $gateway = new TransITConnector(); + $gateway->deviceId = $config->deviceId; + $gateway->merchantId = $config->merchantId; + $gateway->transactionKey = $config->transactionKey; + $gateway->manifest = $config->manifest; + $gateway->userId = $config->username; + $gateway->password = $config->password; + $gateway->developerId = $config->developerId; + $gateway->timeout = $config->timeout; + $gateway->serviceUrl = $config->serviceUrl; + $gateway->acceptorConfig = $config->acceptorConfig; + + static::$instance = new static($gateway); } else { if (empty($config->serviceUrl) && !empty($config->secretApiKey)) { $env = explode('_', $config->secretApiKey)[1]; @@ -152,22 +200,18 @@ public static function configure(ServicesConfig $config) $gateway->serviceUrl = $config->serviceUrl . '/Hps.Exchange.PosGateway/PosGatewayService.asmx'; $gateway->curlOptions = $config->curlOptions; - $payplanEndPoint = (strpos(strtolower($config->serviceUrl), 'cert.') > 0) ? - '/Portico.PayPlan.v2/': - '/PayPlan.v2/'; + static::$instance = new static($gateway); + + if (!empty($config->dataClientId)) { + // TODO: Add data services connector class and code + } else { + static::$instance = new static($gateway); + } $recurring = new PayPlanConnector(); - $recurring->siteId = $config->siteId; - $recurring->licenseId = $config->licenseId; - $recurring->deviceId = $config->deviceId; - $recurring->username = $config->username; - $recurring->password = $config->password; $recurring->secretApiKey = $config->secretApiKey; - $recurring->developerId = $config->developerId; - $recurring->versionNumber = $config->versionNumber; $recurring->timeout = $config->timeout; - $recurring->serviceUrl = $config->serviceUrl . $payplanEndPoint; - $recurring->curlOptions = $config->curlOptions; + $recurring->serviceUrl = $config->serviceUrl . $config->getPayPlanEndpoint(); static::$instance = new static($gateway, $recurring); } diff --git a/src/Terminals/Builders/TerminalReportBuilder.php b/src/Terminals/Builders/TerminalReportBuilder.php index d9023df7..6a3aceb8 100644 --- a/src/Terminals/Builders/TerminalReportBuilder.php +++ b/src/Terminals/Builders/TerminalReportBuilder.php @@ -1,53 +1,53 @@ -reportType = $reportType; - } - - /** - * {@inheritdoc} - * - * @return Transaction - */ - public function execute() - { - return ConnectionContainer::instance()-> - processReport($this); - } - - public function where($criteria, $value) - { - if ($this->searchBuilder == null) { - $this->searchBuilder = new TerminalSearchBuilder($this); - } - - return $this->searchBuilder->andCondition($criteria, $value); - } -} +reportType = $reportType; + } + + /** + * {@inheritdoc} + * + * @return Transaction + */ + public function execute() + { + return ConnectionContainer::instance()-> + processReport($this); + } + + public function where($criteria, $value) + { + if ($this->searchBuilder == null) { + $this->searchBuilder = new TerminalSearchBuilder($this); + } + + return $this->searchBuilder->andCondition($criteria, $value); + } +} diff --git a/src/Terminals/Builders/TerminalSearchBuilder.php b/src/Terminals/Builders/TerminalSearchBuilder.php index 9c2213c9..de695298 100644 --- a/src/Terminals/Builders/TerminalSearchBuilder.php +++ b/src/Terminals/Builders/TerminalSearchBuilder.php @@ -1,36 +1,36 @@ -reportBuilder = $reportBuilder; - } - - public function execute() - { - return $this->reportBuilder->execute(); - } - - public function andCondition($criteria, $value) - { - if (property_exists($this, $criteria)) { - $this->{$criteria} = $value; - } - return $this; - } -} +reportBuilder = $reportBuilder; + } + + public function execute() + { + return $this->reportBuilder->execute(); + } + + public function andCondition($criteria, $value) + { + if (property_exists($this, $criteria)) { + $this->{$criteria} = $value; + } + return $this; + } +} diff --git a/src/Terminals/Enums/SAFReportType.php b/src/Terminals/Enums/SAFReportType.php index 77b52844..ccf842c2 100644 --- a/src/Terminals/Enums/SAFReportType.php +++ b/src/Terminals/Enums/SAFReportType.php @@ -1,24 +1,24 @@ -deviceDetails = $config; - } - - public function connect() - { - } - - public function disconnect() - { - } - - /* - * Send request message to device using socket connection - * @param string $message XML request string - */ - - public function send($message, $requestType = null) - { - $this->requestType = $requestType; - $out = ''; - try { - $protocol = ($this->deviceDetails->connectionMode === ConnectionModes::HTTPS) ? 'https' : 'http'; - $options = $this->getCurlOptions(); - $url = sprintf( - "%s://%s:%s?%s", - $protocol, - $this->deviceDetails->ipAddress, - $this->deviceDetails->port, - base64_encode($message) - ); - - $request = curl_init($url); - curl_setopt_array($request, $options); - $out = curl_exec($request); - - if (!empty($out)) { - TerminalUtils::manageLog($this->deviceDetails->logManagementProvider, $out, true); - return $out; - } - } catch (\Exception $e) { - TerminalUtils::manageLog($this->deviceDetails->logManagementProvider, $e->getMessage(), true); - throw new GatewayException('Device error: ' . $e->getMessage(), null, $e->getMessage()); - } - return; - } - - public function parseResponse($gatewayRawResponse) - { - } - - private function getCurlOptions() - { - $config = [ - CURLOPT_CONNECTTIMEOUT => $this->deviceDetails->timeout, - CURLOPT_TIMEOUT => $this->deviceDetails->timeout, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_VERBOSE => false - ]; - if ($this->deviceDetails->connectionMode === ConnectionModes::HTTPS) { - $config[CURLOPT_SSL_VERIFYPEER] = false; //true - $config[CURLOPT_SSL_VERIFYHOST] = false; //2 - $config[CURLOPT_PROTOCOLS] = CURLPROTO_HTTPS; - $config[CURLOPT_SSLVERSION] = CURL_SSLVERSION_TLSv1_2; - } - - return $config; - } -} +deviceDetails = $config; + } + + public function connect() + { + } + + public function disconnect() + { + } + + /* + * Send request message to device using socket connection + * @param string $message XML request string + */ + + public function send($message, $requestType = null) + { + $this->requestType = $requestType; + $out = ''; + try { + $protocol = ($this->deviceDetails->connectionMode === ConnectionModes::HTTPS) ? 'https' : 'http'; + $options = $this->getCurlOptions(); + $url = sprintf( + "%s://%s:%s?%s", + $protocol, + $this->deviceDetails->ipAddress, + $this->deviceDetails->port, + base64_encode($message) + ); + + $request = curl_init($url); + curl_setopt_array($request, $options); + $out = curl_exec($request); + + if (!empty($out)) { + TerminalUtils::manageLog($this->deviceDetails->logManagementProvider, $out, true); + return $out; + } + } catch (\Exception $e) { + TerminalUtils::manageLog($this->deviceDetails->logManagementProvider, $e->getMessage(), true); + throw new GatewayException('Device error: ' . $e->getMessage(), null, $e->getMessage()); + } + return; + } + + public function parseResponse($gatewayRawResponse) + { + } + + private function getCurlOptions() + { + $config = [ + CURLOPT_CONNECTTIMEOUT => $this->deviceDetails->timeout, + CURLOPT_TIMEOUT => $this->deviceDetails->timeout, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_VERBOSE => false + ]; + if ($this->deviceDetails->connectionMode === ConnectionModes::HTTPS) { + $config[CURLOPT_SSL_VERIFYPEER] = false; //true + $config[CURLOPT_SSL_VERIFYHOST] = false; //2 + $config[CURLOPT_PROTOCOLS] = CURLPROTO_HTTPS; + $config[CURLOPT_SSLVERSION] = CURL_SSLVERSION_TLSv1_2; + } + + return $config; + } +} diff --git a/src/Terminals/PAX/Interfaces/PaxTcpInterface.php b/src/Terminals/PAX/Interfaces/PaxTcpInterface.php index 508d02a4..c93bc5b4 100644 --- a/src/Terminals/PAX/Interfaces/PaxTcpInterface.php +++ b/src/Terminals/PAX/Interfaces/PaxTcpInterface.php @@ -1,253 +1,253 @@ -deviceDetails = $config; - } - - /* - * Create socket connection with device - * Throws GatewayException incase of connection error - */ - public function connect() - { - - if (is_resource($this->tcpConnection)) { - return; - } - - $errno = ''; - $errstr = ''; - - // open socket - try { - if ($this->deviceDetails->connectionMode === ConnectionModes::SSL_TCP) { - $context = stream_context_create([ - 'ssl' => [ - "crypto_method" => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT - ] - ]); - - stream_context_set_option($context, 'ssl', 'allow_self_signed', true); - stream_context_set_option($context, 'ssl', 'verify_peer', false); //true - stream_context_set_option($context, 'ssl', 'verify_peer_name', false); //true - - $this->tcpConnection = stream_socket_client( - $this->deviceDetails->ipAddress . ':' . $this->deviceDetails->port, - $errno, - $errstr, - $this->deviceDetails->timeout, - STREAM_CLIENT_CONNECT, - $context - ); - } else { - $this->tcpConnection = pfsockopen( - $this->deviceDetails->ipAddress, - $this->deviceDetails->port, - $errno, - $errstr - ); - } - } catch (\Exception $e) { - TerminalUtils::manageLog($this->deviceDetails->logManagementProvider, $errstr, true); - throw new GatewayException( - sprintf('Device connection error: %s - %s', $errno, $errstr), - $errno, - $errstr - ); - } - } - - /* - * Close TCP socket connection with device - */ - public function disconnect() - { - // close socket - if (is_resource($this->tcpConnection)) { - fclose($this->tcpConnection); - } - } - - /* - * Send request message to device using socket connection - * @param string $message XML request string - */ - public function send($message, $requestType = null) - { - $this->connect(); - $this->requestType = $requestType; - if ($this->tcpConnection !== null) { - try { - TerminalUtils::manageLog($this->deviceDetails->logManagementProvider, "Input Message: $message"); - for ($i=0; $i < 3; $i++) { - fputs($this->tcpConnection, $message); - $bytesReceived = $this->getTerminalResponseAsync(); - - if ($bytesReceived !== null) { - $length = strlen($bytesReceived); - - //last chr is the LRC - $lrc = isset($bytesReceived[$length - 1]) ? $bytesReceived[$length - 1] : ''; - - //remove first and last chr to caluclate LRC - $rawString = isset($bytesReceived[$length - 1]) ? substr($bytesReceived, 0, ($length - 1)) : ''; - $calculateLRC = TerminalUtils::calculateLRC(trim($rawString)); - - if (empty($lrc) || $lrc != $calculateLRC) { - $this->sendControlCode(ControlCodes::NAK); - } else { - TerminalUtils::manageLog( - $this->deviceDetails->logManagementProvider, - "Device Response : $rawString " - ); - $this->sendControlCode(ControlCodes::ACK); - $this->disconnect(); - return $rawString; - } - } - } - } catch (\Exception $e) { - TerminalUtils::manageLog($this->deviceDetails->logManagementProvider, $e->getMessage(), true); - throw new GatewayException( - 'Device error: ' . $e->getMessage(), - null, - $e->getMessage() - ); - } - } - return; - } - - /* - * Filter the device response. remove control characters - * - * - * @param String $gatewayResponse response from device - */ - public function parseResponse($gatewayRawResponse) - { - } - - - private function getTerminalResponse() - { - $bytesReceived = $this->awaitResponse(true); - - if (!empty($bytesReceived)) { - $code = bin2hex($bytesReceived[0]); - - if ($code == ControlCodes::NAK) { - return null; - } elseif ($code == ControlCodes::EOT) { - throw new GatewayException('Terminal returned EOT for the current message'); - } elseif ($code == ControlCodes::ACK) { - return $this->getTerminalResponse(); - } elseif ($code == ControlCodes::STX) { - return $bytesReceived; - } else { - throw new GatewayException("Unknown message received: $code"); - } - } - } - - private function awaitResponse($readString = false) - { - $startTime = time(); - do { - $part = ($readString === true) ? fgets($this->tcpConnection) : fgetc($this->tcpConnection); - if (!empty($part)) { - return $part; - } - $timeDiff = time() - $startTime; - if ($timeDiff >= $this->deviceDetails->timeout) { - break; - } - } while (true); - - throw new GatewayException( - 'Terminal did not respond in the given timeout' - ); - } - - private function sendControlCode($code) - { - try { - if ($code != ControlCodes::NAK) { - $code = bin2hex($code); - $this->nakCount = 0; - fputs($this->tcpConnection, $code); - } elseif (++$this->nakCount == 3) { - $this->sendControlCode(ControlCodes::EOT); - } - } catch (\Exception $e) { - throw new GatewayException("Failed to send control code."); - } - } - - private function getTerminalResponseAsync() - { - $bytesReceived = $this->awaitResponse(); - - if (!empty($bytesReceived)) { - $code = bin2hex($bytesReceived); - - if ($code == ControlCodes::NAK) { - return null; - } elseif ($code == ControlCodes::EOT) { - throw new GatewayException('Terminal returned EOT for the current message'); - } elseif ($code == ControlCodes::ACK) { - return $this->getTerminalResponse(); - } elseif ($code == ControlCodes::STX) { - return $bytesReceived; - } else { - throw new GatewayException("Unknown message received: $code"); - } - } - } - - public function __destruct() - { - $this->disconnect(); - } -} +deviceDetails = $config; + } + + /* + * Create socket connection with device + * Throws GatewayException incase of connection error + */ + public function connect() + { + + if (is_resource($this->tcpConnection)) { + return; + } + + $errno = ''; + $errstr = ''; + + // open socket + try { + if ($this->deviceDetails->connectionMode === ConnectionModes::SSL_TCP) { + $context = stream_context_create([ + 'ssl' => [ + "crypto_method" => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT + ] + ]); + + stream_context_set_option($context, 'ssl', 'allow_self_signed', true); + stream_context_set_option($context, 'ssl', 'verify_peer', false); //true + stream_context_set_option($context, 'ssl', 'verify_peer_name', false); //true + + $this->tcpConnection = stream_socket_client( + $this->deviceDetails->ipAddress . ':' . $this->deviceDetails->port, + $errno, + $errstr, + $this->deviceDetails->timeout, + STREAM_CLIENT_CONNECT, + $context + ); + } else { + $this->tcpConnection = pfsockopen( + $this->deviceDetails->ipAddress, + $this->deviceDetails->port, + $errno, + $errstr + ); + } + } catch (\Exception $e) { + TerminalUtils::manageLog($this->deviceDetails->logManagementProvider, $errstr, true); + throw new GatewayException( + sprintf('Device connection error: %s - %s', $errno, $errstr), + $errno, + $errstr + ); + } + } + + /* + * Close TCP socket connection with device + */ + public function disconnect() + { + // close socket + if (is_resource($this->tcpConnection)) { + fclose($this->tcpConnection); + } + } + + /* + * Send request message to device using socket connection + * @param string $message XML request string + */ + public function send($message, $requestType = null) + { + $this->connect(); + $this->requestType = $requestType; + if ($this->tcpConnection !== null) { + try { + TerminalUtils::manageLog($this->deviceDetails->logManagementProvider, "Input Message: $message"); + for ($i=0; $i < 3; $i++) { + fputs($this->tcpConnection, $message); + $bytesReceived = $this->getTerminalResponseAsync(); + + if ($bytesReceived !== null) { + $length = strlen($bytesReceived); + + //last chr is the LRC + $lrc = isset($bytesReceived[$length - 1]) ? $bytesReceived[$length - 1] : ''; + + //remove first and last chr to caluclate LRC + $rawString = isset($bytesReceived[$length - 1]) ? substr($bytesReceived, 0, ($length - 1)) : ''; + $calculateLRC = TerminalUtils::calculateLRC(trim($rawString)); + + if (empty($lrc) || $lrc != $calculateLRC) { + $this->sendControlCode(ControlCodes::NAK); + } else { + TerminalUtils::manageLog( + $this->deviceDetails->logManagementProvider, + "Device Response : $rawString " + ); + $this->sendControlCode(ControlCodes::ACK); + $this->disconnect(); + return $rawString; + } + } + } + } catch (\Exception $e) { + TerminalUtils::manageLog($this->deviceDetails->logManagementProvider, $e->getMessage(), true); + throw new GatewayException( + 'Device error: ' . $e->getMessage(), + null, + $e->getMessage() + ); + } + } + return; + } + + /* + * Filter the device response. remove control characters + * + * + * @param String $gatewayResponse response from device + */ + public function parseResponse($gatewayRawResponse) + { + } + + + private function getTerminalResponse() + { + $bytesReceived = $this->awaitResponse(true); + + if (!empty($bytesReceived)) { + $code = bin2hex($bytesReceived[0]); + + if ($code == ControlCodes::NAK) { + return null; + } elseif ($code == ControlCodes::EOT) { + throw new GatewayException('Terminal returned EOT for the current message'); + } elseif ($code == ControlCodes::ACK) { + return $this->getTerminalResponse(); + } elseif ($code == ControlCodes::STX) { + return $bytesReceived; + } else { + throw new GatewayException("Unknown message received: $code"); + } + } + } + + private function awaitResponse($readString = false) + { + $startTime = time(); + do { + $part = ($readString === true) ? fgets($this->tcpConnection) : fgetc($this->tcpConnection); + if (!empty($part)) { + return $part; + } + $timeDiff = time() - $startTime; + if ($timeDiff >= $this->deviceDetails->timeout) { + break; + } + } while (true); + + throw new GatewayException( + 'Terminal did not respond in the given timeout' + ); + } + + private function sendControlCode($code) + { + try { + if ($code != ControlCodes::NAK) { + $code = bin2hex($code); + $this->nakCount = 0; + fputs($this->tcpConnection, $code); + } elseif (++$this->nakCount == 3) { + $this->sendControlCode(ControlCodes::EOT); + } + } catch (\Exception $e) { + throw new GatewayException("Failed to send control code."); + } + } + + private function getTerminalResponseAsync() + { + $bytesReceived = $this->awaitResponse(); + + if (!empty($bytesReceived)) { + $code = bin2hex($bytesReceived); + + if ($code == ControlCodes::NAK) { + return null; + } elseif ($code == ControlCodes::EOT) { + throw new GatewayException('Terminal returned EOT for the current message'); + } elseif ($code == ControlCodes::ACK) { + return $this->getTerminalResponse(); + } elseif ($code == ControlCodes::STX) { + return $bytesReceived; + } else { + throw new GatewayException("Unknown message received: $code"); + } + } + } + + public function __destruct() + { + $this->disconnect(); + } +} diff --git a/src/Terminals/PAX/PaxController.php b/src/Terminals/PAX/PaxController.php index f860ecfe..da1aee43 100644 --- a/src/Terminals/PAX/PaxController.php +++ b/src/Terminals/PAX/PaxController.php @@ -1,417 +1,417 @@ -device = new PaxInterface($this); - $this->requestIdProvider = $config->requestIdProvider; - $this->deviceConfig = $config; - - switch ($config->connectionMode) { - case ConnectionModes::TCP_IP: - case ConnectionModes::SSL_TCP: - $this->deviceInterface = new PaxTcpInterface($config); - break; - case ConnectionModes::HTTP: - case ConnectionModes::HTTPS: - $this->deviceInterface = new PaxHttpInterface($config); - break; - } - } - - /* - * Send control message to device - * - * @param string $message control message to device - * - * @return PaxResponse parsed device response - */ - - public function send($message, $requestType = null) - { - //send message to gateway - return $this->deviceInterface->send(trim($message), $requestType); - } - - public function manageTransaction($builder) - { - $requestId = (!empty($builder->requestId)) ? - $builder->requestId : - $this->requestIdProvider->getRequestId(); - - $amount = new AmountRequest(); - $account = new AccountRequest(); - $extData = new ExtDataSubGroup(); - $trace = new TraceRequest(); - $trace->referenceNumber = $requestId; - - $amount->transactionAmount = TerminalUtils::formatAmount($builder->amount); - - if ($builder->paymentMethod != null) { - if ($builder->paymentMethod instanceof TransactionReference) { - $transactionReference = $builder->paymentMethod; - if (!empty($transactionReference->transactionId)) { - $extData->details[PaxExtData::HOST_REFERENCE_NUMBER] = - $transactionReference->transactionId; - } - } elseif ($builder->paymentMethod instanceof GiftCard) { - $card = $builder->paymentMethod; - $account->accountNumber = $card->number; - } - } - $transactionType = $this->mapTransactionType($builder->transactionType); - switch ($builder->paymentMethodType) { - case PaymentMethodType::CREDIT: - return $this->doCredit( - $transactionType, - $amount, - $account, - $trace, - new AvsRequest(), - new CashierSubGroup(), - new CommercialRequest(), - new EcomSubGroup(), - $extData - ); - case PaymentMethodType::GIFT: - $messageId = ($builder->currency == CurrencyType::CURRENCY) ? - PaxMessageId::T06_DO_GIFT : PaxMessageId::T08_DO_LOYALTY; - return $this->doGift( - $messageId, - $transactionType, - $amount, - $account, - $trace, - new CashierSubGroup(), - $extData - ); - } - } - - public function processTransaction($builder) - { - - $requestId = (!empty($builder->requestId)) ? - $builder->requestId : - $this->requestIdProvider->getRequestId(); - - $amount = new AmountRequest(); - $account = new AccountRequest(); - $extData = new ExtDataSubGroup(); - $trace = new TraceRequest(); - $commercial = new CommercialRequest(); - $ecom = new EcomSubGroup(); - $cashier = new CashierSubGroup(); - $avs = new AvsRequest(); - - $amount->transactionAmount = TerminalUtils::formatAmount($builder->amount); - $amount->tipAmount = TerminalUtils::formatAmount($builder->gratuity); - $amount->cashBackAmount = TerminalUtils::formatAmount($builder->cashBackAmount); - $amount->taxAmount = TerminalUtils::formatAmount($builder->taxAmount); - - $trace->referenceNumber = $requestId; - $trace->invoiceNumber = $builder->invoiceNumber; - if (!empty($builder->clientTransactionId)) { - $trace->clientTransactionId = $builder->clientTransactionId; - } - - if ($builder->paymentMethod != null) { - if ($builder->paymentMethod instanceof CreditCardData) { - $card = $builder->paymentMethod; - if (empty($card->token)) { - $account->accountNumber = $card->number; - $account->expd = $card->getShortExpiry(); - if ($builder->transactionType != TransactionType::VERIFY && - $builder->transactionType != TransactionType::REFUND) { - $account->cvvCode = $card->cvn; - } - } else { - $extData->details[PaxExtData::TOKEN] = $card->token; - } - } elseif ($builder->paymentMethod instanceof TransactionReference) { - $reference = $builder->paymentMethod; - if (!empty($reference->authCode)) { - $trace->authCode = $reference->authCode; - } - if (!empty($reference->transactionId)) { - $extData->details[PaxExtData::HOST_REFERENCE_NUMBER] = $reference->transactionId; - } - } elseif ($builder->paymentMethod instanceof GiftCard) { - $card = $builder->paymentMethod; - $account->accountNumber = $card->number; - } - } - - if ($builder->allowDuplicates !== null) { - $account->dupOverrideFlag = 1; - } - - if ($builder->address !== null) { - $avs->address = $builder->address->streetAddress1; - $avs->zipCode = $builder->address->postalCode; - } - $commercial->customerCode = $builder->customerCode; - $commercial->poNumber = $builder->poNumber; - $commercial->taxExempt = $builder->taxExempt; - $commercial->taxExemptId = $builder->taxExemptId; - - if ($builder->requestMultiUseToken !== null) { - $extData->details[PaxExtData::TOKEN_REQUEST] = $builder->requestMultiUseToken; - } - - if ($builder->signatureCapture !== null) { - $extData->details[PaxExtData::SIGNATURE_CAPTURE] = $builder->signatureCapture; - } - - $transactionType = $this->mapTransactionType($builder->transactionType, $builder->requestMultiUseToken); - switch ($builder->paymentMethodType) { - case PaymentMethodType::CREDIT: - return $this->doCredit( - $transactionType, - $amount, - $account, - $trace, - $avs, - $cashier, - $commercial, - $ecom, - $extData - ); - case PaymentMethodType::DEBIT: - return $this->doDebit( - $transactionType, - $amount, - $account, - $trace, - $cashier, - $extData - ); - case PaymentMethodType::GIFT: - $messageId = ($builder->currency == CurrencyType::CURRENCY) ? - PaxMessageId::T06_DO_GIFT : PaxMessageId::T08_DO_LOYALTY; - return $this->doGift($messageId, $transactionType, $amount, $account, $trace, $cashier, $extData); - - case PaymentMethodType::EBT: - if (!empty($builder->currency)) { - $account->ebtType = substr($builder->currency, 0, 1); - } - return $this->doEBT($transactionType, $amount, $account, $trace, $cashier, $extData); - } - } - - private function mapTransactionType($type, $requestToken = null) - { - switch ($type) { - case TransactionType::ADD_VALUE: - return PaxTxnType::ADD; - case TransactionType::AUTH: - return PaxTxnType::AUTH; - case TransactionType::BALANCE: - return PaxTxnType::BALANCE; - case TransactionType::CAPTURE: - return PaxTxnType::POSTAUTH; - case TransactionType::REFUND: - return PaxTxnType::RETURN_REQUEST; - case TransactionType::SALE: - return PaxTxnType::SALE_REDEEM; - case TransactionType::VERIFY: - return $requestToken ? PaxTxnType::TOKENIZE : PaxTxnType::VERIFY; - case TransactionType::VOID: - return PaxTxnType::VOID; - case TransactionType::BENEFIT_WITHDRAWAL: - return PaxTxnType::WITHDRAWAL; - case TransactionType::REVERSAL: - return PaxTxnType::REVERSAL; - default: - throw new UnsupportedTransactionException( - 'The selected gateway does not support this transaction type.' - ); - } - } - - private function doCredit( - $transactionType, - $amounts, - $accounts, - $trace, - $avs, - $cashier, - $commercial, - $ecom, - $extData - ) { - - $commands = [ - PaxMessageId::T00_DO_CREDIT, - '1.35', - $transactionType, - $amounts->getElementString(), - $accounts->getElementString(), - $trace->getElementString(), - $avs->getElementString(), - $cashier->getElementString(), - $commercial->getElementString(), - $ecom->getElementString(), - $extData->getElementString(), - ]; - $response = $this->doTransaction($commands, PaxMessageId::T00_DO_CREDIT); - return new PaxCreditResponse($response); - } - - private function doTransaction($commands, $requestType = null) - { - $message = implode(chr(ControlCodes::FS), $commands); - $finalMessage = TerminalUtils::buildMessage($message); - return $this->send($finalMessage, $requestType); - } - - private function doDebit($transactionType, $amounts, $accounts, $trace, $cashier, $extData) - { - $commands = [ - PaxMessageId::T02_DO_DEBIT, - '1.35', - $transactionType, - $amounts->getElementString(), - $accounts->getElementString(), - $trace->getElementString(), - $cashier->getElementString(), - $extData->getElementString(), - ]; - $response = $this->doTransaction($commands, PaxMessageId::T02_DO_DEBIT); - return new PaxDebitResponse($response); - } - - private function doGift($messageId, $transactionType, $amounts, $accounts, $trace, $cashier, $extData) - { - $commands = [ - $messageId, - '1.35', - $transactionType, - $amounts->getElementString(), - $accounts->getElementString(), - $trace->getElementString(), - $cashier->getElementString(), - $extData->getElementString(), - ]; - $response = $this->doTransaction($commands, $messageId); - return new PaxGiftResponse($response); - } - - public function processReport($builder) - { - $response = $this->buildReportTransaction($builder); - return new PaxLocalReportResponse($response); - } - - public function buildReportTransaction($builder) - { - $messageId = $this->mapReportType($builder->reportType); - - switch ($builder->reportType) { - case TerminalReportType::LOCAL_DETAIL_REPORT: - $criteria = $builder->searchBuilder; - $extData = new ExtDataSubGroup(); - if (!empty($criteria->MerchantId)) { - $extData->details[PaxExtData::MERCHANT_ID] = $criteria->MerchantId; - } - - if (!empty($criteria->MerchantName)) { - $extData->details[PaxExtData::MERCHANT_NAME] = $criteria->MerchantName; - } - - $commands = [ - $messageId, - '1.35', - '00', - (isset($criteria->TransactionType)) ? $criteria->TransactionType : '', - (isset($criteria->CardType)) ? $criteria->CardType : '', - (isset($criteria->RecordNumber)) ? $criteria->RecordNumber : '', - (isset($criteria->TerminalReferenceNumber)) ? $criteria->TerminalReferenceNumber : '', - (isset($criteria->AuthCode)) ? $criteria->AuthCode : '', - (isset($criteria->ReferenceNumber)) ? $criteria->ReferenceNumber : '', - $extData->getElementString(), - ]; - return $this->doTransaction($commands, $messageId); - default: - throw new UnsupportedTransactionException( - 'The selected gateway does not support this transaction type.' - ); - } - } - - private function mapReportType($type) - { - switch ($type) { - case TerminalReportType::LOCAL_DETAIL_REPORT: - return PaxMessageId::R02_LOCAL_DETAIL_REPORT; - default: - throw new UnsupportedTransactionException( - 'The selected gateway does not support this transaction type.' - ); - } - } - private function doEBT($transactionType, $amounts, $accounts, $trace, $cashier, $extData) - { - $commands = [ - PaxMessageId::T04_DO_EBT, - '1.35', - $transactionType, - $amounts->getElementString(), - $accounts->getElementString(), - $trace->getElementString(), - $cashier->getElementString(), - $extData->getElementString(), - ]; - $response = $this->doTransaction($commands); - return new PaxEBTResponse($response); - } -} +device = new PaxInterface($this); + $this->requestIdProvider = $config->requestIdProvider; + $this->deviceConfig = $config; + + switch ($config->connectionMode) { + case ConnectionModes::TCP_IP: + case ConnectionModes::SSL_TCP: + $this->deviceInterface = new PaxTcpInterface($config); + break; + case ConnectionModes::HTTP: + case ConnectionModes::HTTPS: + $this->deviceInterface = new PaxHttpInterface($config); + break; + } + } + + /* + * Send control message to device + * + * @param string $message control message to device + * + * @return PaxResponse parsed device response + */ + + public function send($message, $requestType = null) + { + //send message to gateway + return $this->deviceInterface->send(trim($message), $requestType); + } + + public function manageTransaction($builder) + { + $requestId = (!empty($builder->requestId)) ? + $builder->requestId : + $this->requestIdProvider->getRequestId(); + + $amount = new AmountRequest(); + $account = new AccountRequest(); + $extData = new ExtDataSubGroup(); + $trace = new TraceRequest(); + $trace->referenceNumber = $requestId; + + $amount->transactionAmount = TerminalUtils::formatAmount($builder->amount); + + if ($builder->paymentMethod != null) { + if ($builder->paymentMethod instanceof TransactionReference) { + $transactionReference = $builder->paymentMethod; + if (!empty($transactionReference->transactionId)) { + $extData->details[PaxExtData::HOST_REFERENCE_NUMBER] = + $transactionReference->transactionId; + } + } elseif ($builder->paymentMethod instanceof GiftCard) { + $card = $builder->paymentMethod; + $account->accountNumber = $card->number; + } + } + $transactionType = $this->mapTransactionType($builder->transactionType); + switch ($builder->paymentMethodType) { + case PaymentMethodType::CREDIT: + return $this->doCredit( + $transactionType, + $amount, + $account, + $trace, + new AvsRequest(), + new CashierSubGroup(), + new CommercialRequest(), + new EcomSubGroup(), + $extData + ); + case PaymentMethodType::GIFT: + $messageId = ($builder->currency == CurrencyType::CURRENCY) ? + PaxMessageId::T06_DO_GIFT : PaxMessageId::T08_DO_LOYALTY; + return $this->doGift( + $messageId, + $transactionType, + $amount, + $account, + $trace, + new CashierSubGroup(), + $extData + ); + } + } + + public function processTransaction($builder) + { + + $requestId = (!empty($builder->requestId)) ? + $builder->requestId : + $this->requestIdProvider->getRequestId(); + + $amount = new AmountRequest(); + $account = new AccountRequest(); + $extData = new ExtDataSubGroup(); + $trace = new TraceRequest(); + $commercial = new CommercialRequest(); + $ecom = new EcomSubGroup(); + $cashier = new CashierSubGroup(); + $avs = new AvsRequest(); + + $amount->transactionAmount = TerminalUtils::formatAmount($builder->amount); + $amount->tipAmount = TerminalUtils::formatAmount($builder->gratuity); + $amount->cashBackAmount = TerminalUtils::formatAmount($builder->cashBackAmount); + $amount->taxAmount = TerminalUtils::formatAmount($builder->taxAmount); + + $trace->referenceNumber = $requestId; + $trace->invoiceNumber = $builder->invoiceNumber; + if (!empty($builder->clientTransactionId)) { + $trace->clientTransactionId = $builder->clientTransactionId; + } + + if ($builder->paymentMethod != null) { + if ($builder->paymentMethod instanceof CreditCardData) { + $card = $builder->paymentMethod; + if (empty($card->token)) { + $account->accountNumber = $card->number; + $account->expd = $card->getShortExpiry(); + if ($builder->transactionType != TransactionType::VERIFY && + $builder->transactionType != TransactionType::REFUND) { + $account->cvvCode = $card->cvn; + } + } else { + $extData->details[PaxExtData::TOKEN] = $card->token; + } + } elseif ($builder->paymentMethod instanceof TransactionReference) { + $reference = $builder->paymentMethod; + if (!empty($reference->authCode)) { + $trace->authCode = $reference->authCode; + } + if (!empty($reference->transactionId)) { + $extData->details[PaxExtData::HOST_REFERENCE_NUMBER] = $reference->transactionId; + } + } elseif ($builder->paymentMethod instanceof GiftCard) { + $card = $builder->paymentMethod; + $account->accountNumber = $card->number; + } + } + + if ($builder->allowDuplicates !== null) { + $account->dupOverrideFlag = 1; + } + + if ($builder->address !== null) { + $avs->address = $builder->address->streetAddress1; + $avs->zipCode = $builder->address->postalCode; + } + $commercial->customerCode = $builder->customerCode; + $commercial->poNumber = $builder->poNumber; + $commercial->taxExempt = $builder->taxExempt; + $commercial->taxExemptId = $builder->taxExemptId; + + if ($builder->requestMultiUseToken !== null) { + $extData->details[PaxExtData::TOKEN_REQUEST] = $builder->requestMultiUseToken; + } + + if ($builder->signatureCapture !== null) { + $extData->details[PaxExtData::SIGNATURE_CAPTURE] = $builder->signatureCapture; + } + + $transactionType = $this->mapTransactionType($builder->transactionType, $builder->requestMultiUseToken); + switch ($builder->paymentMethodType) { + case PaymentMethodType::CREDIT: + return $this->doCredit( + $transactionType, + $amount, + $account, + $trace, + $avs, + $cashier, + $commercial, + $ecom, + $extData + ); + case PaymentMethodType::DEBIT: + return $this->doDebit( + $transactionType, + $amount, + $account, + $trace, + $cashier, + $extData + ); + case PaymentMethodType::GIFT: + $messageId = ($builder->currency == CurrencyType::CURRENCY) ? + PaxMessageId::T06_DO_GIFT : PaxMessageId::T08_DO_LOYALTY; + return $this->doGift($messageId, $transactionType, $amount, $account, $trace, $cashier, $extData); + + case PaymentMethodType::EBT: + if (!empty($builder->currency)) { + $account->ebtType = substr($builder->currency, 0, 1); + } + return $this->doEBT($transactionType, $amount, $account, $trace, $cashier, $extData); + } + } + + private function mapTransactionType($type, $requestToken = null) + { + switch ($type) { + case TransactionType::ADD_VALUE: + return PaxTxnType::ADD; + case TransactionType::AUTH: + return PaxTxnType::AUTH; + case TransactionType::BALANCE: + return PaxTxnType::BALANCE; + case TransactionType::CAPTURE: + return PaxTxnType::POSTAUTH; + case TransactionType::REFUND: + return PaxTxnType::RETURN_REQUEST; + case TransactionType::SALE: + return PaxTxnType::SALE_REDEEM; + case TransactionType::VERIFY: + return $requestToken ? PaxTxnType::TOKENIZE : PaxTxnType::VERIFY; + case TransactionType::VOID: + return PaxTxnType::VOID; + case TransactionType::BENEFIT_WITHDRAWAL: + return PaxTxnType::WITHDRAWAL; + case TransactionType::REVERSAL: + return PaxTxnType::REVERSAL; + default: + throw new UnsupportedTransactionException( + 'The selected gateway does not support this transaction type.' + ); + } + } + + private function doCredit( + $transactionType, + $amounts, + $accounts, + $trace, + $avs, + $cashier, + $commercial, + $ecom, + $extData + ) { + + $commands = [ + PaxMessageId::T00_DO_CREDIT, + '1.35', + $transactionType, + $amounts->getElementString(), + $accounts->getElementString(), + $trace->getElementString(), + $avs->getElementString(), + $cashier->getElementString(), + $commercial->getElementString(), + $ecom->getElementString(), + $extData->getElementString(), + ]; + $response = $this->doTransaction($commands, PaxMessageId::T00_DO_CREDIT); + return new PaxCreditResponse($response); + } + + private function doTransaction($commands, $requestType = null) + { + $message = implode(chr(ControlCodes::FS), $commands); + $finalMessage = TerminalUtils::buildMessage($message); + return $this->send($finalMessage, $requestType); + } + + private function doDebit($transactionType, $amounts, $accounts, $trace, $cashier, $extData) + { + $commands = [ + PaxMessageId::T02_DO_DEBIT, + '1.35', + $transactionType, + $amounts->getElementString(), + $accounts->getElementString(), + $trace->getElementString(), + $cashier->getElementString(), + $extData->getElementString(), + ]; + $response = $this->doTransaction($commands, PaxMessageId::T02_DO_DEBIT); + return new PaxDebitResponse($response); + } + + private function doGift($messageId, $transactionType, $amounts, $accounts, $trace, $cashier, $extData) + { + $commands = [ + $messageId, + '1.35', + $transactionType, + $amounts->getElementString(), + $accounts->getElementString(), + $trace->getElementString(), + $cashier->getElementString(), + $extData->getElementString(), + ]; + $response = $this->doTransaction($commands, $messageId); + return new PaxGiftResponse($response); + } + + public function processReport($builder) + { + $response = $this->buildReportTransaction($builder); + return new PaxLocalReportResponse($response); + } + + public function buildReportTransaction($builder) + { + $messageId = $this->mapReportType($builder->reportType); + + switch ($builder->reportType) { + case TerminalReportType::LOCAL_DETAIL_REPORT: + $criteria = $builder->searchBuilder; + $extData = new ExtDataSubGroup(); + if (!empty($criteria->MerchantId)) { + $extData->details[PaxExtData::MERCHANT_ID] = $criteria->MerchantId; + } + + if (!empty($criteria->MerchantName)) { + $extData->details[PaxExtData::MERCHANT_NAME] = $criteria->MerchantName; + } + + $commands = [ + $messageId, + '1.35', + '00', + (isset($criteria->TransactionType)) ? $criteria->TransactionType : '', + (isset($criteria->CardType)) ? $criteria->CardType : '', + (isset($criteria->RecordNumber)) ? $criteria->RecordNumber : '', + (isset($criteria->TerminalReferenceNumber)) ? $criteria->TerminalReferenceNumber : '', + (isset($criteria->AuthCode)) ? $criteria->AuthCode : '', + (isset($criteria->ReferenceNumber)) ? $criteria->ReferenceNumber : '', + $extData->getElementString(), + ]; + return $this->doTransaction($commands, $messageId); + default: + throw new UnsupportedTransactionException( + 'The selected gateway does not support this transaction type.' + ); + } + } + + private function mapReportType($type) + { + switch ($type) { + case TerminalReportType::LOCAL_DETAIL_REPORT: + return PaxMessageId::R02_LOCAL_DETAIL_REPORT; + default: + throw new UnsupportedTransactionException( + 'The selected gateway does not support this transaction type.' + ); + } + } + private function doEBT($transactionType, $amounts, $accounts, $trace, $cashier, $extData) + { + $commands = [ + PaxMessageId::T04_DO_EBT, + '1.35', + $transactionType, + $amounts->getElementString(), + $accounts->getElementString(), + $trace->getElementString(), + $cashier->getElementString(), + $extData->getElementString(), + ]; + $response = $this->doTransaction($commands); + return new PaxEBTResponse($response); + } +} diff --git a/src/Terminals/PAX/PaxInterface.php b/src/Terminals/PAX/PaxInterface.php index 8d797f5a..e8755c39 100644 --- a/src/Terminals/PAX/PaxInterface.php +++ b/src/Terminals/PAX/PaxInterface.php @@ -1,319 +1,319 @@ -paxController = $deviceController; - } - - #region Admin Messages - - public function initialize() - { - $message = TerminalUtils::buildAdminMessage(PaxMessageId::A00_INITIALIZE); - $rawResponse = $this->paxController->send($message); - - return new InitializeResponse($rawResponse, PaxMessageId::A00_INITIALIZE); - } - - public function batchClose() - { - $message = TerminalUtils::buildAdminMessage(PaxMessageId::B00_BATCH_CLOSE, [date("YMDhms")]); - $rawResponse = $this->paxController->send($message); - - return new BatchResponse($rawResponse); - } - - public function cancel() - { - if ($this->paxController->deviceConfig->connectionMode === ConnectionModes::HTTP) { - throw new ApiException("The cancel command is not available in HTTP mode"); - } - try { - $message = TerminalUtils::buildAdminMessage(PaxMessageId::A14_CANCEL); - $this->paxController->send($message, PaxMessageId::A14_CANCEL); - } catch (\Exception $e) { - if ($e->getMessage() !== 'Device error: Terminal returned EOT for the current message') { - throw $e; - } - } - } - - public function closeLane() - { - throw new UnsupportedTransactionException(''); - } - - public function creditAuth($amount = null) - { - return (new TerminalAuthBuilder(TransactionType::AUTH, PaymentMethodType::CREDIT)) - ->withAmount($amount); - } - - public function creditCapture($amount = null) - { - return (new TerminalManageBuilder(TransactionType::CAPTURE, PaymentMethodType::CREDIT)) - ->withAmount($amount); - } - - public function creditRefund($amount = null) - { - return (new TerminalAuthBuilder(TransactionType::REFUND, PaymentMethodType::CREDIT)) - ->withAmount($amount); - } - - public function creditSale($amount = null) - { - return (new TerminalAuthBuilder(TransactionType::SALE, PaymentMethodType::CREDIT)) - ->withAmount($amount); - } - - public function creditVerify() - { - return (new TerminalAuthBuilder(TransactionType::VERIFY, PaymentMethodType::CREDIT)); - } - - public function creditVoid() - { - return (new TerminalManageBuilder(TransactionType::VOID, PaymentMethodType::CREDIT)); - } - - public function debitRefund($amount = null) - { - return (new TerminalAuthBuilder(TransactionType::REFUND, PaymentMethodType::DEBIT)) - ->withAmount($amount); - } - - public function debitSale($amount = null) - { - return (new TerminalAuthBuilder(TransactionType::SALE, PaymentMethodType::DEBIT)) - ->withAmount($amount); - } - - public function disableHostResponseBeep() - { - } - - public function ebtBalance() - { - return (new TerminalAuthBuilder(TransactionType::BALANCE, PaymentMethodType::EBT)); - } - - public function ebtPurchase($amount = null) - { - return (new TerminalAuthBuilder(TransactionType::SALE, PaymentMethodType::EBT)) - ->withAmount($amount); - } - - public function ebtRefund($amount = null) - { - return (new TerminalAuthBuilder(TransactionType::REFUND, PaymentMethodType::EBT)) - ->withAmount($amount); - } - - public function ebtWithdrawl($amount = null) - { - return (new TerminalAuthBuilder(TransactionType::BENEFIT_WITHDRAWAL, PaymentMethodType::EBT)) - ->withAmount($amount); - } - - public function eod() - { - return $this->batchClose(); - } - - public function getDiagnosticReport($totalFields) - { - throw new UnsupportedTransactionException(''); - } - - public function getLastResponse() - { - throw new UnsupportedTransactionException(''); - } - - public function promptForSignature($transactionId = null) - { - $message = TerminalUtils::buildAdminMessage( - PaxMessageId::A20_DO_SIGNATURE, - [ - (!empty($transactionId)) ? 1 : 0, - (!empty($transactionId)) ? $transactionId : '', - (!empty($transactionId)) ? '00' : '', - 300 - ] - ); - $rawResponse = $this->paxController->send($message); - - return new SignatureResponse($rawResponse, PaxMessageId::A21_RSP_DO_SIGNATURE); - } - - public function getSignatureFile() - { - if (!function_exists('imagecreate')) { - throw new ApiException("The gd2 extension needs to be enabled for this request. Please contact your admin"); - } - - $message = TerminalUtils::buildAdminMessage( - PaxMessageId::A08_GET_SIGNATURE, - [0] - ); - $rawResponse = $this->paxController->send($message); - - return new SignatureResponse( - $rawResponse, - PaxMessageId::A09_RSP_GET_SIGNATURE, - $this->paxController->deviceConfig->deviceType - ); - } - - public function giftAddValue($amount = null) - { - return (new TerminalAuthBuilder(TransactionType::ADD_VALUE, PaymentMethodType::GIFT)) - ->withCurrency(CurrencyType::CURRENCY) - ->withAmount($amount); - } - - public function giftBalance() - { - return (new TerminalAuthBuilder(TransactionType::BALANCE, PaymentMethodType::GIFT)) - ->withCurrency(CurrencyType::CURRENCY); - } - - public function giftSale($amount = null) - { - return (new TerminalAuthBuilder(TransactionType::SALE, PaymentMethodType::GIFT)) - ->withCurrency(CurrencyType::CURRENCY) - ->withAmount($amount); - } - - public function giftVoid() - { - return (new TerminalManageBuilder(TransactionType::VOID, PaymentMethodType::GIFT)) - ->withCurrency(CurrencyType::CURRENCY); - } - - public function lineItem($lineItemDetails) - { - throw new UnsupportedTransactionException(''); - } - - public function openLane() - { - throw new UnsupportedTransactionException(''); - } - - public function reboot() - { - $message = TerminalUtils::buildAdminMessage(PaxMessageId::A26_REBOOT); - $rawResponse = $this->paxController->send($message); - - return new PaxDeviceResponse($rawResponse, PaxMessageId::A26_REBOOT); - } - - public function reset() - { - $message = TerminalUtils::buildAdminMessage(PaxMessageId::A16_RESET); - $rawResponse = $this->paxController->send($message); - - return new PaxDeviceResponse($rawResponse, PaxMessageId::A16_RESET); - } - - public function sendFile($sendFileData) - { - throw new UnsupportedTransactionException(''); - } - - public function startCard($paymentMethodType = null) - { - throw new UnsupportedTransactionException(''); - } - - public function startDownload($deviceSettings) - { - throw new UnsupportedTransactionException(''); - } - - #region Reporting Messages - - public function localDetailReport() - { - return new TerminalReportBuilder(TerminalReportType::LOCAL_DETAIL_REPORT); - } - - #endregion - - #region Saf - public function sendSaf($safIndicator = null) - { - return $this->safUpload($safIndicator); - } - - public function setSafMode($paramValue) - { - $message = TerminalUtils::buildAdminMessage(PaxMessageId::A54_SET_SAF_PARAMETERS, [ - $paramValue, - '', '', '', '', '', '', '', '', '', '' - ]); - $rawResponse = $this->paxController->send($message); - return new PaxDeviceResponse($rawResponse, PaxMessageId::A54_SET_SAF_PARAMETERS); - } - - public function safUpload($safIndicator) - { - $message = TerminalUtils::buildAdminMessage(PaxMessageId::B08_SAF_UPLOAD, [$safIndicator]); - $rawResponse = $this->paxController->send($message); - return new SafUploadResponse($rawResponse); - } - - public function safDelete($safIndicator) - { - $message = TerminalUtils::buildAdminMessage(PaxMessageId::B10_DELETE_SAF_FILE, [$safIndicator]); - - $rawResponse = $this->paxController->send($message); - return new SafDeleteResponse($rawResponse); - } - - public function safSummaryReport($safIndicator) - { - $message = TerminalUtils::buildAdminMessage(PaxMessageId::R10_SAF_SUMMARY_REPORT, [$safIndicator]); - - $rawResponse = $this->paxController->send($message); - return new SafSummaryReport($rawResponse); - } - #endregion -} +paxController = $deviceController; + } + + #region Admin Messages + + public function initialize() + { + $message = TerminalUtils::buildAdminMessage(PaxMessageId::A00_INITIALIZE); + $rawResponse = $this->paxController->send($message); + + return new InitializeResponse($rawResponse, PaxMessageId::A00_INITIALIZE); + } + + public function batchClose() + { + $message = TerminalUtils::buildAdminMessage(PaxMessageId::B00_BATCH_CLOSE, [date("YMDhms")]); + $rawResponse = $this->paxController->send($message); + + return new BatchResponse($rawResponse); + } + + public function cancel() + { + if ($this->paxController->deviceConfig->connectionMode === ConnectionModes::HTTP) { + throw new ApiException("The cancel command is not available in HTTP mode"); + } + try { + $message = TerminalUtils::buildAdminMessage(PaxMessageId::A14_CANCEL); + $this->paxController->send($message, PaxMessageId::A14_CANCEL); + } catch (\Exception $e) { + if ($e->getMessage() !== 'Device error: Terminal returned EOT for the current message') { + throw $e; + } + } + } + + public function closeLane() + { + throw new UnsupportedTransactionException(''); + } + + public function creditAuth($amount = null) + { + return (new TerminalAuthBuilder(TransactionType::AUTH, PaymentMethodType::CREDIT)) + ->withAmount($amount); + } + + public function creditCapture($amount = null) + { + return (new TerminalManageBuilder(TransactionType::CAPTURE, PaymentMethodType::CREDIT)) + ->withAmount($amount); + } + + public function creditRefund($amount = null) + { + return (new TerminalAuthBuilder(TransactionType::REFUND, PaymentMethodType::CREDIT)) + ->withAmount($amount); + } + + public function creditSale($amount = null) + { + return (new TerminalAuthBuilder(TransactionType::SALE, PaymentMethodType::CREDIT)) + ->withAmount($amount); + } + + public function creditVerify() + { + return (new TerminalAuthBuilder(TransactionType::VERIFY, PaymentMethodType::CREDIT)); + } + + public function creditVoid() + { + return (new TerminalManageBuilder(TransactionType::VOID, PaymentMethodType::CREDIT)); + } + + public function debitRefund($amount = null) + { + return (new TerminalAuthBuilder(TransactionType::REFUND, PaymentMethodType::DEBIT)) + ->withAmount($amount); + } + + public function debitSale($amount = null) + { + return (new TerminalAuthBuilder(TransactionType::SALE, PaymentMethodType::DEBIT)) + ->withAmount($amount); + } + + public function disableHostResponseBeep() + { + } + + public function ebtBalance() + { + return (new TerminalAuthBuilder(TransactionType::BALANCE, PaymentMethodType::EBT)); + } + + public function ebtPurchase($amount = null) + { + return (new TerminalAuthBuilder(TransactionType::SALE, PaymentMethodType::EBT)) + ->withAmount($amount); + } + + public function ebtRefund($amount = null) + { + return (new TerminalAuthBuilder(TransactionType::REFUND, PaymentMethodType::EBT)) + ->withAmount($amount); + } + + public function ebtWithdrawl($amount = null) + { + return (new TerminalAuthBuilder(TransactionType::BENEFIT_WITHDRAWAL, PaymentMethodType::EBT)) + ->withAmount($amount); + } + + public function eod() + { + return $this->batchClose(); + } + + public function getDiagnosticReport($totalFields) + { + throw new UnsupportedTransactionException(''); + } + + public function getLastResponse() + { + throw new UnsupportedTransactionException(''); + } + + public function promptForSignature($transactionId = null) + { + $message = TerminalUtils::buildAdminMessage( + PaxMessageId::A20_DO_SIGNATURE, + [ + (!empty($transactionId)) ? 1 : 0, + (!empty($transactionId)) ? $transactionId : '', + (!empty($transactionId)) ? '00' : '', + 300 + ] + ); + $rawResponse = $this->paxController->send($message); + + return new SignatureResponse($rawResponse, PaxMessageId::A21_RSP_DO_SIGNATURE); + } + + public function getSignatureFile() + { + if (!function_exists('imagecreate')) { + throw new ApiException("The gd2 extension needs to be enabled for this request. Please contact your admin"); + } + + $message = TerminalUtils::buildAdminMessage( + PaxMessageId::A08_GET_SIGNATURE, + [0] + ); + $rawResponse = $this->paxController->send($message); + + return new SignatureResponse( + $rawResponse, + PaxMessageId::A09_RSP_GET_SIGNATURE, + $this->paxController->deviceConfig->deviceType + ); + } + + public function giftAddValue($amount = null) + { + return (new TerminalAuthBuilder(TransactionType::ADD_VALUE, PaymentMethodType::GIFT)) + ->withCurrency(CurrencyType::CURRENCY) + ->withAmount($amount); + } + + public function giftBalance() + { + return (new TerminalAuthBuilder(TransactionType::BALANCE, PaymentMethodType::GIFT)) + ->withCurrency(CurrencyType::CURRENCY); + } + + public function giftSale($amount = null) + { + return (new TerminalAuthBuilder(TransactionType::SALE, PaymentMethodType::GIFT)) + ->withCurrency(CurrencyType::CURRENCY) + ->withAmount($amount); + } + + public function giftVoid() + { + return (new TerminalManageBuilder(TransactionType::VOID, PaymentMethodType::GIFT)) + ->withCurrency(CurrencyType::CURRENCY); + } + + public function lineItem($lineItemDetails) + { + throw new UnsupportedTransactionException(''); + } + + public function openLane() + { + throw new UnsupportedTransactionException(''); + } + + public function reboot() + { + $message = TerminalUtils::buildAdminMessage(PaxMessageId::A26_REBOOT); + $rawResponse = $this->paxController->send($message); + + return new PaxDeviceResponse($rawResponse, PaxMessageId::A26_REBOOT); + } + + public function reset() + { + $message = TerminalUtils::buildAdminMessage(PaxMessageId::A16_RESET); + $rawResponse = $this->paxController->send($message); + + return new PaxDeviceResponse($rawResponse, PaxMessageId::A16_RESET); + } + + public function sendFile($sendFileData) + { + throw new UnsupportedTransactionException(''); + } + + public function startCard($paymentMethodType = null) + { + throw new UnsupportedTransactionException(''); + } + + public function startDownload($deviceSettings) + { + throw new UnsupportedTransactionException(''); + } + + #region Reporting Messages + + public function localDetailReport() + { + return new TerminalReportBuilder(TerminalReportType::LOCAL_DETAIL_REPORT); + } + + #endregion + + #region Saf + public function sendSaf($safIndicator = null) + { + return $this->safUpload($safIndicator); + } + + public function setSafMode($paramValue) + { + $message = TerminalUtils::buildAdminMessage(PaxMessageId::A54_SET_SAF_PARAMETERS, [ + $paramValue, + '', '', '', '', '', '', '', '', '', '' + ]); + $rawResponse = $this->paxController->send($message); + return new PaxDeviceResponse($rawResponse, PaxMessageId::A54_SET_SAF_PARAMETERS); + } + + public function safUpload($safIndicator) + { + $message = TerminalUtils::buildAdminMessage(PaxMessageId::B08_SAF_UPLOAD, [$safIndicator]); + $rawResponse = $this->paxController->send($message); + return new SafUploadResponse($rawResponse); + } + + public function safDelete($safIndicator) + { + $message = TerminalUtils::buildAdminMessage(PaxMessageId::B10_DELETE_SAF_FILE, [$safIndicator]); + + $rawResponse = $this->paxController->send($message); + return new SafDeleteResponse($rawResponse); + } + + public function safSummaryReport($safIndicator) + { + $message = TerminalUtils::buildAdminMessage(PaxMessageId::R10_SAF_SUMMARY_REPORT, [$safIndicator]); + + $rawResponse = $this->paxController->send($message); + return new SafSummaryReport($rawResponse); + } + #endregion +} diff --git a/src/Terminals/PAX/Responses/BatchResponse.php b/src/Terminals/PAX/Responses/BatchResponse.php index 8285525f..c2af0e16 100644 --- a/src/Terminals/PAX/Responses/BatchResponse.php +++ b/src/Terminals/PAX/Responses/BatchResponse.php @@ -1,41 +1,41 @@ -totalCount = $messageReader->readToCode(ControlCodes::FS); - $this->totalAmount = $messageReader->readToCode(ControlCodes::FS); - $this->timeStamp = $messageReader->readToCode(ControlCodes::FS); - $this->tid = $messageReader->readToCode(ControlCodes::FS); - $this->mid = $messageReader->readToCode(ControlCodes::FS); - - if (!empty($hostResponse->batchNumber)) { - $this->batchNumber = $hostResponse->batchNumber; - } - } -} +totalCount = $messageReader->readToCode(ControlCodes::FS); + $this->totalAmount = $messageReader->readToCode(ControlCodes::FS); + $this->timeStamp = $messageReader->readToCode(ControlCodes::FS); + $this->tid = $messageReader->readToCode(ControlCodes::FS); + $this->mid = $messageReader->readToCode(ControlCodes::FS); + + if (!empty($hostResponse->batchNumber)) { + $this->batchNumber = $hostResponse->batchNumber; + } + } +} diff --git a/src/Terminals/PAX/Responses/InitializeResponse.php b/src/Terminals/PAX/Responses/InitializeResponse.php index 2a0fe619..e6da489c 100644 --- a/src/Terminals/PAX/Responses/InitializeResponse.php +++ b/src/Terminals/PAX/Responses/InitializeResponse.php @@ -1,30 +1,30 @@ -serialNumber = $messageReader->readToCode(ControlCodes::FS); - $this->modelName = $messageReader->readToCode(ControlCodes::FS); - $this->osVersion = $messageReader->readToCode(ControlCodes::FS); - } -} +serialNumber = $messageReader->readToCode(ControlCodes::FS); + $this->modelName = $messageReader->readToCode(ControlCodes::FS); + $this->osVersion = $messageReader->readToCode(ControlCodes::FS); + } +} diff --git a/src/Terminals/PAX/Responses/PaxBaseResponse.php b/src/Terminals/PAX/Responses/PaxBaseResponse.php index c90f52c9..4b9418a9 100644 --- a/src/Terminals/PAX/Responses/PaxBaseResponse.php +++ b/src/Terminals/PAX/Responses/PaxBaseResponse.php @@ -1,65 +1,65 @@ -messageId = $messageId; - $this->parseResponse(new MessageReader($rawResponse)); - } - - public function parseResponse($messageReader) - { - $code = $messageReader->readCode(); - $this->status = $messageReader->readToCode(ControlCodes::FS); - $this->command = $messageReader->readToCode(ControlCodes::FS); - $this->versionNumber = $messageReader->readToCode(ControlCodes::FS); - $this->deviceResponseCode = $messageReader->readToCode(ControlCodes::FS); - $this->deviceResponseText = $messageReader->readToCode(ControlCodes::FS); - $this->checkResponse(); - } - - /* - * Check the device response code - * - * @param PaxResponse $gatewayResponse parsed response from device - * @param array $acceptedCodes list of success response codes - * - * @return raise GatewayException incase of different unexpected code - */ - - public function checkResponse($acceptedCodes = null) - { - if ($acceptedCodes === null) { - $acceptedCodes = ["000000"]; - } - - if (!empty($this->deviceResponseText)) { - $responseCode = (string) $this->deviceResponseCode; - $responseMessage = (string) $this->deviceResponseText; - - if (!in_array($responseCode, $acceptedCodes)) { - throw new GatewayException( - sprintf( - 'Unexpected Gateway Response: %s - %s', - $responseCode, - $responseMessage - ), - $responseCode, - $responseMessage - ); - } - } else { - throw new GatewayException('Invalid Gateway Response'); - } - } -} +messageId = $messageId; + $this->parseResponse(new MessageReader($rawResponse)); + } + + public function parseResponse($messageReader) + { + $code = $messageReader->readCode(); + $this->status = $messageReader->readToCode(ControlCodes::FS); + $this->command = $messageReader->readToCode(ControlCodes::FS); + $this->versionNumber = $messageReader->readToCode(ControlCodes::FS); + $this->deviceResponseCode = $messageReader->readToCode(ControlCodes::FS); + $this->deviceResponseText = $messageReader->readToCode(ControlCodes::FS); + $this->checkResponse(); + } + + /* + * Check the device response code + * + * @param PaxResponse $gatewayResponse parsed response from device + * @param array $acceptedCodes list of success response codes + * + * @return raise GatewayException incase of different unexpected code + */ + + public function checkResponse($acceptedCodes = null) + { + if ($acceptedCodes === null) { + $acceptedCodes = ["000000"]; + } + + if (!empty($this->deviceResponseText)) { + $responseCode = (string) $this->deviceResponseCode; + $responseMessage = (string) $this->deviceResponseText; + + if (!in_array($responseCode, $acceptedCodes)) { + throw new GatewayException( + sprintf( + 'Unexpected Gateway Response: %s - %s', + $responseCode, + $responseMessage + ), + $responseCode, + $responseMessage + ); + } + } else { + throw new GatewayException('Invalid Gateway Response'); + } + } +} diff --git a/src/Terminals/PAX/Responses/PaxCreditResponse.php b/src/Terminals/PAX/Responses/PaxCreditResponse.php index accb7398..95f8a0b4 100644 --- a/src/Terminals/PAX/Responses/PaxCreditResponse.php +++ b/src/Terminals/PAX/Responses/PaxCreditResponse.php @@ -1,21 +1,21 @@ -mapResponse($messageReader); - } -} +mapResponse($messageReader); + } +} diff --git a/src/Terminals/PAX/Responses/PaxDebitResponse.php b/src/Terminals/PAX/Responses/PaxDebitResponse.php index 06b1b2cb..b1ab6ff7 100644 --- a/src/Terminals/PAX/Responses/PaxDebitResponse.php +++ b/src/Terminals/PAX/Responses/PaxDebitResponse.php @@ -1,21 +1,21 @@ -mapResponse($messageReader); - } -} +mapResponse($messageReader); + } +} diff --git a/src/Terminals/PAX/Responses/PaxDeviceResponse.php b/src/Terminals/PAX/Responses/PaxDeviceResponse.php index a6e476d0..6c58cfdb 100644 --- a/src/Terminals/PAX/Responses/PaxDeviceResponse.php +++ b/src/Terminals/PAX/Responses/PaxDeviceResponse.php @@ -1,290 +1,290 @@ -mapTransactionType($messageReader->readToCode(ControlCodes::FS)); - $amountResponse = new AmountResponse($messageReader); - $accountResponse = new AccountResponse($messageReader); - $traceResponse = new TraceResponse($messageReader); - - if ($this->messageId === PaxMessageId::T01_RSP_DO_CREDIT) { - $avsResponse = new AvsResponse($messageReader); - $commercialResponse = new CommercialResponse($messageReader); - $ecomResponse = new EcomSubGroupResponse($messageReader); - $extDataResponse = new ExtDataSubGroupResponse($messageReader); - - $this->mapAvsResponse($avsResponse); - $this->mapCommercialResponse($commercialResponse); - } else { - $extDataResponse = new ExtDataSubGroupResponse($messageReader); - } - $this->mapHostResponse($hostResponse); - $this->mapAmountResponse($amountResponse); - $this->mapAccountResponse($accountResponse); - $this->mapTraceResponse($traceResponse); - $this->mapExtDataResponse($extDataResponse); - } - - public function mapLocalReportResponse($messageReader = null) - { - $this->totalReportRecords = $messageReader->readToCode(ControlCodes::FS); - $this->reportRecordNumber = $messageReader->readToCode(ControlCodes::FS); - $hostResponse = new HostResponse($messageReader); - $this->edcType = $messageReader->readToCode(ControlCodes::FS); - $this->mapTransactionType($messageReader->readToCode(ControlCodes::FS)); - $this->originalTransactionType = $messageReader->readToCode(ControlCodes::FS); - - $amountResponse = new AmountResponse($messageReader); - $accountResponse = new AccountResponse($messageReader); - $traceResponse = new TraceResponse($messageReader); - $cashierResponse = new CashierResponse($messageReader); - $commercialResponse = new CommercialResponse($messageReader); - $checkResponse = new CheckResponse($messageReader); - $extDataResponse = new ExtDataSubGroupResponse($messageReader); - - $this->mapHostResponse($hostResponse); - $this->mapAmountResponse($amountResponse); - $this->mapAccountResponse($accountResponse); - $this->mapTraceResponse($traceResponse); - $this->mapCashierResponse($cashierResponse); - $this->mapCommercialResponse($commercialResponse); - $this->mapCheckResponse($checkResponse); - $this->mapExtDataResponse($extDataResponse); - } - - private function mapAmountResponse($amountResponse) - { - if (!empty($amountResponse)) { - $this->transactionAmount = $amountResponse->approvedAmount; - $this->amountDue = $amountResponse->amountDue; - $this->tipAmount = $amountResponse->tipAmount; - $this->cashBackAmount = $amountResponse->cashBackAmount; - $this->balanceAmount = $amountResponse->balance1; - $this->merchantFee = $amountResponse->merchantFee; - } - } - - private function mapHostResponse($hostResponse) - { - if (!empty($hostResponse)) { - $this->responseCode = $hostResponse->hostResponseCode; - $this->responseText = $hostResponse->hostResponseMessage; - $this->approvalCode = $hostResponse->authCode; - $this->hostReferenceNumber = $hostResponse->hostReferenceNumber; - $this->authorizationCode = $hostResponse->authCode; - } - } - - private function mapExtDataResponse($extDataResponse) - { - if (!empty($extDataResponse)) { - $this->transactionId = $extDataResponse->getExtValue(PaxExtData::HOST_REFERENCE_NUMBER); - $this->token = $extDataResponse->getExtValue(PaxExtData::TOKEN); - $this->cardBIN = $extDataResponse->getExtValue(PaxExtData::CARD_BIN); - $this->signatureStatus = $extDataResponse->getExtValue(PaxExtData::SIGNATURE_STATUS); - - $this->applicationPreferredName = $extDataResponse->getExtValue(PaxExtData::APPLICATION_PREFERRED_NAME); - $this->applicationLabel = $extDataResponse->getExtValue(PaxExtData::APPLICATION_LABEL); - $this->applicationId = $extDataResponse->getExtValue(PaxExtData::APPLICATION_ID); - $this->applicationCryptogramType = 'TC'; - $this->applicationCryptogram = $extDataResponse->getExtValue(PaxExtData::TRANSACTION_CERTIFICATE); - $this->customerVerificationMethod = $extDataResponse->getExtValue(PaxExtData::CUSTOMER_VERIFICATION_METHOD); - $this->terminalVerificationResults = $extDataResponse->getExtValue( - PaxExtData::TERMINAL_VERIFICATION_RESULTS - ); - } - } - - private function mapAccountResponse($accountResponse) - { - if (!empty($accountResponse)) { - $this->maskedCardNumber = $accountResponse->accountNumber; - $this->entryMethod = $accountResponse->entryMode; - $this->expirationDate = $accountResponse->expireDate; - $this->paymentType = $accountResponse->cardType; - $this->cardHolderName = $accountResponse->cardHolder; - $this->cvvResponseCode = $accountResponse->cvdApprovalCode; - $this->cvvResponseText = $accountResponse->cvdMessage; - $this->cardPresent = $accountResponse->cardPresent; - $this->ebtType = $accountResponse->ebtType; - } - } - - private function mapTraceResponse($traceResponse) - { - if (!empty($traceResponse)) { - $this->transactionNumber = $traceResponse->transactionNumber; - $this->referenceNumber = $traceResponse->referenceNumber; - } - } - - private function mapAvsResponse($avsResponse) - { - if (!empty($avsResponse)) { - $this->avsResponseCode = $avsResponse->avsResponseCode; - $this->avsResponseText = $avsResponse->avsResponseMessage; - } - } - - private function mapCommercialResponse($commercialResponse) - { - if (!empty($commercialResponse)) { - $this->purchaseOrder = $commercialResponse->poNumber; - $this->customerCode = $commercialResponse->customerCode; - $this->taxExempt = $commercialResponse->taxExempt; - $this->taxExemptId = $commercialResponse->taxExemptId; - } - } - - private function mapCashierResponse($cashierResponse) - { - if (!empty($cashierResponse)) { - $this->clerkId = $cashierResponse->clerkId; - $this->shiftId = $cashierResponse->shiftId; - } - } - - private function mapCheckResponse($checkResponse) - { - if (!empty($checkResponse)) { - $this->saleType = $checkResponse->saleType; - $this->routingNumber = $checkResponse->routingNumber; - $this->accountNumber = $checkResponse->accountNumber; - $this->checkNumber = $checkResponse->checkNumber; - $this->checkType = $checkResponse->checkType; - $this->idType = $checkResponse->idType; - $this->idValue = $checkResponse->idValue; - $this->DOB = $checkResponse->DOB; - $this->phoneNumber = $checkResponse->phoneNumber; - $this->zipCode = $checkResponse->zipCode; - } - } - - private function mapTransactionType($transactionType) - { - $transactionTypeValue = EnumUtils::parse(new TerminalTransactionType(), $transactionType); - $this->transactionType = str_replace('_', ' ', $transactionTypeValue); - } -} +mapTransactionType($messageReader->readToCode(ControlCodes::FS)); + $amountResponse = new AmountResponse($messageReader); + $accountResponse = new AccountResponse($messageReader); + $traceResponse = new TraceResponse($messageReader); + + if ($this->messageId === PaxMessageId::T01_RSP_DO_CREDIT) { + $avsResponse = new AvsResponse($messageReader); + $commercialResponse = new CommercialResponse($messageReader); + $ecomResponse = new EcomSubGroupResponse($messageReader); + $extDataResponse = new ExtDataSubGroupResponse($messageReader); + + $this->mapAvsResponse($avsResponse); + $this->mapCommercialResponse($commercialResponse); + } else { + $extDataResponse = new ExtDataSubGroupResponse($messageReader); + } + $this->mapHostResponse($hostResponse); + $this->mapAmountResponse($amountResponse); + $this->mapAccountResponse($accountResponse); + $this->mapTraceResponse($traceResponse); + $this->mapExtDataResponse($extDataResponse); + } + + public function mapLocalReportResponse($messageReader = null) + { + $this->totalReportRecords = $messageReader->readToCode(ControlCodes::FS); + $this->reportRecordNumber = $messageReader->readToCode(ControlCodes::FS); + $hostResponse = new HostResponse($messageReader); + $this->edcType = $messageReader->readToCode(ControlCodes::FS); + $this->mapTransactionType($messageReader->readToCode(ControlCodes::FS)); + $this->originalTransactionType = $messageReader->readToCode(ControlCodes::FS); + + $amountResponse = new AmountResponse($messageReader); + $accountResponse = new AccountResponse($messageReader); + $traceResponse = new TraceResponse($messageReader); + $cashierResponse = new CashierResponse($messageReader); + $commercialResponse = new CommercialResponse($messageReader); + $checkResponse = new CheckResponse($messageReader); + $extDataResponse = new ExtDataSubGroupResponse($messageReader); + + $this->mapHostResponse($hostResponse); + $this->mapAmountResponse($amountResponse); + $this->mapAccountResponse($accountResponse); + $this->mapTraceResponse($traceResponse); + $this->mapCashierResponse($cashierResponse); + $this->mapCommercialResponse($commercialResponse); + $this->mapCheckResponse($checkResponse); + $this->mapExtDataResponse($extDataResponse); + } + + private function mapAmountResponse($amountResponse) + { + if (!empty($amountResponse)) { + $this->transactionAmount = $amountResponse->approvedAmount; + $this->amountDue = $amountResponse->amountDue; + $this->tipAmount = $amountResponse->tipAmount; + $this->cashBackAmount = $amountResponse->cashBackAmount; + $this->balanceAmount = $amountResponse->balance1; + $this->merchantFee = $amountResponse->merchantFee; + } + } + + private function mapHostResponse($hostResponse) + { + if (!empty($hostResponse)) { + $this->responseCode = $hostResponse->hostResponseCode; + $this->responseText = $hostResponse->hostResponseMessage; + $this->approvalCode = $hostResponse->authCode; + $this->hostReferenceNumber = $hostResponse->hostReferenceNumber; + $this->authorizationCode = $hostResponse->authCode; + } + } + + private function mapExtDataResponse($extDataResponse) + { + if (!empty($extDataResponse)) { + $this->transactionId = $extDataResponse->getExtValue(PaxExtData::HOST_REFERENCE_NUMBER); + $this->token = $extDataResponse->getExtValue(PaxExtData::TOKEN); + $this->cardBIN = $extDataResponse->getExtValue(PaxExtData::CARD_BIN); + $this->signatureStatus = $extDataResponse->getExtValue(PaxExtData::SIGNATURE_STATUS); + + $this->applicationPreferredName = $extDataResponse->getExtValue(PaxExtData::APPLICATION_PREFERRED_NAME); + $this->applicationLabel = $extDataResponse->getExtValue(PaxExtData::APPLICATION_LABEL); + $this->applicationId = $extDataResponse->getExtValue(PaxExtData::APPLICATION_ID); + $this->applicationCryptogramType = 'TC'; + $this->applicationCryptogram = $extDataResponse->getExtValue(PaxExtData::TRANSACTION_CERTIFICATE); + $this->customerVerificationMethod = $extDataResponse->getExtValue(PaxExtData::CUSTOMER_VERIFICATION_METHOD); + $this->terminalVerificationResults = $extDataResponse->getExtValue( + PaxExtData::TERMINAL_VERIFICATION_RESULTS + ); + } + } + + private function mapAccountResponse($accountResponse) + { + if (!empty($accountResponse)) { + $this->maskedCardNumber = $accountResponse->accountNumber; + $this->entryMethod = $accountResponse->entryMode; + $this->expirationDate = $accountResponse->expireDate; + $this->paymentType = $accountResponse->cardType; + $this->cardHolderName = $accountResponse->cardHolder; + $this->cvvResponseCode = $accountResponse->cvdApprovalCode; + $this->cvvResponseText = $accountResponse->cvdMessage; + $this->cardPresent = $accountResponse->cardPresent; + $this->ebtType = $accountResponse->ebtType; + } + } + + private function mapTraceResponse($traceResponse) + { + if (!empty($traceResponse)) { + $this->transactionNumber = $traceResponse->transactionNumber; + $this->referenceNumber = $traceResponse->referenceNumber; + } + } + + private function mapAvsResponse($avsResponse) + { + if (!empty($avsResponse)) { + $this->avsResponseCode = $avsResponse->avsResponseCode; + $this->avsResponseText = $avsResponse->avsResponseMessage; + } + } + + private function mapCommercialResponse($commercialResponse) + { + if (!empty($commercialResponse)) { + $this->purchaseOrder = $commercialResponse->poNumber; + $this->customerCode = $commercialResponse->customerCode; + $this->taxExempt = $commercialResponse->taxExempt; + $this->taxExemptId = $commercialResponse->taxExemptId; + } + } + + private function mapCashierResponse($cashierResponse) + { + if (!empty($cashierResponse)) { + $this->clerkId = $cashierResponse->clerkId; + $this->shiftId = $cashierResponse->shiftId; + } + } + + private function mapCheckResponse($checkResponse) + { + if (!empty($checkResponse)) { + $this->saleType = $checkResponse->saleType; + $this->routingNumber = $checkResponse->routingNumber; + $this->accountNumber = $checkResponse->accountNumber; + $this->checkNumber = $checkResponse->checkNumber; + $this->checkType = $checkResponse->checkType; + $this->idType = $checkResponse->idType; + $this->idValue = $checkResponse->idValue; + $this->DOB = $checkResponse->DOB; + $this->phoneNumber = $checkResponse->phoneNumber; + $this->zipCode = $checkResponse->zipCode; + } + } + + private function mapTransactionType($transactionType) + { + $transactionTypeValue = EnumUtils::parse(new TerminalTransactionType(), $transactionType); + $this->transactionType = str_replace('_', ' ', $transactionTypeValue); + } +} diff --git a/src/Terminals/PAX/Responses/PaxEBTResponse.php b/src/Terminals/PAX/Responses/PaxEBTResponse.php index 5ff92bcc..99e2f726 100644 --- a/src/Terminals/PAX/Responses/PaxEBTResponse.php +++ b/src/Terminals/PAX/Responses/PaxEBTResponse.php @@ -1,21 +1,21 @@ -mapResponse($messageReader); - } -} +mapResponse($messageReader); + } +} diff --git a/src/Terminals/PAX/Responses/PaxGiftResponse.php b/src/Terminals/PAX/Responses/PaxGiftResponse.php index c3dd5525..e459ab4f 100644 --- a/src/Terminals/PAX/Responses/PaxGiftResponse.php +++ b/src/Terminals/PAX/Responses/PaxGiftResponse.php @@ -1,22 +1,22 @@ -mapResponse($messageReader); - } -} +mapResponse($messageReader); + } +} diff --git a/src/Terminals/PAX/Responses/PaxLocalReportResponse.php b/src/Terminals/PAX/Responses/PaxLocalReportResponse.php index 0ce2f21e..037912a8 100644 --- a/src/Terminals/PAX/Responses/PaxLocalReportResponse.php +++ b/src/Terminals/PAX/Responses/PaxLocalReportResponse.php @@ -1,26 +1,26 @@ -mapLocalReportResponse($messageReader); - } -} +mapLocalReportResponse($messageReader); + } +} diff --git a/src/Terminals/PAX/Responses/SafDeleteResponse.php b/src/Terminals/PAX/Responses/SafDeleteResponse.php index f4c0c5fc..fbbd35ae 100644 --- a/src/Terminals/PAX/Responses/SafDeleteResponse.php +++ b/src/Terminals/PAX/Responses/SafDeleteResponse.php @@ -1,26 +1,26 @@ -deviceResponseCode == '000000') { - $this->safDeletedCount = (int) $messageReader->readToCode(ControlCodes::FS); - } - } -} +deviceResponseCode == '000000') { + $this->safDeletedCount = (int) $messageReader->readToCode(ControlCodes::FS); + } + } +} diff --git a/src/Terminals/PAX/Responses/SafSummaryReport.php b/src/Terminals/PAX/Responses/SafSummaryReport.php index 23e503af..da254e97 100644 --- a/src/Terminals/PAX/Responses/SafSummaryReport.php +++ b/src/Terminals/PAX/Responses/SafSummaryReport.php @@ -1,29 +1,29 @@ -deviceResponseCode == '000000') { - $this->safTotalCount = (int) $messageReader->readToCode(ControlCodes::FS); - $this->safTotalAmount = (int) $messageReader->readToCode(ControlCodes::FS); - } - } -} +deviceResponseCode == '000000') { + $this->safTotalCount = (int) $messageReader->readToCode(ControlCodes::FS); + $this->safTotalAmount = (int) $messageReader->readToCode(ControlCodes::FS); + } + } +} diff --git a/src/Terminals/PAX/Responses/SafUploadResponse.php b/src/Terminals/PAX/Responses/SafUploadResponse.php index 6fff1710..438bfc48 100644 --- a/src/Terminals/PAX/Responses/SafUploadResponse.php +++ b/src/Terminals/PAX/Responses/SafUploadResponse.php @@ -1,49 +1,49 @@ -deviceResponseCode == '000000') { - $this->totalCount = (int) $messageReader->readToCode(ControlCodes::FS); - $totalAmount = $messageReader->readToCode(ControlCodes::FS); - $this->totalAmount = isset($totalAmount) ? TerminalUtils::reformatAmount($totalAmount) : ''; - - $this->timeStamp = (int) $messageReader->readToCode(ControlCodes::FS); - $this->safUploadedCount = (int) $messageReader->readToCode(ControlCodes::FS); - $safUploadedAmount = $messageReader->readToCode(ControlCodes::FS); - $this->safUploadedAmount = isset($safUploadedAmount) ? TerminalUtils::reformatAmount($safUploadedAmount) : ''; - - $this->safFailedCount = (int) $messageReader->readToCode(ControlCodes::FS); - $this->safFailedTotal = (int) $messageReader->readToCode(ControlCodes::FS); - } - } -} +deviceResponseCode == '000000') { + $this->totalCount = (int) $messageReader->readToCode(ControlCodes::FS); + $totalAmount = $messageReader->readToCode(ControlCodes::FS); + $this->totalAmount = isset($totalAmount) ? TerminalUtils::reformatAmount($totalAmount) : ''; + + $this->timeStamp = (int) $messageReader->readToCode(ControlCodes::FS); + $this->safUploadedCount = (int) $messageReader->readToCode(ControlCodes::FS); + $safUploadedAmount = $messageReader->readToCode(ControlCodes::FS); + $this->safUploadedAmount = isset($safUploadedAmount) ? TerminalUtils::reformatAmount($safUploadedAmount) : ''; + + $this->safFailedCount = (int) $messageReader->readToCode(ControlCodes::FS); + $this->safFailedTotal = (int) $messageReader->readToCode(ControlCodes::FS); + } + } +} diff --git a/src/Terminals/PAX/Responses/SignatureResponse.php b/src/Terminals/PAX/Responses/SignatureResponse.php index 0d484064..3f546c9e 100644 --- a/src/Terminals/PAX/Responses/SignatureResponse.php +++ b/src/Terminals/PAX/Responses/SignatureResponse.php @@ -1,90 +1,90 @@ -deviceType = $deviceType; - parent::__construct($rawResponse, $messageId); - } - - public function parseResponse($messageReader) - { - parent::parseResponse($messageReader); - - if ($this->resultCode == '000000' && $this->command == PaxMessageId::A09_RSP_GET_SIGNATURE) { - $this->totalLength = $messageReader->readToCode(ControlCodes::FS); - $this->responseLength = $messageReader->readToCode(ControlCodes::FS); - $coordinates = $messageReader->readToCode(ControlCodes::FS); - if (empty($coordinates)) { - throw new GatewayException( - 'Device error: ' . $e->getMessage(), - null, - $e->getMessage() - ); - } - $this->signatureData = $this->createSignature($coordinates); - } - } - - private function createSignature($coordinateString) - { - try { - $width = 150; - switch ($this->deviceType) { - case DeviceType::PAX_PX5: - case DeviceType::PAX_PX7: - $width = 350; - break; - } - - $coordinates = explode('^', $coordinateString); - $image = imagecreate($width, 100); - $backgroundColor = imagecolorallocate($image, 224, 234, 234); - $textColor = imagecolorallocate($image, 233, 14, 91); - - $index = 1; - $previousPoints = explode(',', $coordinates[$index]); - - do { - $coordinate = $coordinates[$index++]; - $startPoints = explode(',', $coordinate); - //draw line - if (isset($previousPoints[0]) && $previousPoints[1] && $startPoints[0] && $startPoints[1]) { - imageline( - $image, - $previousPoints[0], - $previousPoints[1], - $startPoints[0], - $startPoints[1], - $textColor - ); - } - $previousPoints = $startPoints; - } while ($coordinates[$index] != '~'); - - // start buffering - ob_start(); - imagepng($image); - $contents = ob_get_contents(); - ob_end_clean(); - - return base64_encode($contents); - } catch (\Exception $e) { - return "Error occurred while getting signature: " . $e->getMessage(); - } - } -} +deviceType = $deviceType; + parent::__construct($rawResponse, $messageId); + } + + public function parseResponse($messageReader) + { + parent::parseResponse($messageReader); + + if ($this->resultCode == '000000' && $this->command == PaxMessageId::A09_RSP_GET_SIGNATURE) { + $this->totalLength = $messageReader->readToCode(ControlCodes::FS); + $this->responseLength = $messageReader->readToCode(ControlCodes::FS); + $coordinates = $messageReader->readToCode(ControlCodes::FS); + if (empty($coordinates)) { + throw new GatewayException( + 'Device error: ' . $e->getMessage(), + null, + $e->getMessage() + ); + } + $this->signatureData = $this->createSignature($coordinates); + } + } + + private function createSignature($coordinateString) + { + try { + $width = 150; + switch ($this->deviceType) { + case DeviceType::PAX_PX5: + case DeviceType::PAX_PX7: + $width = 350; + break; + } + + $coordinates = explode('^', $coordinateString); + $image = imagecreate($width, 100); + $backgroundColor = imagecolorallocate($image, 224, 234, 234); + $textColor = imagecolorallocate($image, 233, 14, 91); + + $index = 1; + $previousPoints = explode(',', $coordinates[$index]); + + do { + $coordinate = $coordinates[$index++]; + $startPoints = explode(',', $coordinate); + //draw line + if (isset($previousPoints[0]) && $previousPoints[1] && $startPoints[0] && $startPoints[1]) { + imageline( + $image, + $previousPoints[0], + $previousPoints[1], + $startPoints[0], + $startPoints[1], + $textColor + ); + } + $previousPoints = $startPoints; + } while ($coordinates[$index] != '~'); + + // start buffering + ob_start(); + imagepng($image); + $contents = ob_get_contents(); + ob_end_clean(); + + return base64_encode($contents); + } catch (\Exception $e) { + return "Error occurred while getting signature: " . $e->getMessage(); + } + } +} diff --git a/src/Terminals/PAX/SubGroups/AccountRequest.php b/src/Terminals/PAX/SubGroups/AccountRequest.php index f09ce916..83ce936a 100644 --- a/src/Terminals/PAX/SubGroups/AccountRequest.php +++ b/src/Terminals/PAX/SubGroups/AccountRequest.php @@ -1,31 +1,31 @@ -{$val}) === false) { - $message .= $this->{$val}; - } - $message .= chr(ControlCodes::US); - } - return rtrim($message, chr(ControlCodes::US)); - } -} +{$val}) === false) { + $message .= $this->{$val}; + } + $message .= chr(ControlCodes::US); + } + return rtrim($message, chr(ControlCodes::US)); + } +} diff --git a/src/Terminals/PAX/SubGroups/AccountResponse.php b/src/Terminals/PAX/SubGroups/AccountResponse.php index 1e412d85..d522b09e 100644 --- a/src/Terminals/PAX/SubGroups/AccountResponse.php +++ b/src/Terminals/PAX/SubGroups/AccountResponse.php @@ -1,70 +1,70 @@ -readToCode(ControlCodes::FS); - // Split using ControlCodes::US - $response = preg_split('/[\x1F;]/', $responseString); - try { - $responseIndexMapping = [ - 'accountNumber' => 0, - 'expireDate' => 2, - 'ebtType' => 3, - 'voucherNumber' => 4, - 'newAccountNumber' => 5, - 'cardHolder' => 7, - 'cvdApprovalCode' => 8, - 'cvdMessage' => 9, - 'cardPresent' => 10 - ]; - - foreach ($responseIndexMapping as $property => $index) { - $this->{$property} = (isset($response[$index])) ? $response[$index] : ''; - } - - // entry mode and card Type - if (isset($response[1])) { - $entryMode = EnumUtils::parse(new PaxEntryMode(), $response[1]); - $this->entryMode = str_replace('_', ' ', $entryMode); - } - - if (isset($response[6])) { - $cardType = EnumUtils::parse(new TerminalCardType(), $response[6]); - $this->cardType = str_replace('_', ' ', $cardType); - } - } catch (\Exception $e) { - } - } -} +readToCode(ControlCodes::FS); + // Split using ControlCodes::US + $response = preg_split('/[\x1F;]/', $responseString); + try { + $responseIndexMapping = [ + 'accountNumber' => 0, + 'expireDate' => 2, + 'ebtType' => 3, + 'voucherNumber' => 4, + 'newAccountNumber' => 5, + 'cardHolder' => 7, + 'cvdApprovalCode' => 8, + 'cvdMessage' => 9, + 'cardPresent' => 10 + ]; + + foreach ($responseIndexMapping as $property => $index) { + $this->{$property} = (isset($response[$index])) ? $response[$index] : ''; + } + + // entry mode and card Type + if (isset($response[1])) { + $entryMode = EnumUtils::parse(new PaxEntryMode(), $response[1]); + $this->entryMode = str_replace('_', ' ', $entryMode); + } + + if (isset($response[6])) { + $cardType = EnumUtils::parse(new TerminalCardType(), $response[6]); + $this->cardType = str_replace('_', ' ', $cardType); + } + } catch (\Exception $e) { + } + } +} diff --git a/src/Terminals/PAX/SubGroups/AmountRequest.php b/src/Terminals/PAX/SubGroups/AmountRequest.php index e137f388..f722a1ee 100644 --- a/src/Terminals/PAX/SubGroups/AmountRequest.php +++ b/src/Terminals/PAX/SubGroups/AmountRequest.php @@ -1,31 +1,31 @@ -{$val}) === false) { - $message .= $this->{$val}; - } - $message .= chr(ControlCodes::US); - } - return rtrim($message, chr(ControlCodes::US)); - } -} +{$val}) === false) { + $message .= $this->{$val}; + } + $message .= chr(ControlCodes::US); + } + return rtrim($message, chr(ControlCodes::US)); + } +} diff --git a/src/Terminals/PAX/SubGroups/AmountResponse.php b/src/Terminals/PAX/SubGroups/AmountResponse.php index 92fa1a53..10457fd4 100644 --- a/src/Terminals/PAX/SubGroups/AmountResponse.php +++ b/src/Terminals/PAX/SubGroups/AmountResponse.php @@ -1,52 +1,52 @@ -readToCode(ControlCodes::FS); -//Split using ControlCodes::US - $response = preg_split('/[\x1F;]/', $responseString); - try { - $responseIndexMapping = [ - 'approvedAmount' => 0, - 'amountDue' => 1, - 'tipAmount' => 2, - 'cashBackAmount' => 3, - 'merchantFee' => 4, - 'taxAmount' => 5, - 'balance1' => 6, - 'balance2' => 7 - ]; - - foreach ($responseIndexMapping as $property => $index) { - $this->{$property} = (isset($response[$index])) - ? TerminalUtils::reformatAmount($response[$index]) - : ''; - } - } catch (\Exception $e) { - } - } -} +readToCode(ControlCodes::FS); +//Split using ControlCodes::US + $response = preg_split('/[\x1F;]/', $responseString); + try { + $responseIndexMapping = [ + 'approvedAmount' => 0, + 'amountDue' => 1, + 'tipAmount' => 2, + 'cashBackAmount' => 3, + 'merchantFee' => 4, + 'taxAmount' => 5, + 'balance1' => 6, + 'balance2' => 7 + ]; + + foreach ($responseIndexMapping as $property => $index) { + $this->{$property} = (isset($response[$index])) + ? TerminalUtils::reformatAmount($response[$index]) + : ''; + } + } catch (\Exception $e) { + } + } +} diff --git a/src/Terminals/PAX/SubGroups/AvsRequest.php b/src/Terminals/PAX/SubGroups/AvsRequest.php index ca2f4874..59cc6c1a 100644 --- a/src/Terminals/PAX/SubGroups/AvsRequest.php +++ b/src/Terminals/PAX/SubGroups/AvsRequest.php @@ -1,26 +1,26 @@ -{$val}) === false) { - $message .= $this->{$val}; - } - $message .= chr(ControlCodes::US); - } - return rtrim($message, chr(ControlCodes::US)); - } -} +{$val}) === false) { + $message .= $this->{$val}; + } + $message .= chr(ControlCodes::US); + } + return rtrim($message, chr(ControlCodes::US)); + } +} diff --git a/src/Terminals/PAX/SubGroups/AvsResponse.php b/src/Terminals/PAX/SubGroups/AvsResponse.php index 045c608f..5603ad46 100644 --- a/src/Terminals/PAX/SubGroups/AvsResponse.php +++ b/src/Terminals/PAX/SubGroups/AvsResponse.php @@ -1,25 +1,25 @@ -readToCode(ControlCodes::FS); - //Split using ControlCodes::US - $response = preg_split('/[\x1F;]/', $responseString); - try { - $this->avsResponseCode = isset($response[0]) ? $response[0] : ''; - $this->avsResponseMessage = isset($response[1]) ? $response[1] : ''; - } catch (\Exception $e) { - } - } -} +readToCode(ControlCodes::FS); + //Split using ControlCodes::US + $response = preg_split('/[\x1F;]/', $responseString); + try { + $this->avsResponseCode = isset($response[0]) ? $response[0] : ''; + $this->avsResponseMessage = isset($response[1]) ? $response[1] : ''; + } catch (\Exception $e) { + } + } +} diff --git a/src/Terminals/PAX/SubGroups/CashierResponse.php b/src/Terminals/PAX/SubGroups/CashierResponse.php index 66b7a65d..8371c5ff 100644 --- a/src/Terminals/PAX/SubGroups/CashierResponse.php +++ b/src/Terminals/PAX/SubGroups/CashierResponse.php @@ -1,25 +1,25 @@ -readToCode(ControlCodes::FS); - //Split using ControlCodes::US - $response = preg_split('/[\x1F;]/', $responseString); - try { - $this->clerkId = isset($response[0]) ? $response[0] : ''; - $this->shiftId = isset($response[1]) ? $response[1] : ''; - } catch (\Exception $e) { - } - } -} +readToCode(ControlCodes::FS); + //Split using ControlCodes::US + $response = preg_split('/[\x1F;]/', $responseString); + try { + $this->clerkId = isset($response[0]) ? $response[0] : ''; + $this->shiftId = isset($response[1]) ? $response[1] : ''; + } catch (\Exception $e) { + } + } +} diff --git a/src/Terminals/PAX/SubGroups/CashierSubGroup.php b/src/Terminals/PAX/SubGroups/CashierSubGroup.php index 8058498f..50012962 100644 --- a/src/Terminals/PAX/SubGroups/CashierSubGroup.php +++ b/src/Terminals/PAX/SubGroups/CashierSubGroup.php @@ -1,26 +1,26 @@ -{$val}) === false) { - $message .= $this->{$val}; - } - $message .= chr(ControlCodes::US); - } - return rtrim($message, chr(ControlCodes::US)); - } -} +{$val}) === false) { + $message .= $this->{$val}; + } + $message .= chr(ControlCodes::US); + } + return rtrim($message, chr(ControlCodes::US)); + } +} diff --git a/src/Terminals/PAX/SubGroups/CheckResponse.php b/src/Terminals/PAX/SubGroups/CheckResponse.php index eb17608d..735f34ff 100644 --- a/src/Terminals/PAX/SubGroups/CheckResponse.php +++ b/src/Terminals/PAX/SubGroups/CheckResponse.php @@ -1,55 +1,55 @@ -readToCode(ControlCodes::FS); - // Split using ControlCodes::US - $response = preg_split('/[\x1F;]/', $responseString); - try { - $responseIndexMapping = [ - 'saleType' => 0, - 'routingNumber' => 1, - 'accountNumber' => 2, - 'checkNumber' => 3, - 'checkType' => 4, - 'idType' => 5, - 'idValue' => 6, - 'DOB' => 7, - 'phoneNumber' => 8, - 'zipCode' => 9 - ]; - - foreach ($responseIndexMapping as $property => $index) { - $this->{$property} = (isset($response[$index])) ? $response[$index] : ''; - } - } catch (\Exception $e) { - } - } -} +readToCode(ControlCodes::FS); + // Split using ControlCodes::US + $response = preg_split('/[\x1F;]/', $responseString); + try { + $responseIndexMapping = [ + 'saleType' => 0, + 'routingNumber' => 1, + 'accountNumber' => 2, + 'checkNumber' => 3, + 'checkType' => 4, + 'idType' => 5, + 'idValue' => 6, + 'DOB' => 7, + 'phoneNumber' => 8, + 'zipCode' => 9 + ]; + + foreach ($responseIndexMapping as $property => $index) { + $this->{$property} = (isset($response[$index])) ? $response[$index] : ''; + } + } catch (\Exception $e) { + } + } +} diff --git a/src/Terminals/PAX/SubGroups/CommercialRequest.php b/src/Terminals/PAX/SubGroups/CommercialRequest.php index 00a49df6..259917db 100644 --- a/src/Terminals/PAX/SubGroups/CommercialRequest.php +++ b/src/Terminals/PAX/SubGroups/CommercialRequest.php @@ -1,28 +1,28 @@ -{$val}) === false) { - $message .= $this->{$val}; - } - $message .= chr(ControlCodes::US); - } - return rtrim($message, chr(ControlCodes::US)); - } -} +{$val}) === false) { + $message .= $this->{$val}; + } + $message .= chr(ControlCodes::US); + } + return rtrim($message, chr(ControlCodes::US)); + } +} diff --git a/src/Terminals/PAX/SubGroups/CommercialResponse.php b/src/Terminals/PAX/SubGroups/CommercialResponse.php index 4e8de743..61a76151 100644 --- a/src/Terminals/PAX/SubGroups/CommercialResponse.php +++ b/src/Terminals/PAX/SubGroups/CommercialResponse.php @@ -1,29 +1,29 @@ -readToCode(ControlCodes::FS); - //Split using ControlCodes::US - $response = preg_split('/[\x1F;]/', $responseString); - try { - $this->poNumber = isset($response[0]) ? $response[0] : ''; - $this->customerCode = isset($response[1]) ? $response[1] : ''; - $this->taxExempt = isset($response[2]) ? $response[2] : ''; - $this->taxExemptId = isset($response[3]) ? $response[3] : ''; - } catch (\Exception $e) { - } - } -} +readToCode(ControlCodes::FS); + //Split using ControlCodes::US + $response = preg_split('/[\x1F;]/', $responseString); + try { + $this->poNumber = isset($response[0]) ? $response[0] : ''; + $this->customerCode = isset($response[1]) ? $response[1] : ''; + $this->taxExempt = isset($response[2]) ? $response[2] : ''; + $this->taxExemptId = isset($response[3]) ? $response[3] : ''; + } catch (\Exception $e) { + } + } +} diff --git a/src/Terminals/PAX/SubGroups/EcomSubGroup.php b/src/Terminals/PAX/SubGroups/EcomSubGroup.php index adbaf1d2..bfeed31f 100644 --- a/src/Terminals/PAX/SubGroups/EcomSubGroup.php +++ b/src/Terminals/PAX/SubGroups/EcomSubGroup.php @@ -1,31 +1,31 @@ -{$val}) === false) { - $message .= $this->{$val}; - } - $message .= chr(ControlCodes::US); - } - return rtrim($message, chr(ControlCodes::US)); - } -} +{$val}) === false) { + $message .= $this->{$val}; + } + $message .= chr(ControlCodes::US); + } + return rtrim($message, chr(ControlCodes::US)); + } +} diff --git a/src/Terminals/PAX/SubGroups/EcomSubGroupResponse.php b/src/Terminals/PAX/SubGroups/EcomSubGroupResponse.php index 5358988c..dd1c13f4 100644 --- a/src/Terminals/PAX/SubGroups/EcomSubGroupResponse.php +++ b/src/Terminals/PAX/SubGroups/EcomSubGroupResponse.php @@ -1,42 +1,42 @@ -readToCode(ControlCodes::FS); - $response = preg_split('/[\x1F;]/', $responseString); - try { - $responseIndexMapping = [ - 'ecomMode' => 0, - 'transactionType' => 1, - 'secureType' => 2, - 'orderNumber' => 3, - 'installments' => 4, - 'currentInstallment' => 5 - ]; - - foreach ($responseIndexMapping as $property => $index) { - $this->{$property} = (isset($response[$index])) ? $response[$index] : ''; - } - } catch (\Exception $e) { - } - } -} +readToCode(ControlCodes::FS); + $response = preg_split('/[\x1F;]/', $responseString); + try { + $responseIndexMapping = [ + 'ecomMode' => 0, + 'transactionType' => 1, + 'secureType' => 2, + 'orderNumber' => 3, + 'installments' => 4, + 'currentInstallment' => 5 + ]; + + foreach ($responseIndexMapping as $property => $index) { + $this->{$property} = (isset($response[$index])) ? $response[$index] : ''; + } + } catch (\Exception $e) { + } + } +} diff --git a/src/Terminals/PAX/SubGroups/ExtDataSubGroup.php b/src/Terminals/PAX/SubGroups/ExtDataSubGroup.php index a890df5f..46d87fc6 100644 --- a/src/Terminals/PAX/SubGroups/ExtDataSubGroup.php +++ b/src/Terminals/PAX/SubGroups/ExtDataSubGroup.php @@ -1,23 +1,23 @@ -details)) { - foreach ($this->details as $key => $val) { - $message .= sprintf("%s=%s%s", $key, $val, chr(ControlCodes::US)); - } - } - return rtrim($message, chr(ControlCodes::US)); - } -} +details)) { + foreach ($this->details as $key => $val) { + $message .= sprintf("%s=%s%s", $key, $val, chr(ControlCodes::US)); + } + } + return rtrim($message, chr(ControlCodes::US)); + } +} diff --git a/src/Terminals/PAX/SubGroups/ExtDataSubGroupResponse.php b/src/Terminals/PAX/SubGroups/ExtDataSubGroupResponse.php index 61551313..98599d47 100644 --- a/src/Terminals/PAX/SubGroups/ExtDataSubGroupResponse.php +++ b/src/Terminals/PAX/SubGroups/ExtDataSubGroupResponse.php @@ -1,33 +1,33 @@ -readToCode(ControlCodes::FS); - $response = preg_split('/[\x1F;]/', $responseString); - try { - foreach ($response as $val) { - $val = explode('=', $val); - if (!empty($val[0]) && isset($val[1])) { - $key = trim(strtoupper($val[0])); - $this->details[$key] = trim($val[1]); - } - } - } catch (\Exception $e) { - } - } - - public function getExtValue($key) - { - return (!empty($this->details[$key])) ? $this->details[$key] : ''; - } -} +readToCode(ControlCodes::FS); + $response = preg_split('/[\x1F;]/', $responseString); + try { + foreach ($response as $val) { + $val = explode('=', $val); + if (!empty($val[0]) && isset($val[1])) { + $key = trim(strtoupper($val[0])); + $this->details[$key] = trim($val[1]); + } + } + } catch (\Exception $e) { + } + } + + public function getExtValue($key) + { + return (!empty($this->details[$key])) ? $this->details[$key] : ''; + } +} diff --git a/src/Terminals/PAX/SubGroups/HostResponse.php b/src/Terminals/PAX/SubGroups/HostResponse.php index 12215487..8b5b8d67 100644 --- a/src/Terminals/PAX/SubGroups/HostResponse.php +++ b/src/Terminals/PAX/SubGroups/HostResponse.php @@ -1,43 +1,43 @@ -readToCode(ControlCodes::FS); - // Split using ControlCodes::US - $response = preg_split('/[\x1F;]/', $responseString); - try { - $responseIndexMapping = [ - 'hostResponseCode' => 0, - 'hostResponseMessage' => 1, - 'authCode' => 2, - 'hostReferenceNumber' => 3, - 'traceNumber' => 4, - 'batchNumber' => 5 - ]; - - foreach ($responseIndexMapping as $property => $index) { - $this->{$property} = (isset($response[$index])) ? $response[$index] : ''; - } - } catch (\Exception $e) { - } - } -} +readToCode(ControlCodes::FS); + // Split using ControlCodes::US + $response = preg_split('/[\x1F;]/', $responseString); + try { + $responseIndexMapping = [ + 'hostResponseCode' => 0, + 'hostResponseMessage' => 1, + 'authCode' => 2, + 'hostReferenceNumber' => 3, + 'traceNumber' => 4, + 'batchNumber' => 5 + ]; + + foreach ($responseIndexMapping as $property => $index) { + $this->{$property} = (isset($response[$index])) ? $response[$index] : ''; + } + } catch (\Exception $e) { + } + } +} diff --git a/src/Terminals/PAX/SubGroups/TraceRequest.php b/src/Terminals/PAX/SubGroups/TraceRequest.php index 68096811..ec7d04ef 100644 --- a/src/Terminals/PAX/SubGroups/TraceRequest.php +++ b/src/Terminals/PAX/SubGroups/TraceRequest.php @@ -1,32 +1,32 @@ -{$val}) === false) { - $message .= $this->{$val}; - } - $message .= chr(ControlCodes::US); - } - return rtrim($message, chr(ControlCodes::US)); - } -} +{$val}) === false) { + $message .= $this->{$val}; + } + $message .= chr(ControlCodes::US); + } + return rtrim($message, chr(ControlCodes::US)); + } +} diff --git a/src/Terminals/PAX/SubGroups/TraceResponse.php b/src/Terminals/PAX/SubGroups/TraceResponse.php index 18c076c1..70dd1d56 100644 --- a/src/Terminals/PAX/SubGroups/TraceResponse.php +++ b/src/Terminals/PAX/SubGroups/TraceResponse.php @@ -1,27 +1,27 @@ -readToCode(ControlCodes::FS); - // Split using ControlCodes::US - $response = preg_split('/[\x1F;]/', $responseString); - try { - $this->transactionNumber = isset($response[0]) ? $response[0] : ''; - $this->referenceNumber = isset($response[1]) ? $response[1] : ''; - $this->timeStamp = isset($response[2]) ? $response[2] : ''; - } catch (\Exception $e) { - } - } -} +readToCode(ControlCodes::FS); + // Split using ControlCodes::US + $response = preg_split('/[\x1F;]/', $responseString); + try { + $this->transactionNumber = isset($response[0]) ? $response[0] : ''; + $this->referenceNumber = isset($response[1]) ? $response[1] : ''; + $this->timeStamp = isset($response[2]) ? $response[2] : ''; + } catch (\Exception $e) { + } + } +} diff --git a/src/Utils/AmountUtils.php b/src/Utils/AmountUtils.php new file mode 100644 index 00000000..ece5be17 --- /dev/null +++ b/src/Utils/AmountUtils.php @@ -0,0 +1,19 @@ + [ + '448460' => '448611', + '448613' => '448615', + '448617' => '448674', + '448676' => '448686', + '448688' => '448699', + '461400' => '461421', + '461423' => '461499', + '480700' => '480899' + ], + 'MC' => [ + '553231' => '553380', + '556083' => '556099', + '556100' => '556599', + '556700' => '556999', + ], + 'Wex' => [ + '690046' => '690046', + '707138' => '707138' + ], + 'Voyager' => [ + '708885' => '708889' + ] + ]; + + /** + * Card type regex patterns + * + * @var array + */ + private static $cardTypes = [ + 'Visa' => '/^4/', + 'MC' => '/^(5[1-5]|2[2-7])/', + 'Amex' => '/^3[47]/', + 'DinersClub' => '/^3[0689]/', + 'EnRoute' => '/^2(014|149)/', + 'Discover' => '/^6([045]|22)/', + 'Jcb' => '/^35/', + "Wex" => "^(?:690046|707138)", + ]; + + public static function parseTrackData($paymentMethod) + { + $trackData = $paymentMethod->value; + preg_match(static::$trackTwoPattern, $trackData, $matches); + if (!empty($matches[1]) && !empty($matches[2]) && !empty($matches[3])) { + $pan = $matches[1]; + $expiry = $matches[2]; + $discretionary = $matches[3]; + + if (!empty($discretionary)) { + if (strlen($pan.$expiry.$discretionary) == 37 && + substr(strtolower($discretionary), -1) == 'f') { + $discretionary = substr($discretionary, 0, strlen($discretionary) - 1); + } + } + + $paymentMethod->trackNumber = TrackNumber::TRACK_TWO; + $paymentMethod->pan = $pan; + $paymentMethod->expiry = $expiry; + $paymentMethod->discretionaryData = $discretionary; + $paymentMethod->trackData = sprintf("%s=%s%s?", $pan, $expiry, $discretionary); + } else { + preg_match(static::$trackOnePattern, $trackData, $matches); + if (!empty($matches[1]) && !empty($matches[2]) && !empty($matches[3])) { + $paymentMethod->trackNumber = TrackNumber::TRACK_ONE; + $paymentMethod->pan = $matches[1]; + $paymentMethod->expiry = $matches[2]; + $paymentMethod->discretionaryData = $matches[3]; + $paymentMethod->trackData = str_replace('%', '', $matches[0]); + } + } + return $paymentMethod; + } + + /** + * Gets a card's type based on the BIN + * + * @return string + */ + public static function getCardType($number) + { + $number = str_replace( + [' ', '-'], + '', + $number + ); + + $type = 'Unknown'; + foreach (static::$cardTypes as $type => $regex) { + if (1 === preg_match($regex, $number)) { + return $type; + } + } + + if ($type === "Unknown") { + if (static::isFleet($type, $number)) { + $type += "Fleet"; + } + } + + return $type; + } + + public static function isFleet($cardType, $pan) + { + if (!empty($pan)) { + $compareValue = substr($pan, 0, 6); + $baseCardType = str_replace("Fleet", '', $cardType); + + if (!empty(static::$fleetBinMap[$baseCardType])) { + $binRanges = static::$fleetBinMap[$baseCardType]; + foreach ($binRanges as $lowerRange => $upperRange) { + if ($compareValue >= $lowerRange && $compareValue <= $upperRange) { + return true; + } + } + } + } + return false; + } +} diff --git a/src/Utils/EnumUtils.php b/src/Utils/EnumUtils.php index 6d848b92..9e114e4c 100644 --- a/src/Utils/EnumUtils.php +++ b/src/Utils/EnumUtils.php @@ -1,22 +1,22 @@ -get($value); - } -} +get($value); + } +} diff --git a/src/Utils/MessageReader.php b/src/Utils/MessageReader.php index efcb924a..aaa36a3f 100644 --- a/src/Utils/MessageReader.php +++ b/src/Utils/MessageReader.php @@ -1,109 +1,109 @@ -length; - } - - public function __construct($bytes) - { - $this->buffer = $bytes; - $this->length = strlen($bytes); - $this->position = 0; - } - - public function canRead() - { - return $this->position < $this->length; - } - - public function peek() - { - return $this->buffer[$this->position]; - } - - public function readCode() - { - return $this->readEnum(new ControlCodes()); - } - - public function readEnum($enumType) - { - $map = new ReverseEnumMap($enumType); - return $map->get(ord($this->buffer[$this->position++])); - } - - public function readByte() - { - return $this->buffer[$this->position++]; - } - - public function readBytes($length) - { - $rvalue = ''; - - try { - for ($i = 0; $i < $this->length; $i++) { - $rvalue[$i] = $this->buffer[$this->position++]; - } - } catch (\Exception $e) { - // eat this exception and return what we have - } - - return $rvalue; - } - - public function readChar() - { - return $this->buffer[$this->position++]; - } - - public function readString($length) - { - $rvalue = ""; - - for ($i = 0; $i < $this->length; $i++) { - $rvalue += $this->buffer[$this->position++]; - } - return $rvalue; - } - - public function readToCode($code, $removeCode = true) - { - $rvalue = ""; - - try { - while (1) { - $currentValue = ord($this->peek()); - if ($currentValue === $code || $currentValue === (int) ControlCodes::ETX) { - break; - } - $rvalue .= $this->buffer[$this->position++]; - } - } catch (\Exception $e) { - $removeCode = false; - } - // pop the code off - if ($removeCode) { - $this->readByte(); - } - return $rvalue; - } - - public function purge() - { - $this->buffer = ''; - $this->length = 0; - } -} +length; + } + + public function __construct($bytes) + { + $this->buffer = $bytes; + $this->length = strlen($bytes); + $this->position = 0; + } + + public function canRead() + { + return $this->position < $this->length; + } + + public function peek() + { + return $this->buffer[$this->position]; + } + + public function readCode() + { + return $this->readEnum(new ControlCodes()); + } + + public function readEnum($enumType) + { + $map = new ReverseEnumMap($enumType); + return $map->get(ord($this->buffer[$this->position++])); + } + + public function readByte() + { + return $this->buffer[$this->position++]; + } + + public function readBytes($length) + { + $rvalue = ''; + + try { + for ($i = 0; $i < $this->length; $i++) { + $rvalue[$i] = $this->buffer[$this->position++]; + } + } catch (\Exception $e) { + // eat this exception and return what we have + } + + return $rvalue; + } + + public function readChar() + { + return $this->buffer[$this->position++]; + } + + public function readString($length) + { + $rvalue = ""; + + for ($i = 0; $i < $this->length; $i++) { + $rvalue += $this->buffer[$this->position++]; + } + return $rvalue; + } + + public function readToCode($code, $removeCode = true) + { + $rvalue = ""; + + try { + while (1) { + $currentValue = ord($this->peek()); + if ($currentValue === $code || $currentValue === (int) ControlCodes::ETX) { + break; + } + $rvalue .= $this->buffer[$this->position++]; + } + } catch (\Exception $e) { + $removeCode = false; + } + // pop the code off + if ($removeCode) { + $this->readByte(); + } + return $rvalue; + } + + public function purge() + { + $this->buffer = ''; + $this->length = 0; + } +} diff --git a/src/Utils/ReverseEnumMap.php b/src/Utils/ReverseEnumMap.php index 54887aa1..ea14ae50 100644 --- a/src/Utils/ReverseEnumMap.php +++ b/src/Utils/ReverseEnumMap.php @@ -1,23 +1,23 @@ -getConstants() as $constant => $value) { - $this->map[$value] = $constant; - } - } - - public function get($value) - { - return isset($this->map[$value]) ? $this->map[$value] : ''; - } -} +getConstants() as $constant => $value) { + $this->map[$value] = $constant; + } + } + + public function get($value) + { + return isset($this->map[$value]) ? $this->map[$value] : ''; + } +} diff --git a/src/Utils/StringUtils.php b/src/Utils/StringUtils.php new file mode 100644 index 00000000..a2393f49 --- /dev/null +++ b/src/Utils/StringUtils.php @@ -0,0 +1,41 @@ +getConfig()); + + $this->card = new GiftCard(); + $this->card->number = '6033590009112245098'; + $this->card->pin = ''; + + $this->track = new GiftCard(); + $this->track->trackData = ';6033590009112245098=64120000000000000?'; + } + + protected function getConfig() + { + $config = new ServicesConfig(); + $config->merchantName = 'Test Shane Logsdon'; + $config->merchantSiteId = 'BKHV2T68'; + $config->merchantKey = 'AT6AN-ALYJE-YF3AW-3M5NN-UQDG1'; + $config->gatewayProvider = GatewayProvider::GENIUS; + $config->environment = Environment::TEST; + return $config; + } + + public function testGiftActivateCard() + { + $response = $this->card->activate(10) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + + public function testGiftAddValue() + { + $response = $this->track->addValue(10) + ->withCurrency('USD') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testGiftBalanceInquiry() + { + $response = $this->card->balanceInquiry() + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testGiftSale() + { + $response = $this->track->charge(10) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testGiftRefund() + { + $response = $this->track->charge(10) + ->withCurrency('USD') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + $transaction = $response->fromId($response->transactionReference->transactionId, null, paymentMethodType::GIFT); + $response = $transaction->refund(10) + ->withCurrency('USD') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testGiftVoid() + { + $response = $this->track->charge(10) + ->withCurrency('USD') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + $transaction = $response->fromId($response->transactionReference->transactionId, null, paymentMethodType::GIFT); + $response = $transaction->void() + ->withCurrency('USD') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testGiftAddCurrencyPoints() + { + $response = $this->track->rewards(10) + ->withCurrency('Currency') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testGiftAddPoints() + { + $response = $this->track->rewards(10) + ->withCurrency('Points') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } +} diff --git a/test/Integration/Gateways/GeniusConnector/MerchantwareTests.php b/test/Integration/Gateways/GeniusConnector/MerchantwareTests.php new file mode 100644 index 00000000..23973b4b --- /dev/null +++ b/test/Integration/Gateways/GeniusConnector/MerchantwareTests.php @@ -0,0 +1,330 @@ +getConfig()); + + $this->address = new Address(); + $this->address->streetAddress1 = '1 Federal Street'; + $this->address->postalCode = '02110'; + + $this->applePay = new CreditCardData(); + $this->applePay->token = 'ew0KCSJ2ZXJzaW9uIjogIkVDX3YxIiwNCgkiZ=='; + $this->applePay->mobileType = MobilePaymentMethodType::APPLEPAY; + + $this->card = TestCards::visaManual(); + $this->tokenizedCard = new CreditCardData(); + $this->tokenizedCard->token = '100000101GC58TDAUFDZ'; + + $this->track = TestCards::visaSwipe(); + } + + protected function getConfig() + { + $config = new ServicesConfig(); + // $config->merchantName = 'QA TSys Sierra Test'; + // $config->merchantSiteId = 'D7MX8E4N'; + // $config->merchantKey = '5U6HL-J7GHG-28AX1-G5KQH-AEH0G'; + $config->merchantName = 'Test Shane Logsdon'; + $config->merchantSiteId = 'BKHV2T68'; + $config->merchantKey = 'AT6AN-ALYJE-YF3AW-3M5NN-UQDG1'; + // $config->registerNumber = '35'; + // $config->terminalId = '3'; + $config->gatewayProvider = GatewayProvider::GENIUS; + $config->environment = Environment::TEST; + return $config; + } + + // AdjustTip only works with certain credentials + // Don't pass in cvn + public function testAdjustTip() + { + $response = $this->card->charge(10) + ->withCurrency('USD') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('APPROVED', $response->responseMessage); + + $adjust = $response->edit() + ->withGratuity(1.05) + ->execute(); + + $this->assertNotNull($adjust); + $this->assertEquals('APPROVED', $response->responseMessage); + } + + public function testAuthorizeKeyed() + { + $response = $this->card->authorize(10) + ->withCurrency('USD') + ->withAddress($this->address) + ->withInvoiceNumber('1556') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testAuthorizeSwiped() + { + $response = $this->track->authorize(10) + ->withCurrency('USD') + ->withInvoiceNumber('1264') + ->withClientTransactionId('137149') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testAuthorizeVault() + { + $response = $this->tokenizedCard->authorize(10) + ->withCurrency('USD') + ->withInvoiceNumber('1558') + ->withClientTransactionId('167903') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testBoardCardKeyed() + { + $token = $this->card->tokenize()->execute(); + $this->assertNotNull($token); + } + + public function testBoardCardSwiped() + { + $token = $this->track->tokenize()->execute(); + $this->assertNotNull($token); + } + + public function testCapture() + { + $response = $this->track->authorize(10) + ->withCurrency('USD') + ->withInvoiceNumber('1264') + ->withClientTransactionId('137149') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + $captureResponse = $response->capture(10)->execute(); + + $this->assertNotNull($captureResponse); + $this->assertEquals('00', $captureResponse->responseCode); + } + + public function testUpdatedBoardedCard() + { + $this->tokenizedCard->expMonth = 12; + $this->tokenizedCard->expYear = 2025; + + $success = $this->tokenizedCard->updateTokenExpiry(); + $this->assertTrue($success); + } + + public function testForceCaptureKeyed() + { + $response = $this->card->authorize(10) + ->withCurrency('USD') + ->withOfflineAuthCode('V00546') + ->withInvoiceNumber('1559') + ->withClientTransactionId('168901') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRefundKeyed() + { + $response = $this->card->refund(4.01) + ->withCurrency('USD') + ->withInvoiceNumber('1701') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + // TODO: Refund using clientTransactionId not implemented on manage transactions + // public function testRefundTransactionId() { + // $response = $this->card->charge(4.01) + // ->withCurrency('USD') + // ->withInvoiceNumber('1703') + // ->withClientTransactionId('165902') + // ->execute(); + + // $this->assertNotNull($response); + // $this->assertEquals('00', $response->responseCode); + + // $refund = $response->refund() + // ->withClientTransactionId('165902') + // ->execute(); + + // $this->assertNotNull($refund); + // $this->Equals('00', $refund->responseCode); + // } + + public function testRefundSwiped() + { + $response = $this->track->refund(4.01) + ->withCurrency('USD') + ->withInvoiceNumber('1701') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRefundVault() + { + $response = $this->tokenizedCard->refund(1.83) + ->withCurrency('USD') + ->withCashBack(0) + ->withConvenienceAmount(0) + ->withInvoiceNumber('1559') + ->withAllowPartialAuth(false) + ->withAllowDuplicates(false) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testSaleKeyed() + { + $response = $this->card->charge(1.05) + ->withCurrency('USD') + ->withCashBack(0) + ->withConvenienceAmount(0) + ->withInvoiceNumber('12345') + ->withClientTransactionId('166901') + ->withAllowPartialAuth(false) + ->withAllowDuplicates(false) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testSaleSwiped() + { + $response = $this->track->charge(1.29) + ->withCurrency('USD') + ->withCashBack(0) + ->withConvenienceAmount(0) + ->withInvoiceNumber('12345') + ->withClientTransactionId('138401') + ->withAllowPartialAuth(false) + ->withAllowDuplicates(false) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testSaleVault() + { + $response = $this->tokenizedCard->charge(1.29) + ->withCurrency('USD') + ->withCashBack(0) + ->withConvenienceAmount(0) + ->withInvoiceNumber('1559') + ->withClientTransactionId('166909') + ->withAllowPartialAuth(false) + ->withAllowDuplicates(false) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testSaleHealthcare() + { + $autoSubstantiation = new AutoSubstantiation(); + $autoSubstantiation->setCopaySubTotal(60); + + $response = $this->card->charge(202) + ->withCurrency('USD') + ->withInvoiceNumber('1556') + ->withClientTransactionId('166901') + ->withAutoSubstantiation($autoSubstantiation) + ->withAllowPartialAuth(false) + ->withAllowDuplicates(false) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + // Response not mapping correctly + public function testSettleBatch() + { + $response = BatchService::closeBatch(); + + $this->assertNotNull($response); + $this->assertEquals('SUCCESS', $response->batchSummary->status); + } + + // createElement not working + public function testUnboardCard() + { + $token = TestCards::masterCardManual()->tokenize()->execute(); + $this->assertNotNull($token->token); + + $deleteCard = new CreditCardData(); + $deleteCard->token = $token->token; + + $success = $deleteCard->deleteToken(); + $this->assertTrue($success); + } + + public function testVoid() + { + $response = $this->card->charge(10) + ->withCurrency('USD') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + $voidResponse = $response->void()->execute(); + + $this->assertNotNull($voidResponse); + $this->assertEquals('00', $voidResponse->responseCode); + } +} diff --git a/test/Integration/Gateways/PorticoConnector/AutoSubstantiationTest.php b/test/Integration/Gateways/PorticoConnector/AutoSubstantiationTest.php new file mode 100644 index 00000000..2febfd00 --- /dev/null +++ b/test/Integration/Gateways/PorticoConnector/AutoSubstantiationTest.php @@ -0,0 +1,45 @@ +card = new CreditCardData(); + $this->card->number = '4111111111111111'; + $this->card->expMonth = 12; + $this->card->expYear = 2025; + $this->card->cvn = '123'; + + ServicesContainer::configure($this->getConfig()); + } + + protected function getConfig() + { + $config = new ServicesConfig(); + $config->secretApiKey = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'; + $config->serviceUrl = 'https://cert.api2.heartlandportico.com'; + return $config; + } + + public function testAutoSub1() { + $AutoSubAmounts = new AutoSubstantiation(); + $AutoSubAmounts->realTimeSubstantiation = true; + $AutoSubAmounts->setDentalSubTotal(5.00); + $AutoSubAmounts->setClinicSubTotal(5); + $AutoSubAmounts->setVisionSubTotal(5); + + $response = $this->card->charge(15) + ->withAutoSubstantiation($AutoSubAmounts) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } +} diff --git a/test/Integration/Gateways/PorticoConnector/CommercialCardTest.php b/test/Integration/Gateways/PorticoConnector/CommercialCardTest.php new file mode 100644 index 00000000..384993e4 --- /dev/null +++ b/test/Integration/Gateways/PorticoConnector/CommercialCardTest.php @@ -0,0 +1,45 @@ +card = new CreditCardData(); + $this->card->number = '4111111111111111'; + $this->card->expMonth = 12; + $this->card->expYear = 2025; + $this->card->cvn = '123'; + ServicesContainer::configure($this->getConfig()); + } + + protected function getConfig() + { + $config = new ServicesConfig(); + $config->secretApiKey = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'; + $config->serviceUrl = 'https://cert.api2.heartlandportico.com'; + return $config; + } + + public function testCommercialData1() { // test sending LVL2 data with the orinal transaction + $commercialData = new CommercialData; + $commercialData->taxAmount = '1.23'; + $commercialData->taxType = TaxType::SALES_TAX; + $commercialData->poNumber = '654564564'; + + $response = $this->card->charge(112.34) + ->withAllowDuplicates(true) + ->withCommercialData($commercialData) + ->withCurrency('USD') + ->execute(); + + $this->assertEquals('B', $response->commercialIndicator); + } +} + diff --git a/test/Integration/Gateways/PorticoConnector/PorticoTokenManagementTest.php b/test/Integration/Gateways/PorticoConnector/PorticoTokenManagementTest.php index 4ccfc30d..05109302 100644 --- a/test/Integration/Gateways/PorticoConnector/PorticoTokenManagementTest.php +++ b/test/Integration/Gateways/PorticoConnector/PorticoTokenManagementTest.php @@ -29,7 +29,6 @@ public function setup() : void } catch (ApiException $exc) { $this->fail($exc->message); } - } protected function getConfig() @@ -69,4 +68,4 @@ public function testDeleteToken() $this->assertEquals('27', $exc->responseCode); } } -} \ No newline at end of file +} diff --git a/test/Integration/Gateways/RealexConnector/AcsResponse.php b/test/Integration/Gateways/RealexConnector/AcsResponse.php index 131078e3..c2d3c4ed 100644 --- a/test/Integration/Gateways/RealexConnector/AcsResponse.php +++ b/test/Integration/Gateways/RealexConnector/AcsResponse.php @@ -17,28 +17,32 @@ class AcsResponse /** * @return string */ - public function getAuthResponse(){ + public function getAuthResponse() + { return $this->authResponse; } /** * @return void */ - public function setAuthResponse($authResponse){ + public function setAuthResponse($authResponse) + { $this->authResponse = $authResponse; } /** * @return string */ - public function getMerchantData(){ + public function getMerchantData() + { return $this->merchantData; } /** * @return void */ - public function setMerchantData($merchantData){ + public function setMerchantData($merchantData) + { $this->merchantData = $merchantData; } -} \ No newline at end of file +} diff --git a/test/Integration/Gateways/RealexConnector/ApiTestCase.php b/test/Integration/Gateways/RealexConnector/ApiTestCase.php index a1f6a047..432ce586 100644 --- a/test/Integration/Gateways/RealexConnector/ApiTestCase.php +++ b/test/Integration/Gateways/RealexConnector/ApiTestCase.php @@ -100,7 +100,7 @@ public function testprocessPaymentRefund() $message = $response->responseMessage; // [ test system ] AUTHORISED $this->assertNotEquals(null, $response); - $this->assertEquals("00", $responseCode); + $this->assertEquals("00", $responseCode); } /* 03. Process Payment OTB */ @@ -901,29 +901,29 @@ public function testfraudManagementDecisionManager() $products = []; $products[] = array( - 'product_id' => 'SKU251584', - 'productname' => 'Magazine Subscription', - 'quantity' => '12', - 'unitprice' => '1200', - 'gift' => 'true', - 'type' => 'subscription', + 'product_id' => 'SKU251584', + 'productname' => 'Magazine Subscription', + 'quantity' => '12', + 'unitprice' => '1200', + 'gift' => 'true', + 'type' => 'subscription', 'risk' => 'Low' ); $products[] = array( - 'product_id' => 'SKU8884784', - 'productname' => 'Charger', - 'quantity' => '10', - 'unitprice' => '1200', - 'gift' => 'false', - 'type' => 'subscription', + 'product_id' => 'SKU8884784', + 'productname' => 'Charger', + 'quantity' => '10', + 'unitprice' => '1200', + 'gift' => 'false', + 'type' => 'subscription', 'risk' => 'High' ); $custom = []; $custom[] = array( - 'field01' => 'fieldValue01', - 'field02' => 'fieldValue02', - 'field03' => 'fieldValue03', + 'field01' => 'fieldValue01', + 'field02' => 'fieldValue02', + 'field03' => 'fieldValue03', 'field04' => 'fieldValue04' ); @@ -944,7 +944,8 @@ public function testfraudManagementDecisionManager() $this->assertEquals("00", $responseCode); } - public function testAuthorisationWithoutAccountId() { + public function testAuthorisationWithoutAccountId() + { $config = new ServicesConfig(); $config->merchantId = 'heartlandgpsandbox'; $config->sharedSecret = 'secret'; @@ -972,7 +973,7 @@ public function testAuthorisationWithoutAccountId() { public function testRefundWithoutAccountId() { $config = new ServicesConfig(); - $config->merchantId = 'heartlandgpsandbox'; + $config->merchantId = 'heartlandgpsandbox'; $config->sharedSecret = 'secret'; $config->refundPassword = 'refund'; $config->serviceUrl = 'https://api.sandbox.realexpayments.com/epage-remote.cgi'; @@ -993,7 +994,6 @@ public function testRefundWithoutAccountId() ->execute(); $this->assertNotEquals(null, $response); - $this->assertEquals("00", $response->responseCode); + $this->assertEquals("00", $response->responseCode); } - } diff --git a/test/Integration/Gateways/RealexConnector/Certifications/SdkTest.php b/test/Integration/Gateways/RealexConnector/Certifications/SdkTest.php index 4fe5a53f..05e488d4 100644 --- a/test/Integration/Gateways/RealexConnector/Certifications/SdkTest.php +++ b/test/Integration/Gateways/RealexConnector/Certifications/SdkTest.php @@ -1983,7 +1983,7 @@ public function testAuth031b() * @expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException */ public function testAuth031c1() - { + { $config = $this->getBaseConfig(); ServicesContainer::configure($config); diff --git a/test/Integration/Gateways/RealexConnector/HppTest.php b/test/Integration/Gateways/RealexConnector/HppTest.php index 66dace35..3e6a88ae 100644 --- a/test/Integration/Gateways/RealexConnector/HppTest.php +++ b/test/Integration/Gateways/RealexConnector/HppTest.php @@ -124,7 +124,7 @@ public function testCreditSale() /* 03. ProcessPaymentOtbRequest */ public function testCreditVerify() - { + { $config = new ServicesConfig(); $config->merchantId = "heartlandgpsandbox"; $config->accountId = "hpp"; @@ -149,7 +149,7 @@ public function testCreditVerify() ->withCurrency("EUR") ->withCustomerId("123456") ->withAddress($address) - ->serialize(); + ->serialize(); $this->assertNotNull($json); $response = $client->sendRequest($json, $hppVersion); @@ -359,7 +359,7 @@ public function testEnableDynamicCurrencyConversionRequest() //serialize the request $json = $service->Charge(19) - ->withCurrency("EUR") + ->withCurrency("EUR") ->withTimestamp("20170725154824") ->withOrderId('GTI5Yxb0SumL_TkDMCAxQA') ->serialize(); @@ -389,7 +389,7 @@ public function testDisableDynamicCurrencyConversionRequest() //serialize the request $json = $service->Charge(19) - ->withCurrency("EUR") + ->withCurrency("EUR") ->withTimestamp("20170725154824") ->withOrderId('GTI5Yxb0SumL_TkDMCAxQA') ->serialize(); diff --git a/test/Integration/Gateways/RealexConnector/RealexApmTest.php b/test/Integration/Gateways/RealexConnector/RealexApmTest.php index f696c6b7..a0eddd4f 100644 --- a/test/Integration/Gateways/RealexConnector/RealexApmTest.php +++ b/test/Integration/Gateways/RealexConnector/RealexApmTest.php @@ -12,9 +12,11 @@ use GlobalPayments\Api\Entities\Transaction; use PHPUnit\Framework\TestCase; -class RealexApmTest extends TestCase { +class RealexApmTest extends TestCase +{ - protected function config() { + protected function config() + { $config = new ServicesConfig(); $config->merchantId = "heartlandgpsandbox"; $config->accountId = "hpp"; @@ -25,11 +27,13 @@ protected function config() { return $config; } - public function setup() { + public function setup() + { ServicesContainer::configure($this->config()); } - public function testApmForCharge() { + public function testApmForCharge() + { $paymentMethod = new AlternativePaymentMethod(AlternativePaymentType::SOFORTUBERWEISUNG); $paymentMethod->returnUrl = 'https://www.example.com/returnUrl'; @@ -60,7 +64,8 @@ public function testApmForCharge() { * @expectedException \GlobalPayments\Api\Entities\Exceptions\BuilderException * @expectedExceptionMessage amount cannot be null for this transaction type */ - public function testApmWithoutAmount() { + public function testApmWithoutAmount() + { $paymentMethod = new AlternativePaymentMethod(AlternativePaymentType::SOFORTUBERWEISUNG); $paymentMethod->returnUrl = 'https://www.example.com/returnUrl'; @@ -79,7 +84,8 @@ public function testApmWithoutAmount() { * @expectedException \GlobalPayments\Api\Entities\Exceptions\BuilderException * @expectedExceptionMessage currency cannot be null for this transaction type */ - public function testApmWithoutCurrency() { + public function testApmWithoutCurrency() + { $paymentMethod = new AlternativePaymentMethod(AlternativePaymentType::SOFORTUBERWEISUNG); $paymentMethod->returnUrl = 'https://www.example.com/returnUrl'; @@ -88,7 +94,7 @@ public function testApmWithoutCurrency() { $paymentMethod->country = 'DE'; $paymentMethod->accountHolderName = 'James Mason'; - $response = $paymentMethod->charge(10) + $response = $paymentMethod->charge(10) ->withDescription('New APM') ->execute(); } @@ -97,7 +103,8 @@ public function testApmWithoutCurrency() { * @expectedException \GlobalPayments\Api\Entities\Exceptions\BuilderException * @expectedExceptionMessage returnUrl cannot be null for this transaction type */ - public function testApmWithoutReturnUrl() { + public function testApmWithoutReturnUrl() + { $paymentMethod = new AlternativePaymentMethod(AlternativePaymentType::SOFORTUBERWEISUNG); $paymentMethod->statusUpdateUrl = 'https://www.example.com/statusUrl'; @@ -115,7 +122,8 @@ public function testApmWithoutReturnUrl() { * @expectedException \GlobalPayments\Api\Entities\Exceptions\BuilderException * @expectedExceptionMessage statusUpdateUrl cannot be null for this transaction type */ - public function testApmWithoutstatusUpdateUrl() { + public function testApmWithoutstatusUpdateUrl() + { $paymentMethod = new AlternativePaymentMethod(AlternativePaymentType::SOFORTUBERWEISUNG); $paymentMethod->returnUrl = 'https://www.example.com/returnUrl'; @@ -133,7 +141,8 @@ public function testApmWithoutstatusUpdateUrl() { * @expectedException \GlobalPayments\Api\Entities\Exceptions\GatewayException * @expectedExceptionMessage FAILED */ - public function testAPMRefundPendingTransaction() { + public function testAPMRefundPendingTransaction() + { $paymentMethod = new AlternativePaymentMethod(AlternativePaymentType::TEST_PAY); $paymentMethod->returnUrl = 'https://www.example.com/returnUrl'; @@ -152,12 +161,13 @@ public function testAPMRefundPendingTransaction() { // send the settle request, we must specify the amount and currency $response = $response->refund(10) - ->withCurrency("EUR") + ->withCurrency("EUR") ->withAlternativePaymentType(AlternativePaymentType::TEST_PAY) ->execute(); } - public function testApmForRefund() { + public function testApmForRefund() + { // a settle request requires the original order id $orderId = "20180912050207-5b989dcfc9433"; // and the payments reference (pasref) from the authorization response @@ -181,5 +191,4 @@ public function testApmForRefund() { $this->assertNotEquals(null, $response); $this->assertEquals("00", $responseCode); } - } diff --git a/test/Integration/Gateways/Terminals/LogManagement.php b/test/Integration/Gateways/Terminals/LogManagement.php index 198133cb..eea33bc1 100644 --- a/test/Integration/Gateways/Terminals/LogManagement.php +++ b/test/Integration/Gateways/Terminals/LogManagement.php @@ -1,21 +1,21 @@ -logLocation, $message, FILE_APPEND); - } catch (\Exception $e) { - throw new ConfigurationException('Error in log management config: ', $e->getMessage()); - } - } -} +logLocation, $message, FILE_APPEND); + } catch (\Exception $e) { + throw new ConfigurationException('Error in log management config: ', $e->getMessage()); + } + } +} diff --git a/test/Integration/Gateways/Terminals/PAX/PaxAdminTests.php b/test/Integration/Gateways/Terminals/PAX/PaxAdminTests.php index 411911fe..84ddf567 100644 --- a/test/Integration/Gateways/Terminals/PAX/PaxAdminTests.php +++ b/test/Integration/Gateways/Terminals/PAX/PaxAdminTests.php @@ -1,98 +1,98 @@ -device = DeviceService::create($this->getConfig()); - } - - public function tearDown() - { - sleep(3); - } - - protected function getConfig() - { - $config = new ConnectionConfig(); - $config->ipAddress = '192.168.42.37'; - $config->port = '10009'; - $config->deviceType = DeviceType::PAX_S300; - $config->connectionMode = ConnectionModes::TCP_IP; - $config->timeout = 30; - $config->requestIdProvider = new RequestIdProvider(); - - return $config; - } - - public function testIntialize() - { - $response = $this->device->initialize(); - - $this->assertNotNull($response); - $this->assertEquals('OK', $response->deviceResponseText); - $this->assertNotNull($response->serialNumber); - } - - public function testReset() - { - $response = $this->device->reset(); - - $this->assertNotNull($response); - $this->assertEquals('OK', $response->deviceResponseText); - } - - public function testCancel() - { - $this->device->cancel(); - } - - public function testReboot() - { - $this->markTestSkipped('Reboot skipped'); - - $response = $this->device->reboot(); - - $this->assertNotNull($response); - $this->assertEquals('OK', $response->deviceResponseText); - } - - public function testPromptForSignature() - { - $response = $this->device->promptForSignature(); - - $this->assertNotNull($response); - $this->assertEquals('OK', $response->deviceResponseText); - } - - public function testGetSignature() - { - $response = $this->device->getSignatureFile(); - - - $this->assertNotNull($response); - $this->assertEquals('OK', $response->deviceResponseText); - $this->assertNotNull($response->signatureData); - } - - public function testSetSafMode() - { - $response = $this->device->setSafMode(SafMode::STAY_OFFLINE); - - $this->assertNotNull($response); - $this->assertEquals('OK', $response->deviceResponseText); - } -} +device = DeviceService::create($this->getConfig()); + } + + public function tearDown() + { + sleep(3); + } + + protected function getConfig() + { + $config = new ConnectionConfig(); + $config->ipAddress = '192.168.42.219'; + $config->port = '10009'; + $config->deviceType = DeviceType::PAX_S300; + $config->connectionMode = ConnectionModes::TCP_IP; + $config->timeout = 30; + $config->requestIdProvider = new RequestIdProvider(); + + return $config; + } + + public function testIntialize() + { + $response = $this->device->initialize(); + + $this->assertNotNull($response); + $this->assertEquals('OK', $response->deviceResponseText); + $this->assertNotNull($response->serialNumber); + } + + public function testReset() + { + $response = $this->device->reset(); + + $this->assertNotNull($response); + $this->assertEquals('OK', $response->deviceResponseText); + } + + public function testCancel() + { + $this->device->cancel(); + } + + public function testReboot() + { + $this->markTestSkipped('Reboot skipped'); + + $response = $this->device->reboot(); + + $this->assertNotNull($response); + $this->assertEquals('OK', $response->deviceResponseText); + } + + public function testPromptForSignature() + { + $response = $this->device->promptForSignature(); + + $this->assertNotNull($response); + $this->assertEquals('OK', $response->deviceResponseText); + } + + public function testGetSignature() + { + $response = $this->device->getSignatureFile(); + + + $this->assertNotNull($response); + $this->assertEquals('OK', $response->deviceResponseText); + $this->assertNotNull($response->signatureData); + } + + public function testSetSafMode() + { + $response = $this->device->setSafMode(SafMode::STAY_OFFLINE); + + $this->assertNotNull($response); + $this->assertEquals('OK', $response->deviceResponseText); + } +} diff --git a/test/Integration/Gateways/Terminals/PAX/PaxBatchTests.php b/test/Integration/Gateways/Terminals/PAX/PaxBatchTests.php index b8221b97..3281cd2a 100644 --- a/test/Integration/Gateways/Terminals/PAX/PaxBatchTests.php +++ b/test/Integration/Gateways/Terminals/PAX/PaxBatchTests.php @@ -1,74 +1,74 @@ -device = DeviceService::create($this->getConfig()); - } - - public function tearDown() - { - sleep(3); - } - - protected function getConfig() - { - $config = new ConnectionConfig(); - $config->ipAddress = '192.168.42.219'; - $config->port = '10009'; - $config->deviceType = DeviceType::PAX_S300; - $config->connectionMode = ConnectionModes::TCP_IP; - $config->timeout = 30; - $config->requestIdProvider = new RequestIdProvider(); - - return $config; - } - - public function testBatchClose() - { - $response = $this->device->batchClose(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - public function testSafUpload() - { - $response = $this->device->safUpload(SafUpload::ALL_TRANSACTION); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - public function testSafDelete() - { - $response = $this->device->safDelete(SafDelete::DELETE_ALL_SAF_RECORD); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - public function testSafReport() - { - $response = $this->device->safSummaryReport(SafReportSummary::ALL_REPORT); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } -} +device = DeviceService::create($this->getConfig()); + } + + public function tearDown() + { + sleep(3); + } + + protected function getConfig() + { + $config = new ConnectionConfig(); + $config->ipAddress = '192.168.42.219'; + $config->port = '10009'; + $config->deviceType = DeviceType::PAX_S300; + $config->connectionMode = ConnectionModes::TCP_IP; + $config->timeout = 30; + $config->requestIdProvider = new RequestIdProvider(); + + return $config; + } + + public function testBatchClose() + { + $response = $this->device->batchClose(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + public function testSafUpload() + { + $response = $this->device->safUpload(SafUpload::ALL_TRANSACTION); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + public function testSafDelete() + { + $response = $this->device->safDelete(SafDelete::DELETE_ALL_SAF_RECORD); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + public function testSafReport() + { + $response = $this->device->safSummaryReport(SafReportSummary::ALL_REPORT); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } +} diff --git a/test/Integration/Gateways/Terminals/PAX/PaxCreditTests.php b/test/Integration/Gateways/Terminals/PAX/PaxCreditTests.php index 11bfcfb3..faae44cc 100644 --- a/test/Integration/Gateways/Terminals/PAX/PaxCreditTests.php +++ b/test/Integration/Gateways/Terminals/PAX/PaxCreditTests.php @@ -1,339 +1,339 @@ -device = DeviceService::create($this->getConfig()); - - $this->card = new CreditCardData(); - $this->card->number = '4111111111111111'; - $this->card->expMonth = 12; - $this->card->expYear = 2025; - $this->card->cvn = '123'; - $this->card->cardHolderName = 'Joe Smith'; - - $this->address = new Address(); - $this->address->streetAddress1 = '123 Main St.'; - $this->address->postalCode = '12345'; - } - - public function tearDown() - { - sleep(3); - } - - protected function getConfig() - { - $config = new ConnectionConfig(); - $config->ipAddress = '192.168.42.37'; - $config->port = '10009'; - $config->deviceType = DeviceType::PAX_S300; - $config->connectionMode = ConnectionModes::TCP_IP; - $config->timeout = 10; - $config->requestIdProvider = new RequestIdProvider(); - - return $config; - } - - public function testCreditSale() - { - $response = $this->device->creditSale(10) - ->withAllowDuplicates(1) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->deviceResponseCode); - } - - public function testCreditSaleManual() - { - $response = $this->device->creditSale(10) - ->withPaymentMethod($this->card) - ->withAddress($this->address) - ->withAllowDuplicates(1) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->deviceResponseCode); - $this->assertNotNull($response->transactionId); - } - - public function testCreditSaleWithSignatureCapture() - { - $response = $this->device->creditSale(20) - ->withPaymentMethod($this->card) - ->withAddress($this->address) - ->withSignatureCapture(1) - ->withAllowDuplicates(1) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->deviceResponseCode); - $this->assertNotNull($response->transactionId); - } - - public function testCreditAuth() - { - $response = $this->device->creditAuth(10) - ->withAllowDuplicates(1) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->deviceResponseCode); - $this->assertNotNull($response->transactionId); - - $captureResponse = $this->device->creditCapture(10) - ->withTransactionId($response->transactionId) - ->execute(); - - $this->assertNotNull($captureResponse); - $this->assertEquals('00', $captureResponse->deviceResponseCode); - $this->assertNotNull($captureResponse->transactionId); - } - - public function testCreditAuthManual() - { - $response = $this->device->creditAuth(10) - ->withAllowDuplicates(1) - ->withPaymentMethod($this->card) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->deviceResponseCode); - $this->assertNotNull($response->transactionId); - - $captureResponse = $this->device->creditCapture(10) - ->withTransactionId($response->transactionId) - ->execute(); - - $this->assertNotNull($captureResponse); - $this->assertEquals('00', $captureResponse->deviceResponseCode); - $this->assertNotNull($captureResponse->transactionId); - } - - public function testCreditRefund() - { - - $response = $this->device->creditSale(10) - ->withPaymentMethod($this->card) - ->withAllowDuplicates(1) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->deviceResponseCode); - $this->assertNotNull($response->transactionId); - - $refundResponse = $this->device->creditRefund(10) - ->withTransactionId($response->transactionId) - ->execute(); - - $this->assertNotNull($refundResponse); - $this->assertEquals('00', $refundResponse->deviceResponseCode); - } - - public function testSaleRefund() - { - - $response = $this->device->creditSale(10) - ->withAllowDuplicates(1) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->deviceResponseCode); - $this->assertNotNull($response->transactionId); - - $refundResponse = $this->device->creditRefund(10) - ->withTransactionId($response->transactionId) - ->execute(); - - $this->assertNotNull($refundResponse); - $this->assertEquals('00', $refundResponse->deviceResponseCode); - } - - public function testRefundByCard() - { - $response = $this->device->creditRefund(8) - ->withPaymentMethod($this->card) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->deviceResponseCode); - } - - public function testCreditVerify() - { - $response = $this->device->creditVerify() - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->deviceResponseCode); - } - - public function testCreditVerifyManual() - { - $response = $this->device->creditVerify() - ->withPaymentMethod($this->card) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->deviceResponseCode); - } - - public function testTokenize() - { - $response = $this->device->creditVerify() - ->withRequestMultiUseToken(1) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->deviceResponseCode); - $this->assertNotNull($response->token); - } - - public function testCreditVoid() - { - $response = $this->device->creditSale(10) - ->withPaymentMethod($this->card) - ->withAllowDuplicates(1) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->deviceResponseCode); - $this->assertNotNull($response->transactionId); - - $refundResponse = $this->device->creditVoid() - ->withTransactionId($response->transactionId) - ->execute(); - - $this->assertNotNull($refundResponse); - $this->assertEquals('00', $refundResponse->deviceResponseCode); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException - * @expectedExceptionMessage amount cannot be null for this transaction type - */ - public function testAuthNoAmount() - { - $response = $this->device->creditAuth() - ->withPaymentMethod($this->card) - ->execute(); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException - * @expectedExceptionMessage transactionId cannot be null for this transaction type - */ - public function testCaptureNoTransactionId() - { - $response = $this->device->creditCapture(10) - ->execute(); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException - * @expectedExceptionMessage amount cannot be null for this transaction type - */ - public function testRefundNoAmount() - { - $response = $this->device->creditRefund() - ->execute(); - } - - /* - * Note: EMV cards needs to be used for this test case - */ - public function testCreditSaleEMV() - { - $response = $this->device->creditSale(10) - ->withAllowDuplicates(1) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->deviceResponseCode); - - //EMV - $this->assertNotNull($response->applicationPreferredName); - $this->assertNotNull($response->applicationLabel); - $this->assertNotNull($response->applicationId); - $this->assertNotNull($response->applicationCryptogramType); - $this->assertNotNull($response->applicationCryptogram); - $this->assertNotNull($response->customerVerificationMethod); - $this->assertNotNull($response->terminalVerificationResults); - } - - public function testCreditSaleManualSSL() - { - $config = new ConnectionConfig(); - $config->ipAddress = '192.168.42.219'; - $config->port = '10009'; - $config->deviceType = DeviceType::PAX_S300; - $config->connectionMode = ConnectionModes::SSL_TCP; - $config->timeout = 10; - $config->requestIdProvider = new RequestIdProvider(); - - $device = DeviceService::create($config); - - $response = $device->creditSale(10) - ->withPaymentMethod($this->card) - ->withAllowDuplicates(1) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->deviceResponseCode); - $this->assertNotNull($response->transactionId); - } - - public function testCreditSaleManualHTTPS() - { - $config = new ConnectionConfig(); - $config->ipAddress = '192.168.42.219'; - $config->port = '10009'; - $config->deviceType = DeviceType::PAX_S300; - $config->connectionMode = ConnectionModes::HTTPS; - $config->timeout = 10; - $config->requestIdProvider = new RequestIdProvider(); - - $device = DeviceService::create($config); - - $response = $device->creditSale(10) - ->withPaymentMethod($this->card) - ->withAllowDuplicates(1) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->deviceResponseCode); - $this->assertNotNull($response->transactionId); - } - - public function testCreditSaleWithMerchantFee() - { - $this->markTestSkipped('Merchant fee needs to be enabled in the device for this test case'); - $response = $this->device->creditSale(10) - ->withAllowDuplicates(1) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('OK', $response->deviceResponseText); - $this->assertNotNull($response->merchantFee); - } -} +device = DeviceService::create($this->getConfig()); + + $this->card = new CreditCardData(); + $this->card->number = '4111111111111111'; + $this->card->expMonth = 12; + $this->card->expYear = 2025; + $this->card->cvn = '123'; + $this->card->cardHolderName = 'Joe Smith'; + + $this->address = new Address(); + $this->address->streetAddress1 = '123 Main St.'; + $this->address->postalCode = '12345'; + } + + public function tearDown() + { + sleep(3); + } + + protected function getConfig() + { + $config = new ConnectionConfig(); + $config->ipAddress = '192.168.42.219'; + $config->port = '10009'; + $config->deviceType = DeviceType::PAX_S300; + $config->connectionMode = ConnectionModes::TCP_IP; + $config->timeout = 10; + $config->requestIdProvider = new RequestIdProvider(); + + return $config; + } + + public function testCreditSale() + { + $response = $this->device->creditSale(10) + ->withAllowDuplicates(1) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->deviceResponseCode); + } + + public function testCreditSaleManual() + { + $response = $this->device->creditSale(10) + ->withPaymentMethod($this->card) + ->withAddress($this->address) + ->withAllowDuplicates(1) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->deviceResponseCode); + $this->assertNotNull($response->transactionId); + } + + public function testCreditSaleWithSignatureCapture() + { + $response = $this->device->creditSale(20) + ->withPaymentMethod($this->card) + ->withAddress($this->address) + ->withSignatureCapture(1) + ->withAllowDuplicates(1) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->deviceResponseCode); + $this->assertNotNull($response->transactionId); + } + + public function testCreditAuth() + { + $response = $this->device->creditAuth(10) + ->withAllowDuplicates(1) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->deviceResponseCode); + $this->assertNotNull($response->transactionId); + + $captureResponse = $this->device->creditCapture(10) + ->withTransactionId($response->transactionId) + ->execute(); + + $this->assertNotNull($captureResponse); + $this->assertEquals('00', $captureResponse->deviceResponseCode); + $this->assertNotNull($captureResponse->transactionId); + } + + public function testCreditAuthManual() + { + $response = $this->device->creditAuth(10) + ->withAllowDuplicates(1) + ->withPaymentMethod($this->card) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->deviceResponseCode); + $this->assertNotNull($response->transactionId); + + $captureResponse = $this->device->creditCapture(10) + ->withTransactionId($response->transactionId) + ->execute(); + + $this->assertNotNull($captureResponse); + $this->assertEquals('00', $captureResponse->deviceResponseCode); + $this->assertNotNull($captureResponse->transactionId); + } + + public function testCreditRefund() + { + + $response = $this->device->creditSale(10) + ->withPaymentMethod($this->card) + ->withAllowDuplicates(1) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->deviceResponseCode); + $this->assertNotNull($response->transactionId); + + $refundResponse = $this->device->creditRefund(10) + ->withTransactionId($response->transactionId) + ->execute(); + + $this->assertNotNull($refundResponse); + $this->assertEquals('00', $refundResponse->deviceResponseCode); + } + + public function testSaleRefund() + { + + $response = $this->device->creditSale(10) + ->withAllowDuplicates(1) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->deviceResponseCode); + $this->assertNotNull($response->transactionId); + + $refundResponse = $this->device->creditRefund(10) + ->withTransactionId($response->transactionId) + ->execute(); + + $this->assertNotNull($refundResponse); + $this->assertEquals('00', $refundResponse->deviceResponseCode); + } + + public function testRefundByCard() + { + $response = $this->device->creditRefund(8) + ->withPaymentMethod($this->card) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->deviceResponseCode); + } + + public function testCreditVerify() + { + $response = $this->device->creditVerify() + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->deviceResponseCode); + } + + public function testCreditVerifyManual() + { + $response = $this->device->creditVerify() + ->withPaymentMethod($this->card) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->deviceResponseCode); + } + + public function testTokenize() + { + $response = $this->device->creditVerify() + ->withRequestMultiUseToken(1) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->deviceResponseCode); + $this->assertNotNull($response->token); + } + + public function testCreditVoid() + { + $response = $this->device->creditSale(10) + ->withPaymentMethod($this->card) + ->withAllowDuplicates(1) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->deviceResponseCode); + $this->assertNotNull($response->transactionId); + + $refundResponse = $this->device->creditVoid() + ->withTransactionId($response->transactionId) + ->execute(); + + $this->assertNotNull($refundResponse); + $this->assertEquals('00', $refundResponse->deviceResponseCode); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException + * @expectedExceptionMessage amount cannot be null for this transaction type + */ + public function testAuthNoAmount() + { + $response = $this->device->creditAuth() + ->withPaymentMethod($this->card) + ->execute(); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException + * @expectedExceptionMessage transactionId cannot be null for this transaction type + */ + public function testCaptureNoTransactionId() + { + $response = $this->device->creditCapture(10) + ->execute(); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException + * @expectedExceptionMessage amount cannot be null for this transaction type + */ + public function testRefundNoAmount() + { + $response = $this->device->creditRefund() + ->execute(); + } + + /* + * Note: EMV cards needs to be used for this test case + */ + public function testCreditSaleEMV() + { + $response = $this->device->creditSale(10) + ->withAllowDuplicates(1) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->deviceResponseCode); + + //EMV + $this->assertNotNull($response->applicationPreferredName); + $this->assertNotNull($response->applicationLabel); + $this->assertNotNull($response->applicationId); + $this->assertNotNull($response->applicationCryptogramType); + $this->assertNotNull($response->applicationCryptogram); + $this->assertNotNull($response->customerVerificationMethod); + $this->assertNotNull($response->terminalVerificationResults); + } + + public function testCreditSaleManualSSL() + { + $config = new ConnectionConfig(); + $config->ipAddress = '192.168.42.219'; + $config->port = '10009'; + $config->deviceType = DeviceType::PAX_S300; + $config->connectionMode = ConnectionModes::SSL_TCP; + $config->timeout = 10; + $config->requestIdProvider = new RequestIdProvider(); + + $device = DeviceService::create($config); + + $response = $device->creditSale(10) + ->withPaymentMethod($this->card) + ->withAllowDuplicates(1) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->deviceResponseCode); + $this->assertNotNull($response->transactionId); + } + + public function testCreditSaleManualHTTPS() + { + $config = new ConnectionConfig(); + $config->ipAddress = '192.168.42.219'; + $config->port = '10009'; + $config->deviceType = DeviceType::PAX_S300; + $config->connectionMode = ConnectionModes::HTTPS; + $config->timeout = 10; + $config->requestIdProvider = new RequestIdProvider(); + + $device = DeviceService::create($config); + + $response = $device->creditSale(10) + ->withPaymentMethod($this->card) + ->withAllowDuplicates(1) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->deviceResponseCode); + $this->assertNotNull($response->transactionId); + } + + public function testCreditSaleWithMerchantFee() + { + $this->markTestSkipped('Merchant fee needs to be enabled in the device for this test case'); + $response = $this->device->creditSale(10) + ->withAllowDuplicates(1) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('OK', $response->deviceResponseText); + $this->assertNotNull($response->merchantFee); + } +} diff --git a/test/Integration/Gateways/Terminals/PAX/PaxDebitTests.php b/test/Integration/Gateways/Terminals/PAX/PaxDebitTests.php index 9ac4b565..f07eb5ac 100644 --- a/test/Integration/Gateways/Terminals/PAX/PaxDebitTests.php +++ b/test/Integration/Gateways/Terminals/PAX/PaxDebitTests.php @@ -1,78 +1,78 @@ -device = DeviceService::create($this->getConfig()); - } - - public function tearDown() - { - sleep(3); - } - - protected function getConfig() - { - $config = new ConnectionConfig(); - $config->ipAddress = '192.168.42.219'; - $config->port = '10009'; - $config->deviceType = DeviceType::PAX_S300; - $config->connectionMode = ConnectionModes::TCP_IP; - $config->timeout = 30; - $config->requestIdProvider = new RequestIdProvider(); - - return $config; - } - - public function testDebitSale() - { - $response = $this->device->debitSale(10) - ->withAllowDuplicates(1) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('OK', $response->deviceResponseText); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException - * @expectedExceptionMessage amount cannot be null for this transaction type - */ - public function testSaleNoAmount() - { - $response = $this->device->debitSale() - ->execute(); - } - - public function testDebitRefund() - { - $response = $this->device->debitSale(10) - ->withAllowDuplicates(1) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('OK', $response->deviceResponseText); - $this->assertNotNull($response->transactionId); - - $refundResponse = $this->device->debitRefund(10) - ->withTransactionId($response->transactionId) - ->execute(); - - $this->assertNotNull($refundResponse); - $this->assertEquals('OK', $refundResponse->deviceResponseText); - } -} +device = DeviceService::create($this->getConfig()); + } + + public function tearDown() + { + sleep(3); + } + + protected function getConfig() + { + $config = new ConnectionConfig(); + $config->ipAddress = '192.168.42.219'; + $config->port = '10009'; + $config->deviceType = DeviceType::PAX_S300; + $config->connectionMode = ConnectionModes::TCP_IP; + $config->timeout = 30; + $config->requestIdProvider = new RequestIdProvider(); + + return $config; + } + + public function testDebitSale() + { + $response = $this->device->debitSale(10) + ->withAllowDuplicates(1) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('OK', $response->deviceResponseText); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException + * @expectedExceptionMessage amount cannot be null for this transaction type + */ + public function testSaleNoAmount() + { + $response = $this->device->debitSale() + ->execute(); + } + + public function testDebitRefund() + { + $response = $this->device->debitSale(10) + ->withAllowDuplicates(1) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('OK', $response->deviceResponseText); + $this->assertNotNull($response->transactionId); + + $refundResponse = $this->device->debitRefund(10) + ->withTransactionId($response->transactionId) + ->execute(); + + $this->assertNotNull($refundResponse); + $this->assertEquals('OK', $refundResponse->deviceResponseText); + } +} diff --git a/test/Integration/Gateways/Terminals/PAX/PaxEBTTests.php b/test/Integration/Gateways/Terminals/PAX/PaxEBTTests.php index d7f6caa5..f5bcd238 100644 --- a/test/Integration/Gateways/Terminals/PAX/PaxEBTTests.php +++ b/test/Integration/Gateways/Terminals/PAX/PaxEBTTests.php @@ -1,149 +1,149 @@ -device = DeviceService::create($this->getConfig()); - } - - public function tearDown() - { - sleep(3); - } - - protected function getConfig() - { - $config = new ConnectionConfig(); - $config->ipAddress = '192.168.42.219'; - $config->port = '10009'; - $config->deviceType = DeviceType::PAX_S300; - $config->connectionMode = ConnectionModes::TCP_IP; - $config->timeout = 30; - $config->requestIdProvider = new RequestIdProvider(); - - return $config; - } - - public function testEbtFoodstampPurchase() - { - $response = $this->device->ebtPurchase(10) - ->withCurrency(CurrencyType::FOODSTAMPS) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - $this->assertEquals('F', $response->ebtType); - } - - public function testEbtCashBenefitPurchase() - { - $response = $this->device->ebtPurchase(10) - ->withCurrency(CurrencyType::CASH_BENEFITS) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - $this->assertEquals('C', $response->ebtType); - } - - public function testEbtVoucherPurchase() - { - $response = $this->device->ebtPurchase(10) - ->withCurrency(CurrencyType::VOUCHER) - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - public function testEbtFoodstampBalanceInquiry() - { - $response = $this->device->ebtBalance() - ->withCurrency(CurrencyType::FOODSTAMPS) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - public function testEbtCashBenefitsBalanceInquiry() - { - $response = $this->device->ebtBalance() - ->withCurrency(CurrencyType::CASH_BENEFITS) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException - * @expectedExceptionMessage Property `currency`is equal to the expected value `VOUCHER` - */ - public function testEbtBalanceInquiryWithVoucher() - { - $this->device->ebtBalance() - ->withCurrency(CurrencyType::VOUCHER) - ->execute(); - } - - public function testEbtFoodStampRefund() - { - $response = $this->device->ebtRefund(10) - ->withCurrency(CurrencyType::FOODSTAMPS) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - public function testEbtCashBenefitRefund() - { - $response = $this->device->ebtRefund(10) - ->withCurrency(CurrencyType::FOODSTAMPS) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException - * @expectedExceptionMessage amount cannot be null for this transaction type - */ - public function testEbtRefundAllowDup() - { - $this->device->ebtRefund() - ->withAllowDuplicates(true) - ->execute(); - } - - public function testEbtCashBenefitWithdrawal() - { - $response = $this->device->ebtWithdrawl(10) - ->withCurrency(CurrencyType::CASH_BENEFITS) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException - * @expectedExceptionMessage currency cannot be null for this transaction type - */ - public function testEbtBenefitWithdrawalAllowDup() - { - $this->device->ebtWithdrawl(10) - ->withAllowDuplicates(true) - ->execute(); - } -} +device = DeviceService::create($this->getConfig()); + } + + public function tearDown() + { + sleep(3); + } + + protected function getConfig() + { + $config = new ConnectionConfig(); + $config->ipAddress = '192.168.42.219'; + $config->port = '10009'; + $config->deviceType = DeviceType::PAX_S300; + $config->connectionMode = ConnectionModes::TCP_IP; + $config->timeout = 30; + $config->requestIdProvider = new RequestIdProvider(); + + return $config; + } + + public function testEbtFoodstampPurchase() + { + $response = $this->device->ebtPurchase(10) + ->withCurrency(CurrencyType::FOODSTAMPS) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + $this->assertEquals('F', $response->ebtType); + } + + public function testEbtCashBenefitPurchase() + { + $response = $this->device->ebtPurchase(10) + ->withCurrency(CurrencyType::CASH_BENEFITS) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + $this->assertEquals('C', $response->ebtType); + } + + public function testEbtVoucherPurchase() + { + $response = $this->device->ebtPurchase(10) + ->withCurrency(CurrencyType::VOUCHER) + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + public function testEbtFoodstampBalanceInquiry() + { + $response = $this->device->ebtBalance() + ->withCurrency(CurrencyType::FOODSTAMPS) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + public function testEbtCashBenefitsBalanceInquiry() + { + $response = $this->device->ebtBalance() + ->withCurrency(CurrencyType::CASH_BENEFITS) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException + * @expectedExceptionMessage Property `currency`is equal to the expected value `VOUCHER` + */ + public function testEbtBalanceInquiryWithVoucher() + { + $this->device->ebtBalance() + ->withCurrency(CurrencyType::VOUCHER) + ->execute(); + } + + public function testEbtFoodStampRefund() + { + $response = $this->device->ebtRefund(10) + ->withCurrency(CurrencyType::FOODSTAMPS) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + public function testEbtCashBenefitRefund() + { + $response = $this->device->ebtRefund(10) + ->withCurrency(CurrencyType::FOODSTAMPS) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException + * @expectedExceptionMessage amount cannot be null for this transaction type + */ + public function testEbtRefundAllowDup() + { + $this->device->ebtRefund() + ->withAllowDuplicates(true) + ->execute(); + } + + public function testEbtCashBenefitWithdrawal() + { + $response = $this->device->ebtWithdrawl(10) + ->withCurrency(CurrencyType::CASH_BENEFITS) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException + * @expectedExceptionMessage currency cannot be null for this transaction type + */ + public function testEbtBenefitWithdrawalAllowDup() + { + $this->device->ebtWithdrawl(10) + ->withAllowDuplicates(true) + ->execute(); + } +} diff --git a/test/Integration/Gateways/Terminals/PAX/PaxGiftTests.php b/test/Integration/Gateways/Terminals/PAX/PaxGiftTests.php index d4fac77b..7fe44398 100644 --- a/test/Integration/Gateways/Terminals/PAX/PaxGiftTests.php +++ b/test/Integration/Gateways/Terminals/PAX/PaxGiftTests.php @@ -1,174 +1,174 @@ -device = DeviceService::create($this->getConfig()); - } - - public function tearDown() - { - sleep(3); - } - - protected function getConfig() - { - $config = new ConnectionConfig(); - $config->ipAddress = '192.168.42.219'; - $config->port = '10009'; - $config->deviceType = DeviceType::PAX_S300; - $config->connectionMode = ConnectionModes::TCP_IP; - $config->timeout = 30; - $config->requestIdProvider = new RequestIdProvider(); - - $this->card = new GiftCard(); - $this->card->number = '5022440000000000098'; - - return $config; - } - - public function testGiftSale() - { - $response = $this->device->giftSale(100) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - public function testGiftSaleManual() - { - $response = $this->device->giftSale(10) - ->withPaymentMethod($this->card) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - public function testGiftSaleWithInvoice() - { - $response = $this->device->giftSale(100) - ->withPaymentMethod($this->card) - ->withInvoiceNumber(123) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException - * @expectedExceptionMessage amount cannot be null for this transaction type - */ - public function testSaleNoAmount() - { - $response = $this->device->giftSale() - ->withPaymentMethod($this->card) - ->execute(); - } - - public function testGiftAddValue() - { - $response = $this->device->giftAddValue(100) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - public function testGiftAddValueManual() - { - $response = $this->device->giftAddValue(100) - ->withPaymentMethod($this->card) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - public function testLoyaltySaleManual() - { - $response = $this->device->giftSale(100) - ->withPaymentMethod($this->card) - ->withCurrency(CurrencyType::POINTS) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - public function testGiftVoidManual() - { - $response = $this->device->giftSale(100) - ->withPaymentMethod($this->card) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - - $voidResponse = $this->device->giftVoid() - ->withTransactionId($response->transactionId) - ->execute(); - - $this->assertNotNull($voidResponse); - $this->assertEquals("00", $voidResponse->deviceResponseCode); - } - - public function testGiftBalance() - { - $response = $this->device->giftBalance() - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - public function testGiftBalanceManual() - { - $response = $this->device->giftBalance() - ->withPaymentMethod($this->card) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - public function testLoyaltyBalance() - { - $response = $this->device->giftBalance() - ->withCurrency(CurrencyType::POINTS) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - public function testLoyaltyBalanceManual() - { - $response = $this->device->giftBalance() - ->withPaymentMethod($this->card) - ->withCurrency(CurrencyType::POINTS) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } -} +device = DeviceService::create($this->getConfig()); + } + + public function tearDown() + { + sleep(3); + } + + protected function getConfig() + { + $config = new ConnectionConfig(); + $config->ipAddress = '192.168.42.219'; + $config->port = '10009'; + $config->deviceType = DeviceType::PAX_S300; + $config->connectionMode = ConnectionModes::TCP_IP; + $config->timeout = 30; + $config->requestIdProvider = new RequestIdProvider(); + + $this->card = new GiftCard(); + $this->card->number = '5022440000000000098'; + + return $config; + } + + public function testGiftSale() + { + $response = $this->device->giftSale(100) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + public function testGiftSaleManual() + { + $response = $this->device->giftSale(10) + ->withPaymentMethod($this->card) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + public function testGiftSaleWithInvoice() + { + $response = $this->device->giftSale(100) + ->withPaymentMethod($this->card) + ->withInvoiceNumber(123) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException + * @expectedExceptionMessage amount cannot be null for this transaction type + */ + public function testSaleNoAmount() + { + $response = $this->device->giftSale() + ->withPaymentMethod($this->card) + ->execute(); + } + + public function testGiftAddValue() + { + $response = $this->device->giftAddValue(100) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + public function testGiftAddValueManual() + { + $response = $this->device->giftAddValue(100) + ->withPaymentMethod($this->card) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + public function testLoyaltySaleManual() + { + $response = $this->device->giftSale(100) + ->withPaymentMethod($this->card) + ->withCurrency(CurrencyType::POINTS) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + public function testGiftVoidManual() + { + $response = $this->device->giftSale(100) + ->withPaymentMethod($this->card) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + + $voidResponse = $this->device->giftVoid() + ->withTransactionId($response->transactionId) + ->execute(); + + $this->assertNotNull($voidResponse); + $this->assertEquals("00", $voidResponse->deviceResponseCode); + } + + public function testGiftBalance() + { + $response = $this->device->giftBalance() + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + public function testGiftBalanceManual() + { + $response = $this->device->giftBalance() + ->withPaymentMethod($this->card) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + public function testLoyaltyBalance() + { + $response = $this->device->giftBalance() + ->withCurrency(CurrencyType::POINTS) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + public function testLoyaltyBalanceManual() + { + $response = $this->device->giftBalance() + ->withPaymentMethod($this->card) + ->withCurrency(CurrencyType::POINTS) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } +} diff --git a/test/Integration/Gateways/Terminals/PAX/PaxLevel2Tests.php b/test/Integration/Gateways/Terminals/PAX/PaxLevel2Tests.php index 239ebf3d..5f088bff 100644 --- a/test/Integration/Gateways/Terminals/PAX/PaxLevel2Tests.php +++ b/test/Integration/Gateways/Terminals/PAX/PaxLevel2Tests.php @@ -1,105 +1,105 @@ -device = DeviceService::create($this->getConfig()); - } - - public function tearDown() - { - sleep(3); - } - - protected function getConfig() - { - $config = new ConnectionConfig(); - $config->ipAddress = '192.168.42.219'; - $config->port = '10009'; - $config->deviceType = DeviceType::PAX_S300; - $config->connectionMode = ConnectionModes::TCP_IP; - $config->timeout = 30; - $config->requestIdProvider = new RequestIdProvider(); - - return $config; - } - - // PoNumber - public function testCheckPoNumber() - { - $response = $this->device->creditSale(10) - ->withPoNumber("123456789") - ->execute(); - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - // CustomerCode - public function testCheckCustomerCode() - { - $response = $this->device->creditSale(11) - ->withCustomerCode("123456789") - ->withTaxAmount(1.22) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - // TaxExempt - public function testCheckTaxExcemptTrue() - { - $response = $this->device->creditSale(12) - ->withCustomerCode("123456789") - ->withTaxType(TaxType::TAX_EXEMPT) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - public function testCheckTaxExcemptFalse() - { - $response = $this->device->creditSale(13) - ->withTaxAmount(1.22) - ->withCustomerCode("987654321") - ->withTaxType(TaxType::SALES_TAX) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - // TaxExemptId - public function testCheckTaxExemptId() - { - $response = $this->device->creditSale(14) - ->withCustomerCode("987654321") - ->withTaxType(TaxType::TAX_EXEMPT, "987654321") - ->execute(); - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - // All fields - public function testcheckAllFields() - { - $response = $this->device->creditSale(15) - ->withPoNumber("123456789") - ->withCustomerCode("8675309") - ->withTaxType(TaxType::TAX_EXEMPT, "987654321") - ->execute(); - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } -} +device = DeviceService::create($this->getConfig()); + } + + public function tearDown() + { + sleep(3); + } + + protected function getConfig() + { + $config = new ConnectionConfig(); + $config->ipAddress = '192.168.42.219'; + $config->port = '10009'; + $config->deviceType = DeviceType::PAX_S300; + $config->connectionMode = ConnectionModes::TCP_IP; + $config->timeout = 30; + $config->requestIdProvider = new RequestIdProvider(); + + return $config; + } + + // PoNumber + public function testCheckPoNumber() + { + $response = $this->device->creditSale(10) + ->withPoNumber("123456789") + ->execute(); + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + // CustomerCode + public function testCheckCustomerCode() + { + $response = $this->device->creditSale(11) + ->withCustomerCode("123456789") + ->withTaxAmount(1.22) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + // TaxExempt + public function testCheckTaxExcemptTrue() + { + $response = $this->device->creditSale(12) + ->withCustomerCode("123456789") + ->withTaxType(TaxType::TAX_EXEMPT) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + public function testCheckTaxExcemptFalse() + { + $response = $this->device->creditSale(13) + ->withTaxAmount(1.22) + ->withCustomerCode("987654321") + ->withTaxType(TaxType::SALES_TAX) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + // TaxExemptId + public function testCheckTaxExemptId() + { + $response = $this->device->creditSale(14) + ->withCustomerCode("987654321") + ->withTaxType(TaxType::TAX_EXEMPT, "987654321") + ->execute(); + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + // All fields + public function testcheckAllFields() + { + $response = $this->device->creditSale(15) + ->withPoNumber("123456789") + ->withCustomerCode("8675309") + ->withTaxType(TaxType::TAX_EXEMPT, "987654321") + ->execute(); + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } +} diff --git a/test/Integration/Gateways/Terminals/PAX/PaxReportTests.php b/test/Integration/Gateways/Terminals/PAX/PaxReportTests.php index 209a0e27..ff380a80 100644 --- a/test/Integration/Gateways/Terminals/PAX/PaxReportTests.php +++ b/test/Integration/Gateways/Terminals/PAX/PaxReportTests.php @@ -1,155 +1,155 @@ -device = DeviceService::create($this->getConfig()); - - $card = new CreditCardData(); - $card->number = '4111111111111111'; - $card->expMonth = 12; - $card->expYear = 2025; - $card->cvn = '123'; - $card->cardHolderName = 'Joe Smith'; - - $response = $this->device->creditSale(10) - ->withPaymentMethod($card) - ->withAllowDuplicates(1) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - - $this->transactionNumber = $response->transactionNumber; - $this->authCode = $response->authorizationCode; - $this->referenceNumber = $response->referenceNumber; - } - - public function tearDown() - { - sleep(3); - } - - protected function getConfig() - { - $config = new ConnectionConfig(); - $config->ipAddress = '192.168.42.219'; - $config->port = '10009'; - $config->deviceType = DeviceType::PAX_S300; - $config->connectionMode = ConnectionModes::TCP_IP; - $config->timeout = 30; - $config->requestIdProvider = new RequestIdProvider(); - - return $config; - } - - public function testReportRecordNumber() - { - $response = $this->device->localDetailReport() - ->where(PaxSearchCriteria::RECORD_NUMBER, 01) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - $this->assertEquals(1, $response->reportRecordNumber); - } - - public function testReportReferenceNumber() - { - $response = $this->device->localDetailReport() - ->where(PaxSearchCriteria::REFERENCE_NUMBER, $this->referenceNumber) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - $this->assertEquals($this->referenceNumber, $response->referenceNumber); - $this->assertEquals($this->transactionNumber, $response->transactionNumber); - } - - public function testReportTerminalReferenceNumber() - { - $response = $this->device->localDetailReport() - ->where(PaxSearchCriteria::TERMINAL_REFERENCE_NUMBER, $this->transactionNumber) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - $this->assertEquals($this->referenceNumber, $response->referenceNumber); - $this->assertEquals($this->transactionNumber, $response->transactionNumber); - } - - public function testReportTransactionType() - { - $response = $this->device->localDetailReport() - ->where(PaxSearchCriteria::TRANSACTION_TYPE, TerminalTransactionType::SALE) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - $this->assertEquals('SALE', $response->transactionType); - } - - public function testReportAuthCode() - { - $response = $this->device->localDetailReport() - ->where(PaxSearchCriteria::AUTH_CODE, $this->authCode) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - $this->assertEquals($this->authCode, $response->authorizationCode); - } - - public function testReportCardType() - { - - $response = $this->device->localDetailReport() - ->where(PaxSearchCriteria::CARD_TYPE, TerminalCardType::VISA) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - $this->assertEquals('VISA', $response->paymentType); - } - - public function testReportMerchantId() - { - $response = $this->device->localDetailReport() - ->where(PaxSearchCriteria::MERCHANT_ID, 12345) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - public function testReportMerchantName() - { - $response = $this->device->localDetailReport() - ->where(PaxSearchCriteria::MERCHANT_NAME, "CAS") - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } -} +device = DeviceService::create($this->getConfig()); + + $card = new CreditCardData(); + $card->number = '4111111111111111'; + $card->expMonth = 12; + $card->expYear = 2025; + $card->cvn = '123'; + $card->cardHolderName = 'Joe Smith'; + + $response = $this->device->creditSale(10) + ->withPaymentMethod($card) + ->withAllowDuplicates(1) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + + $this->transactionNumber = $response->transactionNumber; + $this->authCode = $response->authorizationCode; + $this->referenceNumber = $response->referenceNumber; + } + + public function tearDown() + { + sleep(3); + } + + protected function getConfig() + { + $config = new ConnectionConfig(); + $config->ipAddress = '192.168.42.219'; + $config->port = '10009'; + $config->deviceType = DeviceType::PAX_S300; + $config->connectionMode = ConnectionModes::TCP_IP; + $config->timeout = 30; + $config->requestIdProvider = new RequestIdProvider(); + + return $config; + } + + public function testReportRecordNumber() + { + $response = $this->device->localDetailReport() + ->where(PaxSearchCriteria::RECORD_NUMBER, 01) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + $this->assertEquals(1, $response->reportRecordNumber); + } + + public function testReportReferenceNumber() + { + $response = $this->device->localDetailReport() + ->where(PaxSearchCriteria::REFERENCE_NUMBER, $this->referenceNumber) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + $this->assertEquals($this->referenceNumber, $response->referenceNumber); + $this->assertEquals($this->transactionNumber, $response->transactionNumber); + } + + public function testReportTerminalReferenceNumber() + { + $response = $this->device->localDetailReport() + ->where(PaxSearchCriteria::TERMINAL_REFERENCE_NUMBER, $this->transactionNumber) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + $this->assertEquals($this->referenceNumber, $response->referenceNumber); + $this->assertEquals($this->transactionNumber, $response->transactionNumber); + } + + public function testReportTransactionType() + { + $response = $this->device->localDetailReport() + ->where(PaxSearchCriteria::TRANSACTION_TYPE, TerminalTransactionType::SALE) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + $this->assertEquals('SALE', $response->transactionType); + } + + public function testReportAuthCode() + { + $response = $this->device->localDetailReport() + ->where(PaxSearchCriteria::AUTH_CODE, $this->authCode) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + $this->assertEquals($this->authCode, $response->authorizationCode); + } + + public function testReportCardType() + { + + $response = $this->device->localDetailReport() + ->where(PaxSearchCriteria::CARD_TYPE, TerminalCardType::VISA) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + $this->assertEquals('VISA', $response->paymentType); + } + + public function testReportMerchantId() + { + $response = $this->device->localDetailReport() + ->where(PaxSearchCriteria::MERCHANT_ID, 12345) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + public function testReportMerchantName() + { + $response = $this->device->localDetailReport() + ->where(PaxSearchCriteria::MERCHANT_NAME, "CAS") + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } +} diff --git a/test/Integration/Gateways/Terminals/PAX/vrf/PaxVerificationTests.php b/test/Integration/Gateways/Terminals/PAX/vrf/PaxVerificationTests.php index a3594e24..b2d00118 100644 --- a/test/Integration/Gateways/Terminals/PAX/vrf/PaxVerificationTests.php +++ b/test/Integration/Gateways/Terminals/PAX/vrf/PaxVerificationTests.php @@ -1,946 +1,946 @@ -device = DeviceService::create($this->getConfig()); - - $this->card = new CreditCardData(); - $this->card->number = '5473500000000014'; - $this->card->expMonth = 12; - $this->card->expYear = 2025; - $this->card->cvn = '123'; - $this->card->cardHolderName = 'Joe Smith'; - - $this->address = new Address(); - $this->address->streetAddress1 = '6860 Dallas Pkwy'; - $this->address->postalCode = '76321'; - } - - public function tearDown() - { - sleep(3); - } - - protected function getConfig() - { - $this->config = new ConnectionConfig(); - $this->config->ipAddress = '192.168.42.37'; - $this->config->port = '10009'; - $this->config->deviceType = DeviceType::PAX_S300; - $this->config->connectionMode = ConnectionModes::TCP_IP; - $this->config->timeout = 30; - $this->config->requestIdProvider = new RequestIdProvider(); - $this->config->logManagementProvider = new LogManagement(); - - return $this->config; - } - - private function printReceipt($response, $message = '') - { - print("\n\n Gateway Txn ID: " . $response->transactionId); - - $receipt = "x_trans_type=" . $response->transactionType; - $receipt .= "&x_application_label=" . $response->applicationPreferredName; - $receipt .= "&x_masked_card=" . $response->maskedCardNumber; - $receipt .= "&x_application_id=" . $response->applicationId; - $receipt .= "&x_cryptogram_type=" . $response->applicationCryptogramType; - $receipt .= "&x_application_cryptogram=" . $response->applicationCryptogram; - $receipt .= "&x_expiration_date=" . $response->expirationDate; - $receipt .= "&x_entry_method=" . $response->entryMethod; - $receipt .= "&x_approval=" . $response->approvalCode; - $receipt .= "&x_transaction_amount=" . $response->transactionAmount; - $receipt .= "&x_amount_due=" . $response->balanceAmount; - $receipt .= "&x_customer_verification_method=" . $response->customerVerificationMethod; - $receipt .= "&x_response_text=" . $response->responseText; - $receipt .= "&x_signature_status=" . $response->signatureStatus; - - print("\n Receipt: ".$receipt); - - $log = "\n $message Gateway Txn ID: " . $response->transactionId - . "\n Receipt: ".$receipt - . "\n ======================================================="; - - $this->config->logManagementProvider->setLog($log); - } - - /* - TEST CASE 1 - EMV Contact Sale with Offline PIN - Objective - 1.Process an EMV contact sale with offline PIN. - Test Card - Card #1 EMV MasterCard w Offline PIN - Procedure - 1.Select Sale function for an amount of $4.00. - a.Insert Test Card #1 and select application if prompted. - - On CVM Kernel Terminal will prompt for PIN; enter 4315. - - On No CVM Kernel Terminal, No PIN Prompt will occur - b.Terminal will prompt for PIN; enter 4315. - c.Terminal will respond approved. - Pass Criteria - 1.Transaction must be approved. - 2.Receipt must conform to EMV Receipt Requirements (see pg 2). - References - PAX POSLink (Windows) API Guide, Section 4.5: Class PaymentRequest - PAX Interface Between ECR PC and Terminal, Section 5.2.1: Do Credit - */ - - public function testCase01() - { - $response = $this->device->creditSale(4) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('0', $response->deviceResponseCode); - $this->assertEquals('00', $response->responseCode); - - $this->printReceipt($response, 'testCase01 creditSale'); - } - - /* - TEST CASE 2 - Non EMV Swiped Sale - Objective - 1.Ensure application can handle non-EMV swiped transactions. - 2.Validate partial approval support. - Test Card - Card #4 Magnetic stripe Visa - Procedure - 1.Select sale function and swipe Test Card #4 for the amount of $7.00 - 2.Select sale function and swipe Test Card #4 for the amount of $155.00 - a.Receive an approved amount less than requested. - Pass Criteria - 1.Transactions must be approved online. - 2.For 2nd Credit Sale, provide: - Approved Amount: $ 100.00 - Issuer Response Code: 10 - 3.Receipt must conform to Mag Stripe Receipt Requirements (see pg 2). - References - -  PAX POSLink (Windows) API Guide, Section 4.5: Class PaymentRequest - -  PAX POSLink (Windows) API Guide, Section 4.9: Class PaymentResponse - -  PAX Interface Between ECR PC and Terminal, Section 5.2.1: Do Credit - -  PAX Interface Between ECR PC and Terminal, Section 5.6: Response Sub-groupInformation - */ - - public function testCase02() - { - $response = $this->device->creditSale(7) - ->execute(); - - $this->printReceipt($response, 'testCase02 creditSale $7'); - - $this->assertNotNull($response); - $this->assertEquals('0', $response->deviceResponseCode); - $this->assertEquals('00', $response->responseCode); - - $response = $this->device->creditSale(155) - ->withAddress($this->address) - ->execute(); - - $this->printReceipt($response, 'testCase02 creditSale $155'); - - $this->assertNotNull($response); - $this->assertEquals('0', $response->deviceResponseCode); - $this->assertEquals('100', $response->transactionAmount); - $this->assertEquals('10', $response->responseCode); - } - - /* - TEST CASE 3 - Mag Stripe Online Void - Objective - Process an online void. - Test Card - Card #5 MSD only MasterCard - Procedure - 1.Select Void function to remove the previous Sale of $7.00. - a.Enter on the Portico Gateway software Txnld - (PAX HREF) from the 1st Credit Sale in Test Case 2 when prompted. - b.Select Credit, same as Test Case 2 - Pass Criteria - Transaction receives Gateway Response Code of 0, Issuer Response Code of 00. - References - -  PAX POSLink (Windows) API Guide, Section 4.5: Class PaymentRequest - -  PAX POSLink (Windows) API Guide, Appendix 5.1: Payment TransType - -  PAX Interface Between ECR PC and Terminal, Section 5.2.1: Do Credit - - */ - - public function testCase03() - { - $response = $this->device->creditSale(7) - ->withAddress($this->address) - ->execute(); - - $this->printReceipt($response, 'testCase03 creditSale'); - - $this->assertNotNull($response); - $this->assertEquals('0', $response->deviceResponseCode); - $this->assertNotNull($response->transactionId); - $this->assertEquals('00', $response->responseCode); - - $voidResponse = $this->device->creditVoid() - ->withTransactionId($response->transactionId) - ->execute(); - - $this->printReceipt($voidResponse, 'testCase03 creditVoid'); - - $this->assertNotNull($voidResponse); - $this->assertEquals('0', $voidResponse->deviceResponseCode); - $this->assertEquals('00', $voidResponse->responseCode); - } - - /* - TEST CASE 4 - Manually Entered Sale with AVS & CVV2/CID (If AVS is supported) - Objective - Process a keyed sale, with PAN & exp date, along with Address Verification and Card Security Code to - confirm the application can support any or all of these. - Test Card - Card #5 Magnetic stripe MasterCard - Procedure - 1.Select sale function and manually key Test Card #5 for the amount of $118.00. - a.Enter PAN & expiration date. - b.Enter 321 for Card Security Code (CVV2, CID), if supporting this feature. - Enter 76321 for AVS, if supporting this feature. - Pass Criteria - 1.Transaction must be approved online. - 2.AVS Result Code: Y - CVV Result Code: M - References - -  PAX POSLink (Windows) API Guide, Section 4.5: Class PaymentRequest - -  PAX Interface Between ECR PC and Terminal, Section 5.2.1: Do Credit - - */ - - public function testCase04() - { - $response = $this->device->creditSale(118) - ->execute(); - - $this->printReceipt($response, 'testCase04 creditSale AVS'); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->deviceResponseCode); - $this->assertNotNull($response->transactionId); - } - - /* - TEST CASE 5 - Sale with Tokenization (Required if tokenization is supported) - Objective - Complete Sale and receive Token - Test Card - Card #3 EMV Visa w/ Signature CVM - Card #5 MSD only MasterCard - Procedure - 1.Select a SALE transaction for $15.01 using Card #3 with tokenization enabled. - 1.Select a SALE transaction for $15.02 using Card #5 with tokenization enabled. - Pass Criteria - 1.Transaction # 1 receives Gateway Response Code of 0, Issuer Response Code of 00. - 2.Transaction # 2 receives Gateway Response Code of 0, Issuer Response Code of 00. - References - -  PAX POSLink (Windows) API PAX Interface Between ECR PC and Terminal,Section 5.5.9: - "Request Additional Information" and Section 5.6.10: ResponseAdditional Information - */ - - public function testCase05() - { - //generate token for EMV visa card - $response = $this->device->creditSale(15.01) - ->withRequestMultiUseToken(1) - ->execute(); - - $this->printReceipt($response, 'testCase05 creditSale $15.01'); - - $this->assertNotNull($response); - $this->assertEquals('0', $response->deviceResponseCode); - $this->assertEquals('00', $response->responseCode); - $this->assertNotNull($response->token); - - //write the token in file for later use - file_put_contents('EMVVisaToken', $response->token); - - //generate token for master card - - $response = $this->device->creditSale(15.02) - ->withRequestMultiUseToken(1) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('0', $response->deviceResponseCode); - $this->assertEquals('00', $response->responseCode); - $this->assertNotNull($response->token); - - $this->printReceipt($response, 'testCase05 creditSale $15.02'); - - //write the token in file for later use - file_put_contents('MSDMasterToken', $response->token); - } - - /* - * - * TEST CASE 6 - Sale with Tokenization (Required if Test Case 5 is executed) - Objective - Complete Sale using a Token on File - Test Card - Card #3 EMV Visa w/ Signature CVM - Card #5 MSD only MasterCard - Procedure - 1.Select a SALE transaction for $15.02 using the token generated for Card #3 in testcase #5. - 2.Select a SALE transaction for $15.03 using the token generated for Card #5 in testcase #5. - Pass Criteria - 1.Transaction # 1 receives Gateway Response Code of 0, Issuer Response Code of 00 - 2.Transaction # 2 receives Gateway Response Code of 0, Issuer Response Code of 00 - References - -  PAX POSLink (Windows) API PAX Interface Between ECR PC and Terminal,Section 5.5.9: - "Request Additional Information" and Section 5.6.10: ResponseAdditional Information - * - */ - - public function testCase06() - { - $emvVisaToken = @file_get_contents('EMVVisaToken'); - $msdMasterToken = @file_get_contents('MSDMasterToken'); - - if (empty($emvVisaToken) || empty($msdMasterToken)) { - $this->markTestSkipped('Token values not captured in testCase05'); - } - - //Visa card token sale - $emvVisaCard = new CreditCardData(); - $emvVisaCard->token = trim($emvVisaToken); - - $response = $this->device->creditSale(15.02) - ->withPaymentMethod($emvVisaCard) - ->execute(); - - $this->printReceipt($response, 'testCase06 creditSale $15.02'); - - $this->assertNotNull($response); - $this->assertEquals('0', $response->deviceResponseCode); - $this->assertEquals('00', $response->responseCode); - - //master card token sale - $msdMaster = new CreditCardData(); - $msdMaster->token = trim($msdMasterToken); - - $response = $this->device->creditSale(15.03) - ->withPaymentMethod($msdMaster) - ->execute(); - - $this->printReceipt($response, 'testCase06 creditSale $15.03'); - - $this->assertNotNull($response); - $this->assertEquals('0', $response->deviceResponseCode); - $this->assertEquals('00', $response->responseCode); - } - - - /* - * - * TEST CASE 7 - ECRRefNum - Duplicate Transaction Check - Objective - To produce a CREDIT_SALE Fail!, ResultTxt= DUP TRANSACTION - Test Card - Card #5 Magnetic stripe MasterCard - Procedure - 1.Process a Credit Sale for $2.00 utilizing any ECRRefNum - 2.Reprocess the Credit Sale using same amount and the same ECRRefNum - Pass Criteria - Provide Debug Logs showing the two Credit Sales for $2.00. Both must to be using the same ECRRefNum. - The Log should reflect the CREDIT_SALE Fail! DUP TRANSACTION - References - -   PAX POSLink (Windows) API PAX Interface Between ECR PC and Terminal - Section 5.5.4 - - */ - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException - * @expectedExceptionMessage HOST DECLINE: DUPLICATE TRANSACTION - */ - public function testCase07() - { - $clientTransactionId = 10000 + random_int(0, 99999); - - $response = $this->device->creditSale(2.00) - ->withClientTransactionId($clientTransactionId) - ->execute(); - - $this->printReceipt($response, 'testCase07 creditSale $2.00'); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->deviceResponseCode); - $this->assertEquals('0', $response->responseCode); - - $response = $this->device->creditSale(2.00) - ->withClientTransactionId($clientTransactionId) - ->execute(); - } - - - /* - * - * TEST CASE 8 - POSLink Debugging - Objective - To produce error or debug log during the investigation of Support Cases. - It is expected that the Error Log is turned on by default in customer sites. - Test Card - NA - Procedure - When using PAX POSLink, demonstrate that the Application has the ability to turn on the - LogManagement() Class and set the LogLevel to either Error Mode or Debug Mode. - If using Low Level Integration demonstrate the ability to produce equivalent Log Files. - Pass Criteria - Creation of the Report - Submit the Log File via email along with this VRF and the Receipts. - References - -   PAX POSLink (Windows) API PAX Interface Between ECR PC and Terminal - Section 4.3.1 Constructors, 4.3.2 Methods, 4.3.3 Properties - - */ - - - - - /* - * CONDITIONAL TEST CASE 8 Credit Return - Objective - Confirm support of a Return transaction for credit/debit using the HREF or GatewayTxnID. - Test Card - Card #4 Magnetic stripe Visa - Procedure - 1.Select sale function for the amount of $4.00 - 2.Swipe or Key Test card #4 through the MSR, record the HREF - 3.Select Refund function to refund the previous sale of $4.00, use the HREF from the previous sale - Pass Criteria - 1.Transaction must be approved using the HREF. - References - -  PAX POSLink (Windows) API Guide, Section 4.5: Class PaymentRequest - -  PAX Interface Between ECR PC and Terminal, Section 5.2.1: Do Credit - * - */ - - public function testCase08() - { - $response = $this->device->creditSale(4) - ->withAllowDuplicates(1) - ->execute(); - - $this->printReceipt($response, 'testCase08 creditSale $4'); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->deviceResponseCode); - $this->assertNotNull($response->transactionId); - - $refundResponse = $this->device->creditRefund(4) - ->withTransactionId($response->transactionId) - ->execute(); - - $this->printReceipt($refundResponse, 'testCase08 creditRefund $4'); - - $this->assertNotNull($refundResponse); - $this->assertEquals('00', $refundResponse->deviceResponseCode); - } - - - /* - * CONDITIONAL TEST CASE 9 EMV PIN Debit Sale/ Swiped MSR Debit Sale - Objective - Confirm support of PIN Debit sale - Test Card - Card #4 EMV MasterCard w/ Offline PIN & Magnetic stripe Visa - Procedure - 1.Select sale function for the amount of $10.00. - a.Insert EMV Test Card (For this test case you will need to use your own EMV PIN Debit Card) - b.Select Debit on the card type prompt. - c.Enter PIN of 1234 when pad prompts for it, record the HREF. - 2.Select sale function for the amount of $11.00. - a.Swipe Test Card #4 - b.Select Debit on the card type prompt. - c.Enter PIN of 1234 when pad prompts for it. - Pass Criteria - 1. Transaction must be approved online. Logs must be provided reflecting this transaction. - Provide 1st Inserted EMV Debit Sale:Host Reference Number:2nd Swiped Debit Sale: - References - -  PAX POSLink (Windows) API Guide, Section 4.5: Class PaymentRequest - PAX Interface Between ECR PC and Terminal, Section 5.2.2: Do Debit - */ - - public function testCase09() - { - $response = $this->device->debitSale(10) - ->withAllowDuplicates(1) - ->execute(); - - $this->printReceipt($response, 'testCase09 debitSale $10'); - - $this->assertNotNull($response); - $this->assertEquals('OK', $response->deviceResponseText); - - $response = $this->device->debitSale(11) - ->withAllowDuplicates(1) - ->execute(); - - $this->printReceipt($response, 'testCase09 debitSale $11'); - - $this->assertNotNull($response); - $this->assertEquals('OK', $response->deviceResponseText); - } - - /* - * CONDITIONAL TEST CASE 11 Tip Adjustment - Objective - Complete Sale with Tip Adjustment - Pick One Gratuity Approach: - 1) CREDIT AUTH + CREDIT POSTAUTH (Portico CreditAddToBatch) - 2) CREDIT SALE + CREDIT ADJUST (Portico CreditTxnEdit) - Test Card - Card #5 MSD only MasterCard (AVS required) - Procedure - 1.Select SALE function and swipe Card #5 for the amount of $15.12 - 2.Add a $3.00 tip at Settlement. - Pass Criteria - 1.Transaction must be approved. Using HREF. - 2.Adjusted Tip: - Approved Amount: $18.12 - References - -  PAX POSLink (Windows) API Guide, Section 4.5: Class PaymentRequest - -  PAX Interface Between ECR PC and Terminal, Section 5.2.1: Do Credit - * - */ - - public function testCase11() - { - $response = $this->device->creditSale(15.12) - ->withGratuity(3) - ->withAllowDuplicates(1) - ->withAddress($this->address) - ->execute(); - - $this->printReceipt($response, 'testCase11 Tip'); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->deviceResponseCode); - $this->assertEquals('18.12', $response->transactionAmount); - } - - - /* - * CONDITIONAL TEST CASE 12 HMS Gift - Objective - Transactions: Gift Balance Inquiry, Gift Load, Gift Sale/Redeem, Gift Replace - Test Card - Gift Card (Card Present/Card Swipe) - Procedure - Test System is a Stateless Environment, the responses are Static. - 1.Gift Load (GiftCardAddValue): - a.Initiate a Sale and swipe - b.Enter $8.00 as the amount - 2.Gift Balance Inquiry (GiftCardBalance): - a.Should respond with a BalanceAmt of $10 - 3.Gift Sale/Redeem (GiftCardSale): - a.Initiate a Sale and swipe - b.Enter $1.00 as the amount - Pass Criteria - 1.Gift Load (GiftCardAdd Value): - 2.Gift Balance Inquiry (GiftCardBalance): - 3.Gift Sale/Redeem (GiftCardSale): - References - -  PAX Interface Between ECR PC and Terminal, Section 4.4: Transaction TypeDefinition - -  PAX Interface Between ECR PC and Terminal, Section 5.2.4: Do Gift (T06) (T07) - * - */ - - public function testCase12() - { - $response = $this->device->giftAddValue(8) - ->execute(); - - $this->printReceipt($response, 'testCase12 giftAddValue'); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - - $response = $this->device->giftBalance() - ->execute(); - - $this->printReceipt($response, 'testCase12 giftBalance'); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - - $response = $this->device->giftSale(1) - ->execute(); - - $this->printReceipt($response, 'testCase12 giftSale'); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - - /* - * CONDITIONAL TEST CASE 13 EBT Food Stamp - Objective - Transactions: Food Stamp Purchase, Food Stamp Return and Food Stamp Balance Inquiry - Test Card - Card #4 MSD only Visa - Procedure - 5.Food Stamp Purchase (EBTFSPurchase): - c.Initiate an EBT sale transaction and swipe Test Card #4 - d.Select EBT Food Stamp if prompted. - e.Enter $101.01 as the amount - 6.Food Stamp Return (EBTFSReturn): - b.Intitiate an EBT return and manually enter Test Card #4 - c.Select EBT Food Stamp if prompted - d.Enter $104.01 as the amount - 7.Food Stamp Balance Inquiry (EBTBalanceInquiry): - c.Initiate an EBT blance inquiry transaction and swipe Test Card #4 Settleall transactions. - Pass Criteria - 5.Food Stamp Purchase (EBTFSPurchase) - 6.Food Stamp Return (EBTFSReturn) - 7.Food Stamp Balance Inq (EBTBalanceInquiry) - References - -  PAX POSLink (Windows) API Guide, Section 4.5: Class PaymentRequest - -  PAX Interface Between ECR PC and Terminal, Section 5.2.3: Do EBT - */ - - public function testCase13() - { - $response = $this->device->ebtPurchase(101.01) - ->execute(); - - $this->printReceipt($response, 'testCase13 ebtPurchase'); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - - $response = $this->device->ebtRefund(104.01) - ->withCurrency(CurrencyType::FOODSTAMPS) - ->execute(); - - $this->printReceipt($response, 'testCase13 ebtRefund'); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - - $response = $this->device->ebtBalance() - ->withCurrency(CurrencyType::FOODSTAMPS) - ->execute(); - - $this->printReceipt($response, 'testCase13 ebtBalance'); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - - /* - * CONDITIONAL TEST CASE 14 EBT Cash Benefits - Objective - Transactions: EBT Cash Benefits with Cash Back, EBT Cash Benefits Balance Inquiry and EBT Cash - Benefits Withdraw - Test Card - Card #4 MSD only Visa - Procedure - EBT Cash Benefits w Cash Back (EBTCashBackPurchase): - a.Initiate an EBT sale transaction and swipe Test Card #4 - b.Select EBT Cash Benefits if prompted - c.Enter $101.01 as the amount - d.Enter $5.00 as the cash back amount - e.The settlement amount is $106.01 - 2.EBT Cash Benefits Balance Inquiry (EBTBalanceInquiry): - a.Initiate an EBT cash benefit balance inquiry transaction and swipe Test Card #4 - 3.EBT Cash Benefits Withdraw (EBTCashBenefitWithdrawal): - a.Initiate an EBT cash benefits withdraw transaction and manually enter Test Card #4. - b.Select EBT Cash Benefits Withdraw if prompted - c.Enter $111.01 as the amount. - d.The settlement amount is $111.01 - e.Settle all transactions. - Pass Criteria - 1.Cash Back (EBTCashBackPurchase) - 2.Balance Inquiry (EBTBalanceInquiry) - 3.Withdraw (EBTCashBenefitWithdrawal) - Host Reference Number: - References - -  PAX POSLink (Windows) API Guide, Section 4.5: Class PaymentRequest - -  PAX Interface Between ECR PC and Terminal, Section 5.2.3: Do EBT - * - */ - - public function testCase14() - { - $response = $this->device->ebtPurchase(101.01) - ->execute(); - - $this->printReceipt($response, 'testCase14 ebtPurchase'); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - - $response = $this->device->ebtBalance() - ->withCurrency(CurrencyType::CASH_BENEFITS) - ->execute(); - - $this->printReceipt($response, 'testCase14 ebtBalance'); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - - $response = $this->device->ebtWithdrawl(111.01) - ->withCurrency(CurrencyType::CASH_BENEFITS) - ->execute(); - - $this->printReceipt($response, 'testCase14 ebtWithdrawl'); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - - /* - * CONDITIONAL TEST CASE 15 Level II Corporate Card - Objective - Process the 3 types of Corporate Card transactions: No Tax, Tax Amount, and Tax Exempt; including - the passing of PO Number. - Test Card - Card #4 Magnetic stripe Visa - Procedure - 1.Select sale function for the amount of $112.34. - a.Swipe Test Card #4 - b.Receive CPC Indicator of B - c.Continue with CPCEdit transaction to account for Tax Type of Not Used. - d.Enter the PO Number of 98765432101234567 on the device. - 2.Select sale function for the amount of $123.45. - a.Swipe Test Card #4 - b.Receive CPC Indicator of R - c.Continue with CPCEdit transaction to account for Tax Type of Tax Amount for$1.00. - 3.Select sale function for the amount of $134.56. - a.Swipe test Card #4 - b.Receive CPC Indicator of S. - c.Continue with CPCEdit transaction to account for Tax Type of Tax Exempt. - d.Enter the PO Number of 98765432101234567 on device. - Pass Criteria - 1.Transactions will approve online. - References - -  PAX POSLink (Windows) API Guide, Section 4.5: Class PaymentRequest - -  PAX Interface Between ECR PC and Terminal, Section 5.2.1: Do Credit - -  PAX Interface Between ECR PC and Terminal, Section 5.5.7: Request CommercialInformation - */ - - public function testCase15() - { - $response = $this->device->creditSale(112.34) - ->withTaxType(TaxType::NOT_USED) - ->withPoNumber("98765432101234567") - ->execute(); - - $this->printReceipt($response, 'testCase15 No Tax'); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - - $response = $this->device->creditSale(123.45) - ->withTaxAmount(1) - ->withCustomerCode("987654321") - ->withTaxType(TaxType::SALES_TAX) - ->execute(); - - $this->printReceipt($response, 'testCase15 withTax'); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - - $response = $this->device->creditSale(134.5) - ->withTaxType(TaxType::TAX_EXEMPT) - ->withPoNumber("98765432101234567") - ->execute(); - - $this->printReceipt($response, 'testCase15 TAX_EXEMPT'); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } - - /* - CONDITIONAL TEST CASE 17 Approved Store and Forward sale and Upload - Objective - Process credit sale in Store and Forward, upload transaction, and close batch. - In order to access parameters and functions related to SAF, - Allow Store&Forward needs to be enabled on BroadPOS TMS. - SETSAFPARAMETERS commands are available as well. - Test Card - Card #3 EMV Visa w/ Signature CVM - Procedure - 1.Select Sale function for an amount of $4.00. Response Approved. - 2.Send SAFUPLOAD command - a.SAF Indicator = 2 - b.Result OK - 3.Initiate a Batch Close - Pass Criteria - Transaction approve in SAF and settles in a batch. - References - -  PAX POSLink (Windows) API Guide, Section 4.6: Class ManageRequest - -  PAX Interface Between ECR PC and Terminal, Section 5.1.28: Set SAF Parameters - -  PETE Store and Forward QRG - -*/ - - public function testCase17() - { - //set to saf mode - $response = $this->device->setSafMode(SafMode::STAY_OFFLINE); - - $this->assertNotNull($response); - $this->assertEquals('OK', $response->deviceResponseText); - - //credit sale in offline mode - $response = $this->device->creditSale(4.00) - ->withAllowDuplicates(1) - ->execute(); - - $this->printReceipt($response, 'testCase17 SAF creditSale'); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->deviceResponseCode); - $this->assertEquals('APPROVED OFFLINE', $response->deviceResponseText); - - //SAF upload - $response = $this->device->safUpload(SafUpload::ALL_TRANSACTION); - - $this->printReceipt($response, 'testCase17 safUpload'); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - - //batch Close - $response = $this->device->batchClose(); - - $this->printReceipt($response, 'testCase17 batchClose'); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - - //reset to online mode - $response = $this->device->setSafMode(SafMode::STAY_ONLINE); - - $this->assertNotNull($response); - $this->assertEquals('OK', $response->deviceResponseText); - } - - /* - CONDITIONAL TEST CASE 18 Declined Store and Forward transaction and Delete - (Mandatory if Conditional Test Case 17 is ran) - Objective - Process credit sale in Store and Forward, upload transaction, and delete declined transaction from terminal. - In order to access parameters and functions related to SAF, Allow Store&Forward needs to be enabled - on BroadPOS TMS. SETSAFPARAMETERS commands are available as well. - Test Card - Card #3 EMV Visa w/ Signature CVM - Procedure - 1.Select Sale function for an amount of $10.25. Response Approved. - 2.Send SAFUPLOAD command - a.SAF Indicator = 2 - b.Transaction will decline - 3.Perform DELETESAFFILE - a.SAF Indicator = 2 - Pass Criteria - Transaction approved in SAF and declines when uploaded. Delete record from terminal. - References - -  PAX POSLink (Windows) API Guide, Section 4.6: Class ManageRequest - -  PAX Interface Between ECR PC and Terminal, Section 5.1.28: Set SAF Parameters - -  PETE Store and Forward QRG -*/ - - public function testCase18() - { - - //set to saf mode - $response = $this->device->setSafMode(SafMode::STAY_OFFLINE); - - $this->assertNotNull($response); - $this->assertEquals('OK', $response->deviceResponseText); - - //credit auth in offline mode - $response = $this->device->creditAuth(10.25) - ->withAllowDuplicates(1) - ->execute(); - - $this->printReceipt($response, 'testCase18 SAF creditSale'); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->deviceResponseCode); - - //SAF upload - $response = $this->device->safUpload(SafUpload::ALL_TRANSACTION); - - $this->printReceipt($response, 'testCase18 safUpload'); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - - //SAF Delete - $response = $this->device->safDelete(SafDelete::FAILED_TRANSACTION); - - $this->printReceipt($response, 'testCase18 safDelete'); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - - //reset to online mode - $response = $this->device->setSafMode(SafMode::STAY_ONLINE); - - $this->assertNotNull($response); - $this->assertEquals('OK', $response->deviceResponseText); - } - - /* - CONDITIONAL TEST CASE 19 Batch Close - (Mandatory if Conditional Test Cases are ran) - Objective - Close the batch, ensuring all approved transactions (offline or online) are settled. - Integrators are automatically provided accounts with auto-close enabled, so if manual batch transmission will - not be performed in the production environment then it does not need to be tested. - Test Card - N/A - Procedure - Initiate a Batch Close command - Pass Criteria - Batch submission must be successful. - References - -  PAX POSLink (Windows) API Guide, Section 4.5: Class BatchRequest - -  PAX Interface Between ECR PC and Terminal, Section 5.3.1: Batch Close - * - */ - - public function testCase19() - { - $response = $this->device->batchClose(); - - $this->printReceipt($response, 'testCase19 batchClose'); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->deviceResponseCode); - } -} +device = DeviceService::create($this->getConfig()); + + $this->card = new CreditCardData(); + $this->card->number = '5473500000000014'; + $this->card->expMonth = 12; + $this->card->expYear = 2025; + $this->card->cvn = '123'; + $this->card->cardHolderName = 'Joe Smith'; + + $this->address = new Address(); + $this->address->streetAddress1 = '6860 Dallas Pkwy'; + $this->address->postalCode = '76321'; + } + + public function tearDown() + { + sleep(3); + } + + protected function getConfig() + { + $this->config = new ConnectionConfig(); + $this->config->ipAddress = '192.168.42.219'; + $this->config->port = '10009'; + $this->config->deviceType = DeviceType::PAX_S300; + $this->config->connectionMode = ConnectionModes::TCP_IP; + $this->config->timeout = 30; + $this->config->requestIdProvider = new RequestIdProvider(); + $this->config->logManagementProvider = new LogManagement(); + + return $this->config; + } + + private function printReceipt($response, $message = '') + { + print("\n\n Gateway Txn ID: " . $response->transactionId); + + $receipt = "x_trans_type=" . $response->transactionType; + $receipt .= "&x_application_label=" . $response->applicationPreferredName; + $receipt .= "&x_masked_card=" . $response->maskedCardNumber; + $receipt .= "&x_application_id=" . $response->applicationId; + $receipt .= "&x_cryptogram_type=" . $response->applicationCryptogramType; + $receipt .= "&x_application_cryptogram=" . $response->applicationCryptogram; + $receipt .= "&x_expiration_date=" . $response->expirationDate; + $receipt .= "&x_entry_method=" . $response->entryMethod; + $receipt .= "&x_approval=" . $response->approvalCode; + $receipt .= "&x_transaction_amount=" . $response->transactionAmount; + $receipt .= "&x_amount_due=" . $response->balanceAmount; + $receipt .= "&x_customer_verification_method=" . $response->customerVerificationMethod; + $receipt .= "&x_response_text=" . $response->responseText; + $receipt .= "&x_signature_status=" . $response->signatureStatus; + + print("\n Receipt: ".$receipt); + + $log = "\n $message Gateway Txn ID: " . $response->transactionId + . "\n Receipt: ".$receipt + . "\n ======================================================="; + + $this->config->logManagementProvider->setLog($log); + } + + /* + TEST CASE 1 - EMV Contact Sale with Offline PIN + Objective + 1.Process an EMV contact sale with offline PIN. + Test Card + Card #1 EMV MasterCard w Offline PIN + Procedure + 1.Select Sale function for an amount of $4.00. + a.Insert Test Card #1 and select application if prompted. + - On CVM Kernel Terminal will prompt for PIN; enter 4315. + - On No CVM Kernel Terminal, No PIN Prompt will occur + b.Terminal will prompt for PIN; enter 4315. + c.Terminal will respond approved. + Pass Criteria + 1.Transaction must be approved. + 2.Receipt must conform to EMV Receipt Requirements (see pg 2). + References + PAX POSLink (Windows) API Guide, Section 4.5: Class PaymentRequest + PAX Interface Between ECR PC and Terminal, Section 5.2.1: Do Credit + */ + + public function testCase01() + { + $response = $this->device->creditSale(4) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('0', $response->deviceResponseCode); + $this->assertEquals('00', $response->responseCode); + + $this->printReceipt($response, 'testCase01 creditSale'); + } + + /* + TEST CASE 2 - Non EMV Swiped Sale + Objective + 1.Ensure application can handle non-EMV swiped transactions. + 2.Validate partial approval support. + Test Card + Card #4 Magnetic stripe Visa + Procedure + 1.Select sale function and swipe Test Card #4 for the amount of $7.00 + 2.Select sale function and swipe Test Card #4 for the amount of $155.00 + a.Receive an approved amount less than requested. + Pass Criteria + 1.Transactions must be approved online. + 2.For 2nd Credit Sale, provide: + Approved Amount: $ 100.00 + Issuer Response Code: 10 + 3.Receipt must conform to Mag Stripe Receipt Requirements (see pg 2). + References + -  PAX POSLink (Windows) API Guide, Section 4.5: Class PaymentRequest + -  PAX POSLink (Windows) API Guide, Section 4.9: Class PaymentResponse + -  PAX Interface Between ECR PC and Terminal, Section 5.2.1: Do Credit + -  PAX Interface Between ECR PC and Terminal, Section 5.6: Response Sub-groupInformation + */ + + public function testCase02() + { + $response = $this->device->creditSale(7) + ->execute(); + + $this->printReceipt($response, 'testCase02 creditSale $7'); + + $this->assertNotNull($response); + $this->assertEquals('0', $response->deviceResponseCode); + $this->assertEquals('00', $response->responseCode); + + $response = $this->device->creditSale(155) + ->withAddress($this->address) + ->execute(); + + $this->printReceipt($response, 'testCase02 creditSale $155'); + + $this->assertNotNull($response); + $this->assertEquals('0', $response->deviceResponseCode); + $this->assertEquals('100', $response->transactionAmount); + $this->assertEquals('10', $response->responseCode); + } + + /* + TEST CASE 3 - Mag Stripe Online Void + Objective + Process an online void. + Test Card + Card #5 MSD only MasterCard + Procedure + 1.Select Void function to remove the previous Sale of $7.00. + a.Enter on the Portico Gateway software Txnld + (PAX HREF) from the 1st Credit Sale in Test Case 2 when prompted. + b.Select Credit, same as Test Case 2 + Pass Criteria + Transaction receives Gateway Response Code of 0, Issuer Response Code of 00. + References + -  PAX POSLink (Windows) API Guide, Section 4.5: Class PaymentRequest + -  PAX POSLink (Windows) API Guide, Appendix 5.1: Payment TransType + -  PAX Interface Between ECR PC and Terminal, Section 5.2.1: Do Credit + + */ + + public function testCase03() + { + $response = $this->device->creditSale(7) + ->withAddress($this->address) + ->execute(); + + $this->printReceipt($response, 'testCase03 creditSale'); + + $this->assertNotNull($response); + $this->assertEquals('0', $response->deviceResponseCode); + $this->assertNotNull($response->transactionId); + $this->assertEquals('00', $response->responseCode); + + $voidResponse = $this->device->creditVoid() + ->withTransactionId($response->transactionId) + ->execute(); + + $this->printReceipt($voidResponse, 'testCase03 creditVoid'); + + $this->assertNotNull($voidResponse); + $this->assertEquals('0', $voidResponse->deviceResponseCode); + $this->assertEquals('00', $voidResponse->responseCode); + } + + /* + TEST CASE 4 - Manually Entered Sale with AVS & CVV2/CID (If AVS is supported) + Objective + Process a keyed sale, with PAN & exp date, along with Address Verification and Card Security Code to + confirm the application can support any or all of these. + Test Card + Card #5 Magnetic stripe MasterCard + Procedure + 1.Select sale function and manually key Test Card #5 for the amount of $118.00. + a.Enter PAN & expiration date. + b.Enter 321 for Card Security Code (CVV2, CID), if supporting this feature. + Enter 76321 for AVS, if supporting this feature. + Pass Criteria + 1.Transaction must be approved online. + 2.AVS Result Code: Y + CVV Result Code: M + References + -  PAX POSLink (Windows) API Guide, Section 4.5: Class PaymentRequest + -  PAX Interface Between ECR PC and Terminal, Section 5.2.1: Do Credit + + */ + + public function testCase04() + { + $response = $this->device->creditSale(118) + ->execute(); + + $this->printReceipt($response, 'testCase04 creditSale AVS'); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->deviceResponseCode); + $this->assertNotNull($response->transactionId); + } + + /* + TEST CASE 5 - Sale with Tokenization (Required if tokenization is supported) + Objective + Complete Sale and receive Token + Test Card + Card #3 EMV Visa w/ Signature CVM + Card #5 MSD only MasterCard + Procedure + 1.Select a SALE transaction for $15.01 using Card #3 with tokenization enabled. + 1.Select a SALE transaction for $15.02 using Card #5 with tokenization enabled. + Pass Criteria + 1.Transaction # 1 receives Gateway Response Code of 0, Issuer Response Code of 00. + 2.Transaction # 2 receives Gateway Response Code of 0, Issuer Response Code of 00. + References + -  PAX POSLink (Windows) API PAX Interface Between ECR PC and Terminal,Section 5.5.9: + "Request Additional Information" and Section 5.6.10: ResponseAdditional Information + */ + + public function testCase05() + { + //generate token for EMV visa card + $response = $this->device->creditSale(15.01) + ->withRequestMultiUseToken(1) + ->execute(); + + $this->printReceipt($response, 'testCase05 creditSale $15.01'); + + $this->assertNotNull($response); + $this->assertEquals('0', $response->deviceResponseCode); + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->token); + + //write the token in file for later use + file_put_contents('EMVVisaToken', $response->token); + + //generate token for master card + + $response = $this->device->creditSale(15.02) + ->withRequestMultiUseToken(1) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('0', $response->deviceResponseCode); + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->token); + + $this->printReceipt($response, 'testCase05 creditSale $15.02'); + + //write the token in file for later use + file_put_contents('MSDMasterToken', $response->token); + } + + /* + * + * TEST CASE 6 - Sale with Tokenization (Required if Test Case 5 is executed) + Objective + Complete Sale using a Token on File + Test Card + Card #3 EMV Visa w/ Signature CVM + Card #5 MSD only MasterCard + Procedure + 1.Select a SALE transaction for $15.02 using the token generated for Card #3 in testcase #5. + 2.Select a SALE transaction for $15.03 using the token generated for Card #5 in testcase #5. + Pass Criteria + 1.Transaction # 1 receives Gateway Response Code of 0, Issuer Response Code of 00 + 2.Transaction # 2 receives Gateway Response Code of 0, Issuer Response Code of 00 + References + -  PAX POSLink (Windows) API PAX Interface Between ECR PC and Terminal,Section 5.5.9: + "Request Additional Information" and Section 5.6.10: ResponseAdditional Information + * + */ + + public function testCase06() + { + $emvVisaToken = @file_get_contents('EMVVisaToken'); + $msdMasterToken = @file_get_contents('MSDMasterToken'); + + if (empty($emvVisaToken) || empty($msdMasterToken)) { + $this->markTestSkipped('Token values not captured in testCase05'); + } + + //Visa card token sale + $emvVisaCard = new CreditCardData(); + $emvVisaCard->token = trim($emvVisaToken); + + $response = $this->device->creditSale(15.02) + ->withPaymentMethod($emvVisaCard) + ->execute(); + + $this->printReceipt($response, 'testCase06 creditSale $15.02'); + + $this->assertNotNull($response); + $this->assertEquals('0', $response->deviceResponseCode); + $this->assertEquals('00', $response->responseCode); + + //master card token sale + $msdMaster = new CreditCardData(); + $msdMaster->token = trim($msdMasterToken); + + $response = $this->device->creditSale(15.03) + ->withPaymentMethod($msdMaster) + ->execute(); + + $this->printReceipt($response, 'testCase06 creditSale $15.03'); + + $this->assertNotNull($response); + $this->assertEquals('0', $response->deviceResponseCode); + $this->assertEquals('00', $response->responseCode); + } + + + /* + * + * TEST CASE 7 - ECRRefNum - Duplicate Transaction Check + Objective + To produce a CREDIT_SALE Fail!, ResultTxt= DUP TRANSACTION + Test Card + Card #5 Magnetic stripe MasterCard + Procedure + 1.Process a Credit Sale for $2.00 utilizing any ECRRefNum + 2.Reprocess the Credit Sale using same amount and the same ECRRefNum + Pass Criteria + Provide Debug Logs showing the two Credit Sales for $2.00. Both must to be using the same ECRRefNum. + The Log should reflect the CREDIT_SALE Fail! DUP TRANSACTION + References + -   PAX POSLink (Windows) API PAX Interface Between ECR PC and Terminal + Section 5.5.4 + + */ + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException + * @expectedExceptionMessage HOST DECLINE: DUPLICATE TRANSACTION + */ + public function testCase07() + { + $clientTransactionId = 10000 + random_int(0, 99999); + + $response = $this->device->creditSale(2.00) + ->withClientTransactionId($clientTransactionId) + ->execute(); + + $this->printReceipt($response, 'testCase07 creditSale $2.00'); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->deviceResponseCode); + $this->assertEquals('0', $response->responseCode); + + $response = $this->device->creditSale(2.00) + ->withClientTransactionId($clientTransactionId) + ->execute(); + } + + + /* + * + * TEST CASE 8 - POSLink Debugging + Objective + To produce error or debug log during the investigation of Support Cases. + It is expected that the Error Log is turned on by default in customer sites. + Test Card + NA + Procedure + When using PAX POSLink, demonstrate that the Application has the ability to turn on the + LogManagement() Class and set the LogLevel to either Error Mode or Debug Mode. + If using Low Level Integration demonstrate the ability to produce equivalent Log Files. + Pass Criteria + Creation of the Report + Submit the Log File via email along with this VRF and the Receipts. + References + -   PAX POSLink (Windows) API PAX Interface Between ECR PC and Terminal + Section 4.3.1 Constructors, 4.3.2 Methods, 4.3.3 Properties + + */ + + + + + /* + * CONDITIONAL TEST CASE 8 Credit Return + Objective + Confirm support of a Return transaction for credit/debit using the HREF or GatewayTxnID. + Test Card + Card #4 Magnetic stripe Visa + Procedure + 1.Select sale function for the amount of $4.00 + 2.Swipe or Key Test card #4 through the MSR, record the HREF + 3.Select Refund function to refund the previous sale of $4.00, use the HREF from the previous sale + Pass Criteria + 1.Transaction must be approved using the HREF. + References + -  PAX POSLink (Windows) API Guide, Section 4.5: Class PaymentRequest + -  PAX Interface Between ECR PC and Terminal, Section 5.2.1: Do Credit + * + */ + + public function testCase08() + { + $response = $this->device->creditSale(4) + ->withAllowDuplicates(1) + ->execute(); + + $this->printReceipt($response, 'testCase08 creditSale $4'); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->deviceResponseCode); + $this->assertNotNull($response->transactionId); + + $refundResponse = $this->device->creditRefund(4) + ->withTransactionId($response->transactionId) + ->execute(); + + $this->printReceipt($refundResponse, 'testCase08 creditRefund $4'); + + $this->assertNotNull($refundResponse); + $this->assertEquals('00', $refundResponse->deviceResponseCode); + } + + + /* + * CONDITIONAL TEST CASE 9 EMV PIN Debit Sale/ Swiped MSR Debit Sale + Objective + Confirm support of PIN Debit sale + Test Card + Card #4 EMV MasterCard w/ Offline PIN & Magnetic stripe Visa + Procedure + 1.Select sale function for the amount of $10.00. + a.Insert EMV Test Card (For this test case you will need to use your own EMV PIN Debit Card) + b.Select Debit on the card type prompt. + c.Enter PIN of 1234 when pad prompts for it, record the HREF. + 2.Select sale function for the amount of $11.00. + a.Swipe Test Card #4 + b.Select Debit on the card type prompt. + c.Enter PIN of 1234 when pad prompts for it. + Pass Criteria + 1. Transaction must be approved online. Logs must be provided reflecting this transaction. + Provide 1st Inserted EMV Debit Sale:Host Reference Number:2nd Swiped Debit Sale: + References + -  PAX POSLink (Windows) API Guide, Section 4.5: Class PaymentRequest + PAX Interface Between ECR PC and Terminal, Section 5.2.2: Do Debit + */ + + public function testCase09() + { + $response = $this->device->debitSale(10) + ->withAllowDuplicates(1) + ->execute(); + + $this->printReceipt($response, 'testCase09 debitSale $10'); + + $this->assertNotNull($response); + $this->assertEquals('OK', $response->deviceResponseText); + + $response = $this->device->debitSale(11) + ->withAllowDuplicates(1) + ->execute(); + + $this->printReceipt($response, 'testCase09 debitSale $11'); + + $this->assertNotNull($response); + $this->assertEquals('OK', $response->deviceResponseText); + } + + /* + * CONDITIONAL TEST CASE 11 Tip Adjustment + Objective + Complete Sale with Tip Adjustment + Pick One Gratuity Approach: + 1) CREDIT AUTH + CREDIT POSTAUTH (Portico CreditAddToBatch) + 2) CREDIT SALE + CREDIT ADJUST (Portico CreditTxnEdit) + Test Card + Card #5 MSD only MasterCard (AVS required) + Procedure + 1.Select SALE function and swipe Card #5 for the amount of $15.12 + 2.Add a $3.00 tip at Settlement. + Pass Criteria + 1.Transaction must be approved. Using HREF. + 2.Adjusted Tip: + Approved Amount: $18.12 + References + -  PAX POSLink (Windows) API Guide, Section 4.5: Class PaymentRequest + -  PAX Interface Between ECR PC and Terminal, Section 5.2.1: Do Credit + * + */ + + public function testCase11() + { + $response = $this->device->creditSale(15.12) + ->withGratuity(3) + ->withAllowDuplicates(1) + ->withAddress($this->address) + ->execute(); + + $this->printReceipt($response, 'testCase11 Tip'); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->deviceResponseCode); + $this->assertEquals('18.12', $response->transactionAmount); + } + + + /* + * CONDITIONAL TEST CASE 12 HMS Gift + Objective + Transactions: Gift Balance Inquiry, Gift Load, Gift Sale/Redeem, Gift Replace + Test Card + Gift Card (Card Present/Card Swipe) + Procedure + Test System is a Stateless Environment, the responses are Static. + 1.Gift Load (GiftCardAddValue): + a.Initiate a Sale and swipe + b.Enter $8.00 as the amount + 2.Gift Balance Inquiry (GiftCardBalance): + a.Should respond with a BalanceAmt of $10 + 3.Gift Sale/Redeem (GiftCardSale): + a.Initiate a Sale and swipe + b.Enter $1.00 as the amount + Pass Criteria + 1.Gift Load (GiftCardAdd Value): + 2.Gift Balance Inquiry (GiftCardBalance): + 3.Gift Sale/Redeem (GiftCardSale): + References + -  PAX Interface Between ECR PC and Terminal, Section 4.4: Transaction TypeDefinition + -  PAX Interface Between ECR PC and Terminal, Section 5.2.4: Do Gift (T06) (T07) + * + */ + + public function testCase12() + { + $response = $this->device->giftAddValue(8) + ->execute(); + + $this->printReceipt($response, 'testCase12 giftAddValue'); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + + $response = $this->device->giftBalance() + ->execute(); + + $this->printReceipt($response, 'testCase12 giftBalance'); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + + $response = $this->device->giftSale(1) + ->execute(); + + $this->printReceipt($response, 'testCase12 giftSale'); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + + /* + * CONDITIONAL TEST CASE 13 EBT Food Stamp + Objective + Transactions: Food Stamp Purchase, Food Stamp Return and Food Stamp Balance Inquiry + Test Card + Card #4 MSD only Visa + Procedure + 5.Food Stamp Purchase (EBTFSPurchase): + c.Initiate an EBT sale transaction and swipe Test Card #4 + d.Select EBT Food Stamp if prompted. + e.Enter $101.01 as the amount + 6.Food Stamp Return (EBTFSReturn): + b.Intitiate an EBT return and manually enter Test Card #4 + c.Select EBT Food Stamp if prompted + d.Enter $104.01 as the amount + 7.Food Stamp Balance Inquiry (EBTBalanceInquiry): + c.Initiate an EBT blance inquiry transaction and swipe Test Card #4 Settleall transactions. + Pass Criteria + 5.Food Stamp Purchase (EBTFSPurchase) + 6.Food Stamp Return (EBTFSReturn) + 7.Food Stamp Balance Inq (EBTBalanceInquiry) + References + -  PAX POSLink (Windows) API Guide, Section 4.5: Class PaymentRequest + -  PAX Interface Between ECR PC and Terminal, Section 5.2.3: Do EBT + */ + + public function testCase13() + { + $response = $this->device->ebtPurchase(101.01) + ->execute(); + + $this->printReceipt($response, 'testCase13 ebtPurchase'); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + + $response = $this->device->ebtRefund(104.01) + ->withCurrency(CurrencyType::FOODSTAMPS) + ->execute(); + + $this->printReceipt($response, 'testCase13 ebtRefund'); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + + $response = $this->device->ebtBalance() + ->withCurrency(CurrencyType::FOODSTAMPS) + ->execute(); + + $this->printReceipt($response, 'testCase13 ebtBalance'); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + + /* + * CONDITIONAL TEST CASE 14 EBT Cash Benefits + Objective + Transactions: EBT Cash Benefits with Cash Back, EBT Cash Benefits Balance Inquiry and EBT Cash + Benefits Withdraw + Test Card + Card #4 MSD only Visa + Procedure + EBT Cash Benefits w Cash Back (EBTCashBackPurchase): + a.Initiate an EBT sale transaction and swipe Test Card #4 + b.Select EBT Cash Benefits if prompted + c.Enter $101.01 as the amount + d.Enter $5.00 as the cash back amount + e.The settlement amount is $106.01 + 2.EBT Cash Benefits Balance Inquiry (EBTBalanceInquiry): + a.Initiate an EBT cash benefit balance inquiry transaction and swipe Test Card #4 + 3.EBT Cash Benefits Withdraw (EBTCashBenefitWithdrawal): + a.Initiate an EBT cash benefits withdraw transaction and manually enter Test Card #4. + b.Select EBT Cash Benefits Withdraw if prompted + c.Enter $111.01 as the amount. + d.The settlement amount is $111.01 + e.Settle all transactions. + Pass Criteria + 1.Cash Back (EBTCashBackPurchase) + 2.Balance Inquiry (EBTBalanceInquiry) + 3.Withdraw (EBTCashBenefitWithdrawal) + Host Reference Number: + References + -  PAX POSLink (Windows) API Guide, Section 4.5: Class PaymentRequest + -  PAX Interface Between ECR PC and Terminal, Section 5.2.3: Do EBT + * + */ + + public function testCase14() + { + $response = $this->device->ebtPurchase(101.01) + ->execute(); + + $this->printReceipt($response, 'testCase14 ebtPurchase'); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + + $response = $this->device->ebtBalance() + ->withCurrency(CurrencyType::CASH_BENEFITS) + ->execute(); + + $this->printReceipt($response, 'testCase14 ebtBalance'); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + + $response = $this->device->ebtWithdrawl(111.01) + ->withCurrency(CurrencyType::CASH_BENEFITS) + ->execute(); + + $this->printReceipt($response, 'testCase14 ebtWithdrawl'); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + + /* + * CONDITIONAL TEST CASE 15 Level II Corporate Card + Objective + Process the 3 types of Corporate Card transactions: No Tax, Tax Amount, and Tax Exempt; including + the passing of PO Number. + Test Card + Card #4 Magnetic stripe Visa + Procedure + 1.Select sale function for the amount of $112.34. + a.Swipe Test Card #4 + b.Receive CPC Indicator of B + c.Continue with CPCEdit transaction to account for Tax Type of Not Used. + d.Enter the PO Number of 98765432101234567 on the device. + 2.Select sale function for the amount of $123.45. + a.Swipe Test Card #4 + b.Receive CPC Indicator of R + c.Continue with CPCEdit transaction to account for Tax Type of Tax Amount for$1.00. + 3.Select sale function for the amount of $134.56. + a.Swipe test Card #4 + b.Receive CPC Indicator of S. + c.Continue with CPCEdit transaction to account for Tax Type of Tax Exempt. + d.Enter the PO Number of 98765432101234567 on device. + Pass Criteria + 1.Transactions will approve online. + References + -  PAX POSLink (Windows) API Guide, Section 4.5: Class PaymentRequest + -  PAX Interface Between ECR PC and Terminal, Section 5.2.1: Do Credit + -  PAX Interface Between ECR PC and Terminal, Section 5.5.7: Request CommercialInformation + */ + + public function testCase15() + { + $response = $this->device->creditSale(112.34) + ->withTaxType(TaxType::NOT_USED) + ->withPoNumber("98765432101234567") + ->execute(); + + $this->printReceipt($response, 'testCase15 No Tax'); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + + $response = $this->device->creditSale(123.45) + ->withTaxAmount(1) + ->withCustomerCode("987654321") + ->withTaxType(TaxType::SALES_TAX) + ->execute(); + + $this->printReceipt($response, 'testCase15 withTax'); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + + $response = $this->device->creditSale(134.5) + ->withTaxType(TaxType::TAX_EXEMPT) + ->withPoNumber("98765432101234567") + ->execute(); + + $this->printReceipt($response, 'testCase15 TAX_EXEMPT'); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } + + /* + CONDITIONAL TEST CASE 17 Approved Store and Forward sale and Upload + Objective + Process credit sale in Store and Forward, upload transaction, and close batch. + In order to access parameters and functions related to SAF, + Allow Store&Forward needs to be enabled on BroadPOS TMS. + SETSAFPARAMETERS commands are available as well. + Test Card + Card #3 EMV Visa w/ Signature CVM + Procedure + 1.Select Sale function for an amount of $4.00. Response Approved. + 2.Send SAFUPLOAD command + a.SAF Indicator = 2 + b.Result OK + 3.Initiate a Batch Close + Pass Criteria + Transaction approve in SAF and settles in a batch. + References + -  PAX POSLink (Windows) API Guide, Section 4.6: Class ManageRequest + -  PAX Interface Between ECR PC and Terminal, Section 5.1.28: Set SAF Parameters + -  PETE Store and Forward QRG + +*/ + + public function testCase17() + { + //set to saf mode + $response = $this->device->setSafMode(SafMode::STAY_OFFLINE); + + $this->assertNotNull($response); + $this->assertEquals('OK', $response->deviceResponseText); + + //credit sale in offline mode + $response = $this->device->creditSale(4.00) + ->withAllowDuplicates(1) + ->execute(); + + $this->printReceipt($response, 'testCase17 SAF creditSale'); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->deviceResponseCode); + $this->assertEquals('APPROVED OFFLINE', $response->deviceResponseText); + + //SAF upload + $response = $this->device->safUpload(SafUpload::ALL_TRANSACTION); + + $this->printReceipt($response, 'testCase17 safUpload'); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + + //batch Close + $response = $this->device->batchClose(); + + $this->printReceipt($response, 'testCase17 batchClose'); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + + //reset to online mode + $response = $this->device->setSafMode(SafMode::STAY_ONLINE); + + $this->assertNotNull($response); + $this->assertEquals('OK', $response->deviceResponseText); + } + + /* + CONDITIONAL TEST CASE 18 Declined Store and Forward transaction and Delete + (Mandatory if Conditional Test Case 17 is ran) + Objective + Process credit sale in Store and Forward, upload transaction, and delete declined transaction from terminal. + In order to access parameters and functions related to SAF, Allow Store&Forward needs to be enabled + on BroadPOS TMS. SETSAFPARAMETERS commands are available as well. + Test Card + Card #3 EMV Visa w/ Signature CVM + Procedure + 1.Select Sale function for an amount of $10.25. Response Approved. + 2.Send SAFUPLOAD command + a.SAF Indicator = 2 + b.Transaction will decline + 3.Perform DELETESAFFILE + a.SAF Indicator = 2 + Pass Criteria + Transaction approved in SAF and declines when uploaded. Delete record from terminal. + References + -  PAX POSLink (Windows) API Guide, Section 4.6: Class ManageRequest + -  PAX Interface Between ECR PC and Terminal, Section 5.1.28: Set SAF Parameters + -  PETE Store and Forward QRG +*/ + + public function testCase18() + { + + //set to saf mode + $response = $this->device->setSafMode(SafMode::STAY_OFFLINE); + + $this->assertNotNull($response); + $this->assertEquals('OK', $response->deviceResponseText); + + //credit auth in offline mode + $response = $this->device->creditAuth(10.25) + ->withAllowDuplicates(1) + ->execute(); + + $this->printReceipt($response, 'testCase18 SAF creditSale'); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->deviceResponseCode); + + //SAF upload + $response = $this->device->safUpload(SafUpload::ALL_TRANSACTION); + + $this->printReceipt($response, 'testCase18 safUpload'); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + + //SAF Delete + $response = $this->device->safDelete(SafDelete::FAILED_TRANSACTION); + + $this->printReceipt($response, 'testCase18 safDelete'); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + + //reset to online mode + $response = $this->device->setSafMode(SafMode::STAY_ONLINE); + + $this->assertNotNull($response); + $this->assertEquals('OK', $response->deviceResponseText); + } + + /* + CONDITIONAL TEST CASE 19 Batch Close + (Mandatory if Conditional Test Cases are ran) + Objective + Close the batch, ensuring all approved transactions (offline or online) are settled. + Integrators are automatically provided accounts with auto-close enabled, so if manual batch transmission will + not be performed in the production environment then it does not need to be tested. + Test Card + N/A + Procedure + Initiate a Batch Close command + Pass Criteria + Batch submission must be successful. + References + -  PAX POSLink (Windows) API Guide, Section 4.5: Class BatchRequest + -  PAX Interface Between ECR PC and Terminal, Section 5.3.1: Batch Close + * + */ + + public function testCase19() + { + $response = $this->device->batchClose(); + + $this->printReceipt($response, 'testCase19 batchClose'); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->deviceResponseCode); + } +} diff --git a/test/Integration/Gateways/TransITConnector/Certification/DirectMarketingMOTO_3.php b/test/Integration/Gateways/TransITConnector/Certification/DirectMarketingMOTO_3.php new file mode 100644 index 00000000..d7be5130 --- /dev/null +++ b/test/Integration/Gateways/TransITConnector/Certification/DirectMarketingMOTO_3.php @@ -0,0 +1,721 @@ +getConfig()); + } + + public function getConfig() { + $config = new ServicesConfig(); + $config->merchantId = '887000003226'; + $config->username = 'TA5622118'; + $config->password = 'f8mapGqWrE^rVaA9'; + $config->deviceId = '88700000322601'; + $config->transactionKey = '2HZFSJ98G4XEGHXGP31IRLLG8H3XAWB2'; + $config->developerId = '003226G001'; + $config->gatewayProvider = GatewayProvider::TRANSIT; + $config->acceptorConfig = new AcceptorConfig(); // might need to adjust this per transaction or per file + $config->acceptorConfig->operatingEnvironment = OperatingEnvironment::ON_MERCHANT_PREMISES_ATTENDED; + $config->acceptorConfig->cardDataSource = CardDataSource::PHONE; + return $config; + } + + public function getMailConfig() { + $mailConfig = $this->getConfig(); + $mailConfig->acceptorConfig->cardDataSource = CardDataSource::MAIL; + return $mailConfig; + } + + public static $visaMUT; + public static $visaMUTCardBrandTransactionId; + public static $masterCardMUT; + public static $test22VoidTarget; + public static $test23VoidTarget; + public static $test29RefundTarget; + public static $test30RefundTarget; + public static $test32VoidTarget; + + public function test01VisaLevelII() { + + $commercialData = new CommercialData(TaxType::NOT_USED); + $commercialData->poNumber = '9876543210'; + $commercialData->taxAmount = 0; + + $response = $this->getVisa1()->charge(.52) + ->withCurrency("USD") + ->withCommercialData($commercialData) + ->withDescription("test01VisaLevelII") + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test02MasterCardLevelII() { + $commercialData = new CommercialData(TaxType::SALES_TAX); + $commercialData->poNumber = '9876543210'; + $commercialData->taxAmount = .02; + + $response = $this->getMCKeyedTIC()->charge(.52) + ->withCurrency("USD") + ->withCommercialData($commercialData) + ->withDescription("test02MasterCardLevelII") + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test03AmexManualLevelII() { + $commercialData = new CommercialData(TaxType::NOT_USED); + $commercialData->supplierReferenceNumber = "123456"; + $commercialData->customerReferenceId = "987654"; + $commercialData->destinationPostalCode = "85284"; + $commercialData->description = "AMEX LEVEL 2 TEST CASE"; + $commercialData->taxAmount = 0; + + $response = $this->getAmex()->charge(1.50) + ->withCurrency('USD') + ->withCommercialData($commercialData) + ->withDescription('test03AmexManualLevelII') + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test04MasterCard2BINSale() { + $response = $this->getMC2BIN()->charge(11.10) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test04_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test05DiscoverSale() { + $response = $this->getDiscover()->charge(12.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test05_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test06DinersAuth() { + $response = $this->getDiners()->authorize(6.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test06_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + // $this->assertEquals(5.55, $response->authorizedAmount); test script is wrong, gateway doesn't return partial auth on this test + } + + public function test07MasterCardSale() { + $response = $this->getMCUnclassifiedTIC()->charge(15.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test07_' . time()) + ->execute(); + + self::$test22VoidTarget = $response->transactionId; + + $this->assertEquals('00', $response->responseCode); + } + + public function test08JCBSale() { + ServicesContainer::configure($this->getMailConfig()); + + $response = $this->getJCB()->charge(13.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test08_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test09VisaSale() { + ServicesContainer::configure($this->getMailConfig()); + + $response = $this->getVisa1()->charge(32.49) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test09_' . time()) + ->execute(); + + self::$test30RefundTarget = $response->transactionId; + $this->assertEquals('00', $response->responseCode); + } + + public function test10DiscoverCUPSale() { + ServicesContainer::configure($this->getMailConfig()); + + $response = $this->getDiscoverCUP()->charge(7.05) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test10_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test11VisaSale() { + ServicesContainer::configure($this->getMailConfig()); + + $response = $this->getVisa1()->charge(11.12) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test11_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + self::$test29RefundTarget = $response->transactionId; + } + + public function test12AMEXSale() { + ServicesContainer::configure($this->getMailConfig()); + + $response = $this->getAmex()->charge(4.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test12_' . time()) + ->execute(); + + self::$test23VoidTarget = $response->transactionId; + + $this->assertEquals('00', $response->responseCode); + } + + public function test13VisaVerify() { + $response = $this->getVisa1()->verify() + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test13_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test14MasterCardVerify() { + $response = $this->getMCUnclassifiedTIC()->verify() + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test14_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test15AMEXVerify() { + ServicesContainer::configure($this->getMailConfig()); + + $response = $this->getAmex()->verify() + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test15_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test16VisaLvl3() { + $commercialData = new CommercialData(TaxType::NOT_USED, CommercialIndicator::LEVEL_III); + $commercialData->poNumber = 1784951399984509620; + $commercialData->taxAmount = .01; + $commercialData->destinationPostalCode = '85212'; + $commercialData->destinationCountryCode = "USA"; + $commercialData->originPostalCode = "22193"; + $commercialData->summaryCommodityCode = "SCC"; + $commercialData->customerVatNumber = "123456789"; + $commercialData->vatInvoiceNumber = "UVATREF162"; + $commercialData->orderDate = date('m/d/Y'); + $commercialData->freightAmount = 0.01; + $commercialData->dutyAmount = 0.01; + $commercialData->additionalTaxDetails = new AdditionalTaxDetails( + .01, + TaxCategory::VAT, + .04, + "VAT" + ); + + $lineItem1 = new CommercialLineItem; + $lineItem1->productCode = "PRDCD1"; + $lineItem1->name = "PRDCD1NAME"; + $lineItem1->unitCost = 0.01; + $lineItem1->quantity = 1; + $lineItem1->unitOfMeasure = "METER"; + $lineItem1->description = "PRODUCT 1 NOTES"; + $lineItem1->commodityCode = "12DIGIT ACCO"; + $lineItem1->alternateTaxId = "1234567890"; + $lineItem1->creditDebitIndicator = CreditDebitIndicator::CREDIT; + $lineItem1->discountDetails = new DiscountDetails( + .50, + "Indep Sale 1", + .1, + "SALE" + ); + $lineItem1->taxAmount = 0; + $lineItem1->taxName = 'item 1 name'; + + $lineItem2 = new CommercialLineItem; + $lineItem2->productCode = "PRDCD2"; + $lineItem2->name = "PRDCD2NAME"; + $lineItem2->unitCost = 0.01; + $lineItem2->quantity = 1; + $lineItem2->unitOfMeasure = "METER"; + $lineItem2->description = "PRODUCT 2 NOTES"; + $lineItem2->commodityCode = "12DIGIT ACCO"; + $lineItem2->alternateTaxId = "1234567890"; + $lineItem2->creditDebitIndicator = CreditDebitIndicator::DEBIT; + $lineItem2->discountDetails = new DiscountDetails( + .50, + "Indep Sale 1", + .1, + "SALE" + ); + $lineItem2->taxAmount = .03; + $lineItem2->taxName = 'a tax name here'; + $lineItem2->taxType = TaxType::SALES_TAX; + $lineItem2->taxPercentage = .69; + + $commercialData->addLineItems($lineItem1, $lineItem2); // can pass multiple line items or just call this function multiple times + + $response = $this->getVisa1()->charge(.53) + ->withCurrency('USD') + ->withCommercialData($commercialData) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test17MasterCardLvl3() { + $commercialData = new CommercialData(TaxType::NOT_USED, CommercialIndicator::LEVEL_III); + $commercialData->poNumber = "9876543210"; + $commercialData->taxAmount = 0.01; + $commercialData->destinationPostalCode = "85212"; + $commercialData->destinationCountryCode = "USA"; + $commercialData->originPostalCode = "22193"; + $commercialData->summaryCommodityCode = "SCC"; + $commercialData->customerVatNumber = "123456789"; + $commercialData->vatInvoiceNumber = "UVATREF162"; + $commercialData->orderDate = date('m/d/Y'); + $commercialData->freightAmount = 0.01; + $commercialData->dutyAmount = 0.01; + $commercialData->additionalTaxDetails = new AdditionalTaxDetails(.01, TaxCategory::VAT, .04, "VAT"); + + $lineItem = new CommercialLineItem; + $lineItem->productCode = "PRDCD1"; + $lineItem->name = "PRDCD1NAME"; + $lineItem->unitCost = 0.01; + $lineItem->quantity = 1; + $lineItem->unitOfMeasure = "METER"; + $lineItem->description = "PRODUCT 1 NOTES"; + $lineItem->commodityCode = "12DIGIT ACCO"; + $lineItem->alternateTaxId = "1234567890"; + $lineItem->creditDebitIndicator = CreditDebitIndicator::CREDIT; + $lineItem->discountDetails = new DiscountDetails( + .01, + 'little discount', + 1, + 'discount type 1' + ); + $lineItem->taxAmount = 1; + $lineItem->taxName = 'a tax name here'; + $lineItem->taxPercentage = 12; + + $commercialData->addLineItems($lineItem); + + $response = $this->getMCUnclassifiedTIC()->charge(.53) + ->withCurrency('USD') + ->withCommercialData($commercialData) + ->withAddress($this->getAVSData()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function testGenerateTokensForUseWithNextTests() { + $response1 = $this->getVisa1()->tokenize() + ->execute(); + + $this->assertEquals('00', $response1->responseCode); + self::$visaMUT = $response1->token; + + $response2 = $this->getMCUnclassifiedTIC()->tokenize() + ->execute(); + + $this->assertEquals('00', $response2->responseCode); + self::$masterCardMUT = $response2->token; + } + + public function test18VisaCardAuth() { + $card = $this->getVisa1(); + $card->number = self::$visaMUT; + + $response = $card->verify() + ->withAddress($this->getAVSData()) + ->withCardOnFile(true) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + self::$visaMUTCardBrandTransactionId = $response->cardBrandTransactionId; + } + + public function test19VisaCIT() { + $storedcreds = new StoredCredential; + $storedcreds->initiator = StoredCredentialInitiator::MERCHANT; + + $card = $this->getVisa1();; + $card->token = self::$visaMUT; + $card->number = null; + + $response = $card->charge(25.50) + ->withCurrency('USD') + ->withStoredCredential($storedcreds) + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test19_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test20MCCIT() { + $storedcreds = new StoredCredential; + $storedcreds->initiator = StoredCredentialInitiator::MERCHANT; + + $cardAsMUT = $this->getMCUnclassifiedTIC(); + $cardAsMUT->number = self::$masterCardMUT; + + $response = $cardAsMUT->charge(29.75) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test20_' . time()) + ->withStoredCredential($storedcreds) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test21VisaMIT() { + $storedcreds = new StoredCredential; + $storedcreds->initiator = StoredCredentialInitiator::MERCHANT; + $storedcreds->cardBrandTransactionId = self::$visaMUTCardBrandTransactionId; + + $card = $this->getVisa1(); + $card->number = self::$visaMUT; + + $response = $card->charge(32.49) + ->withCurrency('USD') + ->withStoredCredential($storedcreds) + ->withAddress($this->getAVSData()) + ->withCardOnFile(true) + ->withClientTransactionId('test21_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test22PartialVoid() { + $response = Transaction::fromId(self::$test22VoidTarget) + ->void(5.00) + ->withDescription('PARTIAL_REVERSAL') + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test23FullVoid() { + $response = Transaction::fromId(self::$test23VoidTarget) + ->void() + ->withDescription('POST_AUTH_USER_DECLINE') + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test24VisaMultiCapture () { + $response = $this->getVisa1()->authorize(30.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test24_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + + $firstCaptureResponse = $response->capture(15.00) + ->withMultiCapture(1,2) + ->execute(); + + $this->assertEquals('00', $firstCaptureResponse->responseCode); + + $secondCaptureResponse = $response->capture(15.00) + ->withMultiCapture(2,2) + ->execute(); + + $this->assertEquals('00', $secondCaptureResponse->responseCode); + } + + public function test25MCMultiCapture () { + ServicesContainer::configure($this->getMailConfig()); + + $response = $this->getMCUnclassifiedTIC()->authorize(50.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test25_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + + $firstCaptureResponse = $response->capture(30.00) + ->withMultiCapture(1,3) + ->execute(); + + $this->assertEquals('00', $firstCaptureResponse->responseCode); + + $secondCaptureResponse = $response->capture(10.00) + ->withMultiCapture(2,3) + ->execute(); + + $this->assertEquals('00', $secondCaptureResponse->responseCode); + + $thirdCaptureResponse = $response->capture(10.00) + ->withMultiCapture(3,3) + ->execute(); + + $this->assertEquals('00', $thirdCaptureResponse->responseCode); + } + + public function test26MCMultiCapture () { + $response = $this->getMCUnclassifiedTIC()->authorize(60.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test26_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + + $captureResponse = $response->capture() + ->withMultiCapture() + ->execute(); + + $this->assertEquals('00', $captureResponse->responseCode); + } + + public function test27CloseBatch () { + $response = BatchService::closeBatch(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test28SleepBeforeProceeding () { // test script says, "Once settled wait until after the next :15 minutes to the hour before continuing with below steps", so this function should satisfy that requirement. + sleep(3900); + } + + public function test29RefundWithReference () { + $response = Transaction::fromId(self::$test29RefundTarget) + ->refund() + ->withCurrency("USD") + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test30RefundWithReference () { + $response = Transaction::fromId(self::$test30RefundTarget) + ->refund() + ->withCurrency("USD") + ->execute(); + + $this->assertEquals('00', $response->responseCode); + self::$test32VoidTarget = $response->transactionId; + } + + public function test32VoidRefund () { + $response = Transaction::fromId(self::$test32VoidTarget) + ->void() + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test33CloseBatch () { + $response = BatchService::closeBatch(); + + $this->assertEquals('00', $response->responseCode); + } + + public function getVisa1 () { + $card = new CreditCardData; + $card->number = 4012000098765439; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 999; + $card->cardType = CardType::VISA; + $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getVisa2 () { + $card = new CreditCardData; + $card->number = 4012881888818888; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 999; + $card->cardType = CardType::VISA; + $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getMCUnclassifiedTIC () { + $card = new CreditCardData; + $card->number = 5146315000000055; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 998; + $card->cardType = CardType::MASTERCARD; + $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getMCSwipeTIC () { + $card = new CreditCardData; + $card->number = 5146312200000035; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 998; + $card->cardType = CardType::MASTERCARD; + $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getMCKeyedTIC () { + $card = new CreditCardData; + $card->number = 5146312620000045; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 998; + $card->cardType = CardType::MASTERCARD; + $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getMC2BIN () { + $card = new CreditCardData; + $card->number = 2223000048400011; + $card->expYear = 25; + $card->expMonth = 12; + $card->cvn = 998; + $card->cardType = CardType::MASTERCARD; + $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getAmex () { + $card = new CreditCardData; + $card->number = 371449635392376; + $card->expYear = 25; + $card->expMonth = 12; + $card->cvn = 9997; + $card->cardType = CardType::AMEX; + $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getDiscover () { + $card = new CreditCardData; + $card->number = 6011000993026909; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 996; + $card->cardType = CardType::DISCOVER; + $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getDiscoverCUP () { + $card = new CreditCardData; + $card->number = 6282000123842342; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 996; + $card->cardType = CardType::DISCOVER; + $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getDiscoverCUP2 () { + $card = new CreditCardData; + $card->number = 6221261111112650; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 996; + $card->cardType = CardType::DISCOVER; + $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getDiners () { + $card = new CreditCardData; + $card->number = 3055155515160018; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 996; + $card->cardType = CardType::DINERS; + $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getJCB () { + $card = new CreditCardData; + $card->number = 3530142019945859; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 996; + $card->cardType = CardType::JCB; + $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getAVSData () { + $address = new Address(); + $address->streetAddress1 = '8320'; + $address->postalCode = '85284'; + return $address; + } +} diff --git a/test/Integration/Gateways/TransITConnector/Certification/Ecommerce_3.php b/test/Integration/Gateways/TransITConnector/Certification/Ecommerce_3.php new file mode 100644 index 00000000..2e19053a --- /dev/null +++ b/test/Integration/Gateways/TransITConnector/Certification/Ecommerce_3.php @@ -0,0 +1,784 @@ +getConfig()); + } + + protected function getConfig() { + $config = new ServicesConfig(); + $config->merchantId = '887000003226'; + $config->username = 'TA5622118'; + $config->password = 'Hrcb^619'; + $config->deviceId = '88700000322601'; + $config->transactionKey = '57ZL83P6A2V8KGI49QWK017C7WXG03O8'; + $config->developerId = '003226G001'; + $config->gatewayProvider = GatewayProvider::TRANSIT; + $config->acceptorConfig = new AcceptorConfig(); // might need to adjust this per transaction or per file + return $config; + } + + public static $test20VoidTarget; + public static $test21VoidTarget; + public static $test30MUT; + public static $test31MUT; + + // These are all stolen from dotnet cert file + public function test01VisaLevelII() { + $commercialData = new CommercialData(TaxType::NOT_USED); + $commercialData->poNumber = '9876543210'; + $commercialData->taxAmount = 0; + + $response = $this->getVisa1()->charge(.52) + ->withCurrency("USD") + ->withCommercialData($commercialData) + ->withDescription("test01VisaLevelII") + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test02MasterCardLevelII() { + $commercialData = new CommercialData(TaxType::SALES_TAX); + $commercialData->poNumber = '9876543210'; + $commercialData->taxAmount = .02; + + $response = $this->getMCKeyedTIC()->charge(.52) + ->withCurrency("USD") + ->withCommercialData($commercialData) + ->withDescription("test02MasterCardLevelII") + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test03AmexManualLevelII() { + $commercialData = new CommercialData(TaxType::NOT_USED); + $commercialData->supplierReferenceNumber = "123456"; + $commercialData->customerReferenceId = "987654"; + $commercialData->destinationPostalCode = "85284"; + $commercialData->description = "AMEX LEVEL 2 TEST CASE"; + $commercialData->taxAmount = 0; + + $response = $this->getAmex()->charge(1.50) + ->withCurrency('USD') + ->withCommercialData($commercialData) + ->withDescription('test03AmexManualLevelII') + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test04MasterCard2BINSale() { + $response = $this->getMC2BIN()->charge(11.10) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test04' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test05DiscoverSale() { + $response = $this->getDiscover()->charge(12.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test05' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test06DinersAuth() { + $response = $this->getDiners()->authorize(6.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test06' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + // $this->assertEquals(5.55, $response->authorizedAmount); test script is wrong, gateway doesn't return partial auth on this test + } + + public function test07MasterCardSale() { + $response = $this->getMCUnclassifiedTIC()->charge(15.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test07' . time()) + ->execute(); + + self::$test20VoidTarget = $response->transactionId; + + $this->assertEquals('00', $response->responseCode); + } + + public function test08MasterCardSale() { + $response = $this->getMCUnclassifiedTIC()->charge(34.13) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test08' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test09JCBSale() { + $response = $this->getJCB()->charge(13.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test09' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test10AMEX() { + $card = $this->getAmex(); + $card->cvn = null; + + $response = $card->charge(13.50) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test10' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test11VisaSale() { + $response = $this->getVisa1()->charge(32.49) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test11' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test12DiscoverCUPSale() { + $response = $this->getDiscoverCUP()->charge(10.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test12' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test13VisaSale() { + $response = $this->getVisa1()->charge(11.12) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test13' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test14AMEXSale() { + $response = $this->getAmex()->charge(4.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test14' . time()) + ->execute(); + + self::$test21VoidTarget = $response->transactionId; + + $this->assertEquals('00', $response->responseCode); + } + + public function test15VisaVerify() { + $response = $this->getVisa1()->verify() + ->withRequestMultiUseToken(true) + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test15' . time()) + ->execute(); + + self::$test30MUT = $response->token; + + $this->assertEquals('00', $response->responseCode); + } + + public function test15aVisaVerify() { + $response = $this->getVisa1()->verify() + // ->withRequestMultiUseToken(true) + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test15a' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test16MasterCardVerify() { + $response = $this->getMCUnclassifiedTIC()->verify() + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test16' . time()) + ->withRequestMultiUseToken(true) + ->execute(); + + self::$test31MUT = $response->token; + + $this->assertEquals('00', $response->responseCode); + } + + public function test16aMasterCardVerify() { + $response = $this->getMCUnclassifiedTIC()->verify() + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test16a' . time()) + // ->withRequestMultiUseToken(true) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test17AMEXVerify() { + $response = $this->getAmex()->verify() + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test17' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test18VisaLvl3() { + $commercialData = new CommercialData(TaxType::NOT_USED, CommercialIndicator::LEVEL_III); + $commercialData->poNumber = 1784951399984509620; + $commercialData->taxAmount = .01; + $commercialData->destinationPostalCode = '85212'; + $commercialData->destinationCountryCode = "USA"; + $commercialData->originPostalCode = "22193"; + $commercialData->summaryCommodityCode = "SCC"; + $commercialData->customerVatNumber = "123456789"; + $commercialData->vatInvoiceNumber = "UVATREF162"; + $commercialData->orderDate = date('m/d/Y'); + $commercialData->freightAmount = 0.01; + $commercialData->dutyAmount = 0.01; + $commercialData->additionalTaxDetails = new AdditionalTaxDetails( + .01, + TaxCategory::VAT, + .04, + "VAT" + ); + + $lineItem1 = new CommercialLineItem; + $lineItem1->productCode = "PRDCD1"; + $lineItem1->name = "PRDCD1NAME"; + $lineItem1->unitCost = 0.01; + $lineItem1->quantity = 1; + $lineItem1->unitOfMeasure = "METER"; + $lineItem1->description = "PRODUCT 1 NOTES"; + $lineItem1->commodityCode = "12DIGIT ACCO"; + $lineItem1->alternateTaxId = "1234567890"; + $lineItem1->creditDebitIndicator = CreditDebitIndicator::CREDIT; + $lineItem1->discountDetails = new DiscountDetails( + .50, + "Indep Sale 1", + .1, + "SALE" + ); + $lineItem1->taxAmount = 0; + $lineItem1->taxName = 'item 1 name'; + + $lineItem2 = new CommercialLineItem; + $lineItem2->productCode = "PRDCD2"; + $lineItem2->name = "PRDCD2NAME"; + $lineItem2->unitCost = 0.01; + $lineItem2->quantity = 1; + $lineItem2->unitOfMeasure = "METER"; + $lineItem2->description = "PRODUCT 2 NOTES"; + $lineItem2->commodityCode = "12DIGIT ACCO"; + $lineItem2->alternateTaxId = "1234567890"; + $lineItem2->creditDebitIndicator = CreditDebitIndicator::DEBIT; + $lineItem2->discountDetails = new DiscountDetails( + .50, + "Indep Sale 1", + .1, + "SALE" + ); + $lineItem2->taxAmount = .03; + $lineItem2->taxName = 'a tax name here'; + $lineItem2->taxType = TaxType::SALES_TAX; + $lineItem2->taxPercentage = .69; + + $commercialData->addLineItems($lineItem1, $lineItem2); // can pass multiple line items or just call this function multiple times + + $response = $this->getVisa1()->charge(.53) + ->withCurrency('USD') + ->withCommercialData($commercialData) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test19MasterCardLvl3() { + $commercialData = new CommercialData(TaxType::NOT_USED, CommercialIndicator::LEVEL_III); + $commercialData->poNumber = "9876543210"; + $commercialData->taxAmount = 0.01; + $commercialData->destinationPostalCode = "85212"; + $commercialData->destinationCountryCode = "USA"; + $commercialData->originPostalCode = "22193"; + $commercialData->summaryCommodityCode = "SCC"; + $commercialData->customerVatNumber = "123456789"; + $commercialData->vatInvoiceNumber = "UVATREF162"; + $commercialData->orderDate = date('m/d/Y'); + $commercialData->freightAmount = 0.01; + $commercialData->dutyAmount = 0.01; + $commercialData->additionalTaxDetails = new AdditionalTaxDetails(.01, TaxCategory::VAT, .04, "VAT"); + + $lineItem = new CommercialLineItem; + $lineItem->productCode = "PRDCD1"; + $lineItem->name = "PRDCD1NAME"; + $lineItem->unitCost = 0.01; + $lineItem->quantity = 1; + $lineItem->unitOfMeasure = "METER"; + $lineItem->description = "PRODUCT 1 NOTES"; + $lineItem->commodityCode = "12DIGIT ACCO"; + $lineItem->alternateTaxId = "1234567890"; + $lineItem->creditDebitIndicator = CreditDebitIndicator::CREDIT; + $lineItem->discountDetails = new DiscountDetails( + .01, + 'little discount', + 1, + 'discount type 1' + ); + $lineItem->taxAmount = 1; + $lineItem->taxName = 'a tax name here'; + $lineItem->taxPercentage = 12; + + $commercialData->addLineItems($lineItem); + + $response = $this->getMCUnclassifiedTIC()->charge(.53) + ->withCurrency('USD') + ->withCommercialData($commercialData) + ->withAddress($this->getAVSData()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test20PartialVoid() { + $response = Transaction::fromId(self::$test20VoidTarget) + ->void(5.00) + ->withDescription('PARTIAL_REVERSAL') + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test21FullVoid() { + $response = Transaction::fromId(self::$test21VoidTarget) + ->void() + ->withDescription('POST_AUTH_USER_DECLINE') + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test22Visa3DS () { + $threeDeeInfo = new ThreeDSecure(); + $threeDeeInfo->eci = 5; + $threeDeeInfo->secureCode = '1234567890123456789012345678901234567890'; + // $threeDeeInfo->ucafIndicator = UcafIndicator::FULLY_AUTHENTICATED; + // $threeDeeInfo->setVersion(Secure3dVersion::ONE); + + $card = $this->getVisa1(); + $card->threeDSecure = $threeDeeInfo; + + $response = $card->charge(1.01) + ->withCurrency('USD') + ->withClientTransactionId('test22_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test23MC3DS_V1 () { + $threeDeeInfo = new ThreeDSecure(); + $threeDeeInfo->eci = 5; + $threeDeeInfo->secureCode = '12345678901234567890123456789012'; + $threeDeeInfo->authenticationType = '21'; + $threeDeeInfo->ucafIndicator = UcafIndicator::FULLY_AUTHENTICATED; + $threeDeeInfo->setVersion(Secure3dVersion::ONE); + + $card = $this->getMCUnclassifiedTIC(); + $card->threeDSecure = $threeDeeInfo; + + $response = $card->charge(34.02) + ->withCurrency('USD') + ->withClientTransactionId('test23_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test24MC3DS_V2 () { + $threeDeeInfo = new ThreeDSecure(); + $threeDeeInfo->eci = 5; + $threeDeeInfo->secureCode = '12345678901234567890123456789012'; + $threeDeeInfo->authenticationType = '21'; + $threeDeeInfo->directoryServerTransactionId = 'c272b04f-6e7b-43a2-bb78-90f4fb94aa25'; + $threeDeeInfo->ucafIndicator = UcafIndicator::FULLY_AUTHENTICATED; + $threeDeeInfo->setVersion(Secure3dVersion::TWO); + + $card = $this->getMCUnclassifiedTIC(); + $card->threeDSecure = $threeDeeInfo; + + $response = $card->charge(34.06) + ->withCurrency('USD') + ->withClientTransactionId('test24_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test25Discover3DS () { + $threeDeeInfo = new ThreeDSecure(); + $threeDeeInfo->eci = 5; + $threeDeeInfo->secureCode = '1234567890123456789012345678901234567890'; + // $threeDeeInfo->ucafIndicator = UcafIndicator::FULLY_AUTHENTICATED; + // $threeDeeInfo->setVersion(Secure3dVersion::ONE); + + $card = $this->getDiscover(); + $card->threeDSecure = $threeDeeInfo; + + $response = $card->charge(45.02) + ->withCurrency('USD') + ->withClientTransactionId('test25_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test26Amex3DS () { + $threeDeeInfo = new ThreeDSecure(); + $threeDeeInfo->eci = 5; + $threeDeeInfo->secureCode = '1234567890123456789012345678901234567890'; + // $threeDeeInfo->ucafIndicator = UcafIndicator::FULLY_AUTHENTICATED; + // $threeDeeInfo->setVersion(Secure3dVersion::ONE); + + $card = $this->getAmex(); + $card->threeDSecure = $threeDeeInfo; + + $response = $card->charge(32.02) + ->withCurrency('USD') + ->withClientTransactionId('test26_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test27MC3DS_V2_2 () { + $threeDeeInfo = new ThreeDSecure(); + $threeDeeInfo->eci = 5; + $threeDeeInfo->authenticationValue = 'ODQzNjgwNjU0ZjM3N2JmYTg0NTM='; + $threeDeeInfo->authenticationType = '24'; + $threeDeeInfo->directoryServerTransactionId = 'c272b04f-6e7b-43a2-bb78-90f4fb94aa25'; + $threeDeeInfo->ucafIndicator = UcafIndicator::MERCHANT_RISK_BASED; + $threeDeeInfo->setVersion(Secure3dVersion::TWO); + + $card = $this->getMCUnclassifiedTIC(); + $card->threeDSecure = $threeDeeInfo; + + $response = $card->charge(34.05) + ->withCurrency('USD') + ->withClientTransactionId('test27_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test28Visa3DS_ECI6 () { + $threeDeeInfo = new ThreeDSecure(); + $threeDeeInfo->eci = 6; + $threeDeeInfo->secureCode = '1234567890123456789012345678901234567890'; + // $threeDeeInfo->ucafIndicator = UcafIndicator::FULLY_AUTHENTICATED; + // $threeDeeInfo->setVersion(Secure3dVersion::TWO); + + $card = $this->getVisa1(); + $card->threeDSecure = $threeDeeInfo; + + $response = $card->charge(.81) + ->withCurrency('USD') + ->withClientTransactionId('test28_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test29MC3DS_ECI6 () { + $threeDeeInfo = new ThreeDSecure(); + $threeDeeInfo->eci = 6; + $threeDeeInfo->secureCode = '12345678901234567890123456789012'; + $threeDeeInfo->ucafIndicator = UcafIndicator::FULLY_AUTHENTICATED; + $threeDeeInfo->setVersion(Secure3dVersion::ONE); + + $card = $this->getMCUnclassifiedTIC(); + $card->threeDSecure = $threeDeeInfo; + + $response = $card->charge(29.00) + ->withCurrency('USD') + ->withClientTransactionId('test29_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test30SaleVisaCIT () { + $storedcreds = new StoredCredential; + $storedcreds->initiator = StoredCredentialInitiator::MERCHANT; + + $cardAsMUT = $this->getVisa1(); + $cardAsMUT->number = self::$test30MUT; + + $response = $cardAsMUT->charge(14.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test30_' . time()) + ->withStoredCredential($storedcreds) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test31SaleNonVisaCIT () { + $storedcreds = new StoredCredential; + $storedcreds->initiator = StoredCredentialInitiator::MERCHANT; + + $cardAsMUT = $this->getMCUnclassifiedTIC(); + $cardAsMUT->number = self::$test31MUT; + + $response = $cardAsMUT->charge(15.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test31_' . time()) + ->withStoredCredential($storedcreds) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test32VisaMultiCapture () { + $response = $this->getVisa1()->authorize(30.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test32_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + + $firstCaptureResponse = $response->capture(15.00) + ->withMultiCapture(1, 2) + ->execute(); + + $this->assertEquals('00', $firstCaptureResponse->responseCode); + + $secondCaptureResponse = $response->capture(15.00) + ->withMultiCapture(2, 2) + ->execute(); + + $this->assertEquals('00', $secondCaptureResponse->responseCode); + } + + public function test33MCMultiCapture () { + $response = $this->getMCUnclassifiedTIC()->authorize(50.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test33_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + + $firstCaptureResponse = $response->capture(30.00) + ->withMultiCapture(1, 3) + ->execute(); + + $this->assertEquals('00', $firstCaptureResponse->responseCode); + + $secondCaptureResponse = $response->capture(10.00) + ->withMultiCapture(2, 3) + ->execute(); + + $this->assertEquals('00', $secondCaptureResponse->responseCode); + + $thirdCaptureResponse = $response->capture(10.00) + ->withMultiCapture(3, 3) + ->execute(); + + $this->assertEquals('00', $thirdCaptureResponse->responseCode); + } + + public function test34MCMultiCapture () { + $response = $this->getMCUnclassifiedTIC()->authorize(60.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test34_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + + $captureResponse = $response->capture() + ->withMultiCapture() + ->execute(); + + $this->assertEquals('00', $captureResponse->responseCode); + } + + public function test35CloseBatch () { + $response = BatchService::closeBatch(); + + $this->assertEquals('00', $response->responseCode); + } + + public function getVisa1 () { + $card = new CreditCardData; + $card->number = 4012000098765439; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 999; + $card->cardType = CardType::VISA; + return $card; + } + + public function getVisa2 () { + $card = new CreditCardData; + $card->number = 4012881888818888; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 999; + $card->cardType = CardType::VISA; + return $card; + } + + public function getMCUnclassifiedTIC () { + $card = new CreditCardData; + $card->number = 5146315000000055; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 998; + $card->cardType = CardType::MASTERCARD; + return $card; + } + + public function getMCSwipeTIC () { + $card = new CreditCardData; + $card->number = 5146312200000035; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 998; + $card->cardType = CardType::MASTERCARD; + return $card; + } + + public function getMCKeyedTIC () { + $card = new CreditCardData; + $card->number = 5146312620000045; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 998; + $card->cardType = CardType::MASTERCARD; + return $card; + } + + public function getMC2BIN () { + $card = new CreditCardData; + $card->number = 2223000048400011; + $card->expYear = 25; + $card->expMonth = 12; + $card->cvn = 998; + $card->cardType = CardType::MASTERCARD; + return $card; + } + + public function getAmex () { + $card = new CreditCardData; + $card->number = 371449635392376; + $card->expYear = 25; + $card->expMonth = 12; + $card->cvn = 9997; + $card->cardType = CardType::AMEX; + return $card; + } + + public function getDiscover () { + $card = new CreditCardData; + $card->number = 6011000993026909; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 996; + $card->cardType = CardType::DISCOVER; + return $card; + } + + public function getDiscoverCUP () { + $card = new CreditCardData; + $card->number = 6282000123842342; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 996; + $card->cardType = CardType::DISCOVER; + return $card; + } + + public function getDiscoverCUP2 () { + $card = new CreditCardData; + $card->number = 6221261111112650; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 996; + $card->cardType = CardType::DISCOVER; + return $card; + } + + public function getDiners () { + $card = new CreditCardData; + $card->number = 3055155515160018; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 996; + $card->cardType = CardType::DINERS; + return $card; + } + + public function getJCB () { + $card = new CreditCardData; + $card->number = 3530142019945859; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 996; + $card->cardType = CardType::JCB; + return $card; + } + + public function getAVSData () { + $address = new Address(); + $address->streetAddress1 = '8320'; + $address->postalCode = '85284'; + return $address; + } +} diff --git a/test/Integration/Gateways/TransITConnector/Certification/Token_Request_Only.php b/test/Integration/Gateways/TransITConnector/Certification/Token_Request_Only.php new file mode 100644 index 00000000..d28156ed --- /dev/null +++ b/test/Integration/Gateways/TransITConnector/Certification/Token_Request_Only.php @@ -0,0 +1,276 @@ +getConfig()); + } + + public function getConfig() { + $config = new ServicesConfig(); + $config->merchantId = '887000003226'; + $config->username = 'TA5622118'; + $config->password = 'f8mapGqWrE^rVaA9'; + $config->deviceId = '88700000322601'; + $config->transactionKey = '2HZFSJ98G4XEGHXGP31IRLLG8H3XAWB2'; + $config->developerId = '003226G001'; + $config->gatewayProvider = GatewayProvider::TRANSIT; + $config->acceptorConfig = new AcceptorConfig(); + $config->acceptorConfig->operatingEnvironment = OperatingEnvironment::ON_MERCHANT_PREMISES_ATTENDED; + $config->acceptorConfig->cardDataSource = CardDataSource::INTERNET; + return $config; + } + + public function getMailConfig() { + $mailConfig = $this->getConfig(); + $mailConfig->acceptorConfig->cardDataSource = CardDataSource::MAIL; + $mailConfig->acceptorConfig->operatingEnvironment = OperatingEnvironment::ON_MERCHANT_PREMISES_ATTENDED; + return $mailConfig; + } + + public function getPhoneConfig() { + $phoneConfig = $this->getConfig(); + $phoneConfig->acceptorConfig->cardDataSource = CardDataSource::PHONE; + $phoneConfig->acceptorConfig->operatingEnvironment = OperatingEnvironment::ON_MERCHANT_PREMISES_ATTENDED; + return $phoneConfig; + } + + public function test01GenerateVisaMUT() { + $response = $this->getVisa1()->tokenize()->execute(); + + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->token); + } + + public function test02GenerateMasterCardMUT() { + $response = $this->getMCUnclassifiedTIC()->tokenize()->execute(); + + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->token); + } + + public function test03GenerateMasterCardBin2MUT() { + $response = $this->getMC2BIN()->tokenize()->execute(); + + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->token); + } + + public function test04GenerateDiscoverMUT() { + $response = $this->getDiscover()->tokenize()->execute(); + + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->token); + } + + public function test05GenerateAmexMUT() { + ServicesContainer::configure($this->getPhoneConfig()); + + $response = $this->getAmex()->tokenize()->execute(); + + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->token); + } + + public function test06GenerateJCB_MUT() { + ServicesContainer::configure($this->getMailConfig()); + + $response = $this->getJCB()->tokenize()->execute(); + + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->token); + } + + public function test07GeneratDiscoverCUP_MUT() { + ServicesContainer::configure($this->getMailConfig()); + + $response = $this->getDiscoverCUP()->tokenize()->execute(); + + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->token); + } + + public function test08GenerateDinersMUT() { + ServicesContainer::configure($this->getPhoneConfig()); + + $response = $this->getDiners()->tokenize()->execute(); + + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->token); + } + + public function getVisa1 () { + $card = new CreditCardData; + $card->number = 4012000098765439; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 999; + $card->cardType = CardType::VISA; + // $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getVisa2 () { + $card = new CreditCardData; + $card->number = 4012881888818888; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 999; + $card->cardType = CardType::VISA; + // $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getMCUnclassifiedTIC () { + $card = new CreditCardData; + $card->number = 5146315000000055; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 998; + $card->cardType = CardType::MASTERCARD; + // $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getMCSwipeTIC () { + $card = new CreditCardData; + $card->number = 5146312200000035; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 998; + $card->cardType = CardType::MASTERCARD; + // $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getMCKeyedTIC () { + $card = new CreditCardData; + $card->number = 5146312620000045; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 998; + $card->cardType = CardType::MASTERCARD; + // $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getMC2BIN () { + $card = new CreditCardData; + $card->number = 2223000048400011; + $card->expYear = 25; + $card->expMonth = 12; + $card->cvn = 998; + $card->cardType = CardType::MASTERCARD; + // $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getAmex () { + $card = new CreditCardData; + $card->number = 371449635392376; + $card->expYear = 25; + $card->expMonth = 12; + $card->cvn = 9997; + $card->cardType = CardType::AMEX; + // $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getDiscover () { + $card = new CreditCardData; + $card->number = 6011000993026909; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 996; + $card->cardType = CardType::DISCOVER; + // $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getDiscoverCUP () { + $card = new CreditCardData; + $card->number = 6282000123842342; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 996; + $card->cardType = CardType::DISCOVER; + // $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getDiscoverCUP2 () { + $card = new CreditCardData; + $card->number = 6221261111112650; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 996; + $card->cardType = CardType::DISCOVER; + // $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getDiners () { + $card = new CreditCardData; + $card->number = 3055155515160018; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 996; + $card->cardType = CardType::DINERS; + // $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getJCB () { + $card = new CreditCardData; + $card->number = 3530142019945859; + $card->expYear = 20; + $card->expMonth = 12; + $card->cvn = 996; + $card->cardType = CardType::JCB; + // $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getAVSData () { + $address = new Address(); + $address->streetAddress1 = '8320'; + $address->postalCode = '85284'; + return $address; + } +} diff --git a/test/Integration/Gateways/TransITConnector/CommercialCardTest.php b/test/Integration/Gateways/TransITConnector/CommercialCardTest.php new file mode 100644 index 00000000..0033a9a8 --- /dev/null +++ b/test/Integration/Gateways/TransITConnector/CommercialCardTest.php @@ -0,0 +1,220 @@ +getConfig()); + } + + protected function getConfig() { + $config = new ServicesConfig(); + $config->merchantId = '887000003226'; + $config->username = 'TA5622118'; + $config->password = 'f8mapGqWrE^rVaA9'; + $config->deviceId = '88700000322602'; + $config->transactionKey = '2HZFSJ98G4XEGHXGP31IRLLG8H3XAWB2'; + $config->developerId = '003226G001'; + $config->gatewayProvider = GatewayProvider::TRANSIT; + $config->acceptorConfig = new AcceptorConfig(); + return $config; + } + + protected function getAddy() { + $addy = new Address(); + $addy->streetAddress1 = 'address line 1 contents'; + $addy->postalCode = '47130'; + return $addy; + } + + protected function getVisaManual() { + $visaManual = new CreditCardData(); + $visaManual->number = '4012000098765439'; + $visaManual->expMonth = 12; + $visaManual->expYear = 2020; + $visaManual->cvn = '999'; + return $visaManual; + } + + protected function getMasterCardManual() { + $masterCardManual = new CreditCardData(); + $masterCardManual->number = '5146315000000055'; + $masterCardManual->expMonth = 12; + $masterCardManual->expYear = 2020; + $masterCardManual->cvn = '998'; + return $masterCardManual; + } + + protected function getAmexManual() { + $amexManual = new CreditCardData(); + $amexManual->number = "371449635392376"; + $amexManual->expMonth = 12; + $amexManual->expYear = 2020; + $amexManual->cvn = "9997"; + return $amexManual; + } + + // These are all stolen from dotnet cert file + public function test01VisaManualLevelII() { + $commercialData = new CommercialData(TaxType::NOT_USED); + $commercialData->poNumber = '9876543210'; + $commercialData->taxAmount = 0; + + $response = $this->getVisaManual()->charge(52) + ->withCurrency("USD") + ->withCommercialData($commercialData) + ->withAddress($this->getAddy()) + ->withDescription("Test_001_Visa_Level_II_Sale") + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test02MasterCardManualLevelII() { + $commercialData = new CommercialData(TaxType::SALES_TAX); + $commercialData->poNumber = '9876543210'; + $commercialData->taxAmount = .02; + + $response = $this->getMasterCardManual()->charge(.52) + ->withCurrency("USD") + ->withCommercialData($commercialData) + ->withAddress($this->getAddy()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test03AmexManualLevelII() { + $commercialData = new CommercialData(TaxType::NOT_USED); + $commercialData->supplierReferenceNumber = "123456"; + $commercialData->customerReferenceId = "987654"; + $commercialData->destinationPostalCode = "85284"; + $commercialData->description = "AMEX LEVEL 2 TEST CASE"; + $commercialData->taxAmount = 0; + + $response = $this->getAmexManual()->charge(1.50) + ->withCurrency('USD') + ->withCommercialData($commercialData) + ->withAddress($this->getAddy()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test04VisaManualLevelIII() { + $commercialData = new CommercialData(TaxType::NOT_USED, CommercialIndicator::LEVEL_III); + $commercialData->poNumber = 1784951399984509620; + $commercialData->taxAmount = .01; + $commercialData->destinationPostalCode = '85212'; + $commercialData->destinationCountryCode = "USA"; + $commercialData->originPostalCode = "22193"; + $commercialData->summaryCommodityCode = "SCC"; + $commercialData->customerVatNumber = "123456789"; + $commercialData->vatInvoiceNumber = "UVATREF162"; + $commercialData->orderDate = date('m/d/Y'); + $commercialData->freightAmount = 0.01; + $commercialData->dutyAmount = 0.01; + $commercialData->additionalTaxDetails = new AdditionalTaxDetails( + .01, + TaxCategory::VAT, + .04, + "VAT" + ); + + $lineItem1 = new CommercialLineItem; + $lineItem1->productCode = "PRDCD1"; + $lineItem1->name = "PRDCD1NAME"; + $lineItem1->unitCost = 0.01; + $lineItem1->quantity = 1; + $lineItem1->unitOfMeasure = "METER"; + $lineItem1->description = "PRODUCT 1 NOTES"; + $lineItem1->commodityCode = "12DIGIT ACCO"; + $lineItem1->alternateTaxId = "1234567890"; + $lineItem1->creditDebitIndicator = CreditDebitIndicator::CREDIT; + $lineItem1->discountDetails = new DiscountDetails( + .50, + "Indep Sale 1", + .1, + "SALE" + ); + + $lineItem2 = new CommercialLineItem; + $lineItem2->productCode = "PRDCD2"; + $lineItem2->name = "PRDCD2NAME"; + $lineItem2->unitCost = 0.01; + $lineItem2->quantity = 1; + $lineItem2->unitOfMeasure = "METER"; + $lineItem2->description = "PRODUCT 2 NOTES"; + $lineItem2->commodityCode = "12DIGIT ACCO"; + $lineItem2->alternateTaxId = "1234567890"; + $lineItem2->creditDebitIndicator = CreditDebitIndicator::DEBIT; + $lineItem2->discountDetails = new DiscountDetails( + .50, + "Indep Sale 1", + .1, + "SALE" + ); + + $commercialData->addLineItems($lineItem1, $lineItem2); // can pass multiple line items or just call this function multiple times + + $response = $this->getVisaManual()->charge(.53) + ->withCurrency('USD') + ->withCommercialData($commercialData) + ->withAddress($this->getAddy()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test05MasterCardManualLevelIII() { + $commercialData = new CommercialData(TaxType::NOT_USED, CommercialIndicator::LEVEL_III); + $commercialData->poNumber = "9876543210"; + $commercialData->taxAmount = 0.01; + $commercialData->destinationPostalCode = "85212"; + $commercialData->destinationCountryCode = "USA"; + $commercialData->originPostalCode = "22193"; + $commercialData->summaryCommodityCode = "SCC"; + $commercialData->customerVatNumber = "123456789"; + $commercialData->vatInvoiceNumber = "UVATREF162"; + $commercialData->orderDate = date('m/d/Y'); + $commercialData->freightAmount = 0.01; + $commercialData->dutyAmount = 0.01; + $commercialData->additionalTaxDetails = new AdditionalTaxDetails(.01, TaxCategory::VAT, .04, "VAT"); + + $lineItem = new CommercialLineItem; + $lineItem->productCode = "PRDCD1"; + $lineItem->name = "PRDCD1NAME"; + $lineItem->unitCost = 0.01; + $lineItem->quantity = 1; + $lineItem->unitOfMeasure = "METER"; + $lineItem->description = "PRODUCT 1 NOTES"; + $lineItem->commodityCode = "12DIGIT ACCO"; + $lineItem->alternateTaxId = "1234567890"; + $lineItem->creditDebitIndicator = CreditDebitIndicator::CREDIT; + $commercialData->addLineItems($lineItem); + + $response = $this->getMasterCardManual()->charge(.53) + ->withCurrency('USD') + ->withCommercialData($commercialData) + ->withAddress($this->getAddy()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } +} diff --git a/test/Integration/Gateways/TransITConnector/TransITAdminTest.php b/test/Integration/Gateways/TransITConnector/TransITAdminTest.php new file mode 100644 index 00000000..9edf946b --- /dev/null +++ b/test/Integration/Gateways/TransITConnector/TransITAdminTest.php @@ -0,0 +1,93 @@ +card = TestCards::visaManual(); + + ServicesContainer::configure($this->getConfig()); + } + + protected function getConfig() + { + $config = new ServicesConfig(); + $config->merchantId = '887000003226'; + $config->username = 'TA5622118'; + $config->password = 'f8mapGqWrE^rVaA9'; + $config->deviceId = '88700000322602'; + $config->transactionKey = '2HZFSJ98G4XEGHXGP31IRLLG8H3XAWB2'; + $config->developerId = '003226G001'; + $config->gatewayProvider = GatewayProvider::TRANSIT; + + return $config; + } + + public function testTokenizeCardKeyed() + { + $token = $this->card->tokenize()->execute(); + $this->assertNotNull($token); + $this->assertEquals('00', $token->responseCode); + $this->assertNotNull($token->token); + } + + public function testCreateManifest() + { + $config = new ServicesConfig(); + $config->merchantId = '887000003226'; + $config->username = 'TA5622118'; + $config->password = 'f8mapGqWrE^rVaA9'; + $config->deviceId = '88700000322602'; + $config->developerId = '003226G001'; + $config->gatewayProvider = GatewayProvider::TRANSIT; + + ServicesContainer::configure($config); + $provider = ServicesContainer::instance()->getClient(); + + //create Transaction Key + $response = $provider->getTransactionKey(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->transactionKey); + + //create Manifest + $provider->transactionKey = $response->transactionKey; + $manifest = $provider->createManifest(); + + $this->assertNotNull($manifest); + } + + public function testDisableTransactionKey() + { + $config = new ServicesConfig(); + $config->merchantId = '887000003226'; + $config->username = 'TA5622118'; + $config->password = 'f8mapGqWrE^rVaA9'; + $config->deviceId = '88700000322602'; + $config->developerId = '003226G001'; + //TransactionKey needs to be disabled. Throw 'Invalid Transaction Key' when key is not in active state + $config->transactionKey = 'F508Z7TIGFORSTDYJQLMK9NGFFPBIXV0'; + $config->gatewayProvider = GatewayProvider::TRANSIT; + + ServicesContainer::configure($config); + $provider = ServicesContainer::instance()->getClient(); + + //create new Transaction Key + $response = $provider->getTransactionKey(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->transactionKey); + } +} diff --git a/test/Integration/Gateways/TransITConnector/TransITDebitTest.php b/test/Integration/Gateways/TransITConnector/TransITDebitTest.php new file mode 100644 index 00000000..f6d0fd6f --- /dev/null +++ b/test/Integration/Gateways/TransITConnector/TransITDebitTest.php @@ -0,0 +1,54 @@ +track = new DebitTrackData(); + + $encryptionData = new EncryptionData(); + $encryptionData->version = '01'; + $encryptionData->ksn = '000000000000000'; + + $this->track->encryptionData = $encryptionData; + $this->track->pinBlock = '0000'; + $this->track->setValue(';'); + + ServicesContainer::configure($this->getConfig()); + } + + protected function getConfig() + { + $config = new ServicesConfig(); + $config->merchantId = '887000003226'; + $config->username = 'TA5622118'; + $config->password = 'f8mapGqWrE^rVaA9'; + $config->deviceId = '88700000322602'; + $config->transactionKey = '2HZFSJ98G4XEGHXGP31IRLLG8H3XAWB2'; + $config->developerId = '003226G001'; + + $config->gatewayProvider = GatewayProvider::TRANSIT; + return $config; + } + + public function testDebitSale() + { + $response = $this->track->charge(10) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } +} diff --git a/test/Integration/Gateways/TransITConnector/TransITTests.php b/test/Integration/Gateways/TransITConnector/TransITTests.php new file mode 100644 index 00000000..e6814e59 --- /dev/null +++ b/test/Integration/Gateways/TransITConnector/TransITTests.php @@ -0,0 +1,323 @@ +getConfig()); + + $this->address = new Address(); + $this->address->streetAddress1 = '1 Federal Street'; + $this->address->postalCode = '02110'; + + $this->card = TestCards::masterCardManual(); + + $this->track = new CreditTrackData(); + $this->track->setValue(';'); + + $this->tokenizedCard = new CreditCardData(); + $this->tokenizedCard->token = '5RpF5t9Asb9U6527'; + } + + protected function getConfig() + { + $config = new ServicesConfig(); + $config->merchantId = '887000003226'; + $config->username = 'TA5622118'; + $config->password = 'f8mapGqWrE^rVaA9'; + $config->deviceId = '88700000322602'; + $config->transactionKey = '2HZFSJ98G4XEGHXGP31IRLLG8H3XAWB2'; + $config->developerId = '003226G001'; + $config->gatewayProvider = GatewayProvider::TRANSIT; + return $config; + } + + public function testAdjustTip() + { + $response = $this->card->charge(10) + ->withCurrency('USD') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + $adjust = $response->edit() + ->withGratuity(1.05) + ->execute(); + + $this->assertNotNull($adjust); + $this->assertEquals('00', $response->responseCode); + } + + public function testAuthorizeKeyed() + { + $response = $this->card->authorize(10) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertFalse($response->avsResponseCode == '0'); // verify an AVS response of some sort + } + + public function testAuthorizeSwiped() + { + $response = $this->track->authorize(100) + ->withCurrency('USD') + ->withInvoiceNumber('1264') + ->withClientTransactionId('137149') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testAuthorizeToken() + { + $response = $this->tokenizedCard->authorize(10) + ->withCurrency('USD') + ->withInvoiceNumber('1558') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testTokenizedCardSale() + { + $token = $this->card->tokenize()->execute(); + $this->assertNotNull($token); + $this->assertEquals('00', $token->responseCode); + $this->assertNotNull($token->token); + + $tokenizedCard = new CreditCardData(); + $tokenizedCard->token = $token->token; + + $response = $tokenizedCard->charge(10) + ->withCurrency('USD') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testBalanceInquiry() + { + $response = $this->card->balanceInquiry() + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testCapture() + { + $response = $this->card->authorize(10) + ->withCurrency('USD') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + $captureResponse = $response->capture()->execute(); + + $this->assertNotNull($captureResponse); + $this->assertEquals('00', $captureResponse->responseCode); + } + + public function testSaleKeyed() + { + + $response = $this->card->charge(100) + ->withCurrency('USD') + ->withAllowDuplicates(false) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testSaleSwiped() + { + $response = $this->track->charge(100) + ->withCurrency('USD') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testSaleToken() + { + $response = $this->tokenizedCard->charge(1.29) + ->withCurrency('USD') + ->withCashBack(0) + ->withConvenienceAmount(0) + ->withInvoiceNumber('1559') + ->withClientTransactionId('166909') + ->withAllowPartialAuth(false) + ->withAllowDuplicates(false) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + // Response not mapping correctly + public function testSettleBatch() + { + $response = BatchService::closeBatch(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->batchSummary); + $this->assertNotNull($response->batchSummary->totalAmount); + } + + public function testVoid() + { + $response = $this->card->charge(10) + ->withCurrency('USD') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + $voidResponse = $response->void() + ->withDescription('DEVICE_UNAVAILABLE') + ->execute(); + + $this->assertNotNull($voidResponse); + $this->assertEquals('00', $voidResponse->responseCode); + } + + public function testVerify() + { + $response = $this->card->verify() + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRequestMUTOnSale() { + $response = $this->card->charge(12.34) + ->withCurrency('USD') + ->withRequestMultiUseToken(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertNotNull($response->token); + } + + public function testRefund() + { + $response = $this->card->charge(10) + ->withCurrency('USD') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + $refundResponse = $response->refund() + ->withCurrency('USD') + ->execute(); + + $this->assertNotNull($refundResponse); + $this->assertEquals('00', $refundResponse->responseCode); + } + + public function testRefundByCard() + { + $response = $this->card->refund(15.11) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRefundBySwipe() + { + $response = $this->track->refund(15.11) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testSaleSwipedTrack1Pattern() + { + $this->track = new CreditTrackData(); + $this->track->setValue('%B5473500000000014^MC TEST CARD^251210199998888777766665555444433332'); + + $response = $this->track->charge(10) + ->withCurrency('USD') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException + * @expectedExceptionMessage amount cannot be null for this transaction type. + */ + public function testAuthorizeWithoutAmount() + { + $response = $this->card->authorize() + ->withCurrency('USD') + ->execute(); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException + * @expectedExceptionMessage amount cannot be null for this transaction type. + */ + public function testSaleWithoutAmount() + { + $response = $this->card->charge() + ->withCurrency('USD') + ->execute(); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException + * @expectedExceptionMessage amount cannot be null for this transaction type. + */ + public function testRefundWithoutAmount() + { + $response = $this->card->refund() + ->withCurrency('USD') + ->execute(); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\ConfigurationException + * @expectedExceptionMessage deviceID is required for this configuration. + */ + public function testCredentialsError() + { + $config = new ServicesConfig(); + $config->gatewayProvider = GatewayProvider::TRANSIT; + + ServicesContainer::configure($config); + } +}