File manager - Edit - /home/opticamezl/www/newok/firstdata.tar
Back
composer.json 0000604 00000001707 15174251217 0007274 0 ustar 00 { "name": "omnipay/firstdata", "type": "library", "description": "First Data driver for the Omnipay payment processing library", "keywords": [ "first data", "firstdata", "gateway", "merchant", "omnipay", "pay", "payment" ], "homepage": "https://github.com/thephpleague/omnipay-firstdata", "license": "MIT", "authors": [ { "name": "Adrian Macneil", "email": "adrian@adrianmacneil.com" }, { "name": "Omnipay Contributors", "homepage": "https://github.com/thephpleague/omnipay-firstdata/contributors" } ], "autoload": { "psr-4": { "Omnipay\\FirstData\\" : "src/" } }, "require": { "omnipay/common": "~2.0" }, "require-dev": { "omnipay/tests": "~2.0" }, "extra": { "branch-alias": { "dev-master": "2.0.x-dev" } } } .gitignore 0000604 00000000165 15174251217 0006537 0 ustar 00 /vendor composer.lock composer.phar phpunit.xml .directory .idea /documents dirlist.app dirlist.cache dirlist.vendor LICENSE 0000604 00000002047 15174251217 0005555 0 ustar 00 Copyright (c) 2012-2013 Adrian Macneil Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. README.md 0000604 00000011222 15174251217 0006022 0 ustar 00 # Omnipay: First Data **First Data driver for the Omnipay PHP payment processing library** [](https://travis-ci.org/thephpleague/omnipay-firstdata) [](https://packagist.org/packages/omnipay/firstdata) [](https://packagist.org/packages/omnipay/firstdata) [Omnipay](https://github.com/thephpleague/omnipay) is a framework agnostic, multi-gateway payment processing library for PHP 5.3+. This package implements First Data support for Omnipay. ## Installation Omnipay is installed via [Composer](http://getcomposer.org/). To install, simply add it to your `composer.json` file: ```json { "require": { "omnipay/firstdata": "~2.0" } } ``` And run composer to update your dependencies: $ curl -s http://getcomposer.org/installer | php $ php composer.phar update ## Basic Usage The following gateways are provided by this package: * FirstData_Connect * FirstData_Webservice * FirstData_Payeezy For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay) repository. ## References First Data Corporation is a global payment technology solutions company headquartered in Atlanta, Georgia, United States. First Data Corporation was incorporated in 1971. In 1980, American Express Information Services Corporation (ISC) bought 80% of First Data. First Data Corporation spun off from American Express and went public in 1992. The First Data Global Gateway Connect 2.0 is a simple payment solution for connecting an online store to the First Data Global Gateway. It provides redirect based payments (purchase() method with a corresponding completePurchase() method). It is referred to here as the "First Data Connect" gateway, currently at version 2.0. The Global Gateway was originally called the LinkPoint Gateway but since First Data's acquisition of LinkPoint it is now known as the First Data Global Gateway. As of this writing the Global Gateway version 9.0 is supported. It is referred to here as the "First Data Webservice" gateway, more correctly speaking it is the "First Data Global Web Services API", currently at version 9.0 The First Data Global Gateway e4 (previously referred to as "First Data Global", and so if you see internet references to the First Data Global Gateway, they are probably referring to this one, distinguished by having URLs like "api.globalgatewaye4.firstdata.com") is now called the Payeezy Gateway and is referred to here as the "First Data Payeezy" Gateway. The Connect, Global, and Payeezy gateways are implemented here although each have gone through a number of API changes since their initial releases. The First Data APIs are listed here: https://www.firstdata.com/en_us/customer-center/merchants/first-data-global-gateway-api-software-landing.html ### First Data Connect 2.0 The First Data Connect 2.0 Integration guide is here: https://www.firstdata.com/downloads/pdf/FDGG_Connect_2.0_Integration_Manual_v2.0.pdf ### First Data Global Web Services API 9.0 The Global Webservice API description is here: https://www.firstdata.com/downloads/pdf/FDGG_Web_Service_API_v9.0.pdf The API manual for an older (v1.1) version of the same can be found here: https://www.firstdata.com/downloads/marketing-merchant/fd_globalgatewayapi_usermanual.pdf Reference code that implements connections to this gateway can be found at: * http://ashokks.com/First-Data-Global-Gateway-Web-Service-API-Complete-PHP-Example # First Data Payeezy Gateway API details for the Payeezy gateway are here: https://support.payeezy.com/hc/en-us and here: https://support.payeezy.com/hc/en-us/articles/204029989-First-Data-Payeezy-Gateway-Web-Service-API-Reference-Guide- Reference code that implements connections to this gateway can be found at: * https://github.com/VinceG/php-first-data-api * https://github.com/loganhenson/firstdata ## Support If you are having general issues with Omnipay, we suggest posting on [Stack Overflow](http://stackoverflow.com/). Be sure to add the [omnipay tag](http://stackoverflow.com/questions/tagged/omnipay) so it can be easily found. If you want to keep up to date with release anouncements, discuss ideas for the project, or ask more detailed questions, there is also a [mailing list](https://groups.google.com/forum/#!forum/omnipay) which you can subscribe to. If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/thephpleague/omnipay-firstdata/issues), or better yet, fork the library and submit a pull request. CONTRIBUTING.md 0000604 00000001040 15174251217 0006771 0 ustar 00 # Contributing Guidelines * Fork the project. * Make your feature addition or bug fix. * Add tests for it. This is important so I don't break it in a future version unintentionally. * Commit just the modifications, do not mess with the composer.json or CHANGELOG.md files. * Ensure your code is nicely formatted in the [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) style and that all tests pass. * Send the pull request. * Check that the Travis CI build passed. If not, rinse and repeat. src/ConnectGateway.php 0000604 00000012263 15174251217 0010764 0 ustar 00 <?php /** * First Data Connect Gateway */ namespace Omnipay\FirstData; use Omnipay\Common\AbstractGateway; /** * First Data Connect Gateway * * The First Data Global Gateway Connect 2.0 is a simple payment solution for connecting an * online store to the First Data Global Gateway. It is referred to here as the "First Data * Connect" gateway, currently at version 2.0. * * First Data Connect supports both a redirect method of payment and a direct post * method of payment. So far only the direct post method of payment is supported by * this gateway code. * * ### Form Hosting * * First Data Global Gateway Connect 2.0 allows two ways for collecting payment: * * * A redirect mode which uses the ready-made form pages for the payment process that * First Data provides. With this option, you forward your customers to First Data * for payment. They enter the cardholder data on First Data’s payment page. * Afterwards, Connect 2.0 redirects the customer back to your website and notifies * your website of the payment result. * * * You can create your own payment forms and host them on your server. Although your * server hosts the forms, your website sends the cardholder data directly from the * customer to the First Data Global Gateway * * ### Payment Modes * * First Data Global Gateway Connect 2.0 supports three different payment modes. * * * In PayOnly mode, First Data Global Gateway Connect 2.0 collects the minimum * information needed to process a transaction. * * * In PayPlus mode, First Data Global Gateway Connect 2.0 collects the same payment * information as in PayOnly mode plus a full set of billing information. * * * In FullPay mode, First Data Global Gateway Connect 2.0 collects the same payment * and billing information collected in PayPlus mode plus shipping information. * * ### Test Accounts * * You can apply for a test account at this URL: * * http://www.firstdata.com/product_solutions/ecommerce/global_gateway/index.htm * * There are some issues with obtaining shared secrets for testing Connect 2.0. * * ### Example * * <code> * // Create a gateway for the First Data Connect Gateway * // (routes to GatewayFactory::create) * $gateway = Omnipay::create('FirstData_Connect'); * * // Initialise the gateway * $gateway->initialize(array( * 'storeId' => '12341234', * 'sharedSecret' => 'IcantTELLyouITSaSECRET', * 'testMode' => true, // Or false when you are ready for live transactions * )); * * // Do a purchase transaction on the gateway * $transaction = $gateway->purchase(array( * 'description' => 'Your order for widgets', * 'amount' => '10.00', * 'transactionId' => 12345, * )); * $response = $transaction->send(); * if ($response->isSuccessful()) { * echo "Purchase transaction was successful!\n"; * $sale_id = $response->getTransactionReference(); * echo "Transaction reference = " . $sale_id . "\n"; * } * </code> * * @link https://www.firstdata.com/downloads/pdf/FDGG_Connect_2.0_Integration_Manual_v2.0.pdf */ class ConnectGateway extends AbstractGateway { public function getName() { return 'First Data Connect'; } public function getDefaultParameters() { return array( 'storeId' => '', 'sharedSecret' => '', 'testMode' => false, ); } /** * Set Store ID * * Calls to the Connect Gateway API are secured with a store ID and * shared secret. * * @return ConnectGateway provides a fluent interface */ public function setStoreId($value) { return $this->setParameter('storeId', $value); } /** * Get Store ID * * Calls to the Connect Gateway API are secured with a store ID and * shared secret. * * @return string */ public function getStoreId() { return $this->getParameter('storeId'); } /** * Set Shared Secret * * Calls to the Connect Gateway API are secured with a store ID and * shared secret. * * @return ConnectGateway provides a fluent interface */ public function setSharedSecret($value) { return $this->setParameter('sharedSecret', $value); } /** * Get Shared Secret * * Calls to the Connect Gateway API are secured with a store ID and * shared secret. * * @return string */ public function getSharedSecret() { return $this->getParameter('sharedSecret'); } /** * Create a purchase request. * * @param array $parameters * @return \Omnipay\FirstData\Message\PurchaseRequest */ public function purchase(array $parameters = array()) { return $this->createRequest('\Omnipay\FirstData\Message\PurchaseRequest', $parameters); } /** * Create a complete purchase request. * * @param array $parameters * @return \Omnipay\FirstData\Message\CompletePurchaseRequest */ public function completePurchase(array $parameters = array()) { return $this->createRequest('\Omnipay\FirstData\Message\CompletePurchaseRequest', $parameters); } } src/GlobalGateway.php 0000604 00000000356 15174251217 0010573 0 ustar 00 <?php /** * First Data Global Gateway */ namespace Omnipay\FirstData; /** * First Data Global Gateway * * This gateway has been deprecated and is now called the "Payeezy" Gateway. */ class GlobalGateway extends PayeezyGateway { } src/PayeezyGateway.php 0000604 00000015161 15174251217 0011021 0 ustar 00 <?php /** * First Data Payeezy Gateway */ namespace Omnipay\FirstData; use Omnipay\Common\AbstractGateway; /** * First Data Payeezy Gateway * * The First Data Global Gateway e4 (previously referred to as "First Data Global", and so if you see * internet references to the First Data Global Gateway, they are probably referring to this one, distinguished * by having URLs like "api.globalgatewaye4.firstdata.com") is now called the Payeezy Gateway and is * referred to here as the First Data Payeezy Gateway. * * API details for the Payeezy gateway are at the links below. * * ### Example * * <code> * // Create a gateway for the First Data Payeezy Gateway * // (routes to GatewayFactory::create) * $gateway = Omnipay::create('FirstData_Payeezy'); * * // Initialise the gateway * $gateway->initialize(array( * 'gatewayId' => '12341234', * 'password' => 'thisISmyPASSWORD', * 'testMode' => true, // Or false when you are ready for live transactions * )); * * // Create a credit card object * $card = new CreditCard(array( * 'firstName' => 'Example', * 'lastName' => 'Customer', * 'number' => '4222222222222222', * 'expiryMonth' => '01', * 'expiryYear' => '2020', * 'cvv' => '123', * 'email' => 'customer@example.com', * 'billingAddress1' => '1 Scrubby Creek Road', * 'billingCountry' => 'AU', * 'billingCity' => 'Scrubby Creek', * 'billingPostcode' => '4999', * 'billingState' => 'QLD', * )); * * // Do a purchase transaction on the gateway * $transaction = $gateway->purchase(array( * 'description' => 'Your order for widgets', * 'amount' => '10.00', * 'transactionId' => 12345, * 'clientIp' => $_SERVER['REMOTE_ADDR'], * 'card' => $card, * )); * $response = $transaction->send(); * if ($response->isSuccessful()) { * echo "Purchase transaction was successful!\n"; * $sale_id = $response->getTransactionReference(); * echo "Transaction reference = " . $sale_id . "\n"; * } * </code> * * ### Test Accounts * * Test accounts can be obtained here: * https://provisioning.demo.globalgatewaye4.firstdata.com/signup * Note that only USD transactions are supported for test accounts. * * Once you have created a test account, log in to the gateway here: * https://demo.globalgatewaye4.firstdata.com/main * Navigate to Administration -> Terminals and click on the terminal with TERM ECOMM name, * There will be a Gateway ID displayed there and you can also generate a password. * * Test credit card numbers can be found here: * https://support.payeezy.com/hc/en-us/articles/204504235-Using-test-credit-card-numbers * * ### Quirks * * This gateway requires both a transaction reference (aka an authorization number) * and a transaction tag to implement either voids or refunds. These are referred * to in the documentation as "tagged refund" and "tagged voids". * * Card token transactions are supported (these are referred to in the documentation as * "TransArmor Multi-Pay") but have to be enabled for each merchant account. There is no * createCard method, instead a card token is generated when a zero dollar authorization * is submitted. * * Void and Refund transactions require the amount parameter. * * @link https://support.payeezy.com/hc/en-us * @link https://provisioning.demo.globalgatewaye4.firstdata.com/signup * @link https://support.payeezy.com/hc/en-us/articles/204504235-Using-test-credit-card-numbers */ class PayeezyGateway extends AbstractGateway { public function getName() { return 'First Data Payeezy'; } public function getDefaultParameters() { return array( 'gatewayid' => '', 'password' => '', 'testMode' => false, ); } /** * Get Gateway ID * * Calls to the Payeezy Gateway API are secured with a gateway ID and * password. * * @return string */ public function getGatewayId() { return $this->getParameter('gatewayid'); } /** * Set Gateway ID * * Calls to the Payeezy Gateway API are secured with a gateway ID and * password. * * @return PayeezyGateway provides a fluent interface. */ public function setGatewayId($value) { return $this->setParameter('gatewayid', $value); } /** * Get Password * * Calls to the Payeezy Gateway API are secured with a gateway ID and * password. * * @return string */ public function getPassword() { return $this->getParameter('password'); } /** * Set Password * * Calls to the Payeezy Gateway API are secured with a gateway ID and * password. * * @return PayeezyGateway provides a fluent interface. */ public function setPassword($value) { return $this->setParameter('password', $value); } /** * Create a purchase request. * * @param array $parameters * @return \Omnipay\FirstData\Message\PayeezyPurchaseRequest */ public function purchase(array $parameters = array()) { return $this->createRequest('\Omnipay\FirstData\Message\PayeezyPurchaseRequest', $parameters); } /** * Create an authorize request. * * @param array $parameters * @return \Omnipay\FirstData\Message\PayeezyAuthorizeRequest */ public function authorize(array $parameters = array()) { return $this->createRequest('\Omnipay\FirstData\Message\PayeezyAuthorizeRequest', $parameters); } /** * Create a capture request. * * @param array $parameters * @return \Omnipay\FirstData\Message\PayeezyCaptureRequest */ public function capture(array $parameters = array()) { return $this->createRequest('\Omnipay\FirstData\Message\PayeezyCaptureRequest', $parameters); } /** * Create a refund request. * * @param array $parameters * @return \Omnipay\FirstData\Message\PayeezyRefundRequest */ public function refund(array $parameters = array()) { return $this->createRequest('\Omnipay\FirstData\Message\PayeezyRefundRequest', $parameters); } /** * Create a void request. * * @param array $parameters * @return \Omnipay\FirstData\Message\PayeezyVoidRequest */ public function void(array $parameters = array()) { return $this->createRequest('\Omnipay\FirstData\Message\PayeezyVoidRequest', $parameters); } } src/Message/WebserviceAbstractRequest.php 0000604 00000030430 15174251217 0014564 0 ustar 00 <?php /** * First Data Webservice Abstract Request */ namespace Omnipay\FirstData\Message; use Omnipay\Common\Message\AbstractRequest; /** * First Data Webservice Abstract Request */ abstract class WebserviceAbstractRequest extends AbstractRequest { /** @var string Live WSDL URL */ protected $liveWsdl = "https://ws.firstdataglobalgateway.com/fdggwsapi/services/order.wsdl"; /** @var string Test WSDL URL */ protected $testWsdl = "https://ws.merchanttest.firstdataglobalgateway.com/fdggwsapi/services/order.wsdl"; /** @var string Live endpoint for direct posting XML data */ protected $liveEndpoint = 'https://ws.firstdataglobalgateway.com:443/fdggwsapi/services'; /** @var string Test endpoint for direct posting XML data */ protected $testEndpoint = 'https://ws.merchanttest.firstdataglobalgateway.com:443/fdggwsapi/services'; /** @var resource cURL handle */ protected $curl; /** @var string SOAP template */ protected $soapTemplate =' <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Header /> <SOAP-ENV:Body> %xmlBody% </SOAP-ENV:Body> </SOAP-ENV:Envelope> '; /** @var string XML template for the purchase request */ protected $xmlTemplate =''; /** * Get SSL Certificate file name * * You must establish a secure communication channel to send the HTTP request. * This ensures that the data sent between your client application and the First * Data Webservice Gateway Web Service API is encrypted and that both parties can * be sure they are communicating with each other and no one else. * * The Web Service API requires an SSL connection with client and server exchanging * certificates to guarantee this level of security. The client and server certificates * each uniquely identify the party. * * @return string */ public function getSslCertificate() { return $this->getParameter('sslCertificate'); } /** * Set SSL Certificate file name * * You must establish a secure communication channel to send the HTTP request. * This ensures that the data sent between your client application and the First * Data Webservice Gateway Web Service API is encrypted and that both parties can * be sure they are communicating with each other and no one else. * * The Web Service API requires an SSL connection with client and server exchanging * certificates to guarantee this level of security. The client and server certificates * each uniquely identify the party. * * @param string $value * @return WebserviceAbstractRequest provides a fluent interface. */ public function setSslCertificate($value) { return $this->setParameter('sslCertificate', $value); } /** * Get SSL Key file name * * You must establish a secure communication channel to send the HTTP request. * This ensures that the data sent between your client application and the First * Data Webservice Gateway Web Service API is encrypted and that both parties can * be sure they are communicating with each other and no one else. * * The Web Service API requires an SSL connection with client and server exchanging * certificates to guarantee this level of security. The client and server certificates * each uniquely identify the party. * * @return string */ public function getSslKey() { return $this->getParameter('sslKey'); } /** * Set SSL Key file name * * You must establish a secure communication channel to send the HTTP request. * This ensures that the data sent between your client application and the First * Data Webservice Gateway Web Service API is encrypted and that both parties can * be sure they are communicating with each other and no one else. * * The Web Service API requires an SSL connection with client and server exchanging * certificates to guarantee this level of security. The client and server certificates * each uniquely identify the party. * * @param string $value * @return WebserviceAbstractRequest provides a fluent interface. */ public function setSslKey($value) { return $this->setParameter('sslKey', $value); } /** * Get SSL Key password * * You must establish a secure communication channel to send the HTTP request. * This ensures that the data sent between your client application and the First * Data Webservice Gateway Web Service API is encrypted and that both parties can * be sure they are communicating with each other and no one else. * * The Web Service API requires an SSL connection with client and server exchanging * certificates to guarantee this level of security. The client and server certificates * each uniquely identify the party. * * @return string */ public function getSslKeyPassword() { return $this->getParameter('sslKeyPassword'); } /** * Set SSL Key password * * You must establish a secure communication channel to send the HTTP request. * This ensures that the data sent between your client application and the First * Data Webservice Gateway Web Service API is encrypted and that both parties can * be sure they are communicating with each other and no one else. * * The Web Service API requires an SSL connection with client and server exchanging * certificates to guarantee this level of security. The client and server certificates * each uniquely identify the party. * * @param string $value * @return WebserviceAbstractRequest provides a fluent interface. */ public function setSslKeyPassword($value) { return $this->setParameter('sslKeyPassword', $value); } /** * Get Username * * Calls to the Webservice Gateway API are secured with a username and * password sent via HTTP Basic Authentication. * * @return string */ public function getUserName() { return $this->getParameter('userName'); } /** * Set Username * * Calls to the Webservice Gateway API are secured with a username and * password sent via HTTP Basic Authentication. * * @param string $value * @return WebserviceAbstractRequest provides a fluent interface. */ public function setUserName($value) { return $this->setParameter('userName', $value); } /** * Get Password * * Calls to the Webservice Gateway API are secured with a username and * password sent via HTTP Basic Authentication. * * @return string */ public function getPassword() { return $this->getParameter('password'); } /** * Set Password * * Calls to the Webservice Gateway API are secured with a username and * password sent via HTTP Basic Authentication. * * @param string $value * @return WebserviceAbstractRequest provides a fluent interface. */ public function setPassword($value) { return $this->setParameter('password', $value); } /** * Get the base transaction data. * * @return array */ protected function getBaseData() { $data = array(); return $data; } /** * Get the transaction headers. * * @return array */ protected function getHeaders() { return array( 'Content-Type: text/xml' ); } public function getData() { $data = $this->getBaseData(); return $data; } /** * Build the cURL client. * * @return resource */ public function buildCurlClient() { // // Use PHP Native cURL because the various Soap clients (BeSimple, // PHP native SoapClient) can't handle the WSDL file. // $this->curl = curl_init($this->getEndPoint()); $sslCertificate = $this->getSslCertificate(); $sslKey = $this->getSslKey(); $sslKeyPassword = $this->getSslKeyPassword(); $userName = $this->getUsername(); $password = $this->getPassword(); $headers = $this->getHeaders(); // configuring cURL not to verify the server certificate curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, 0); // setting the path where cURL can find the client certificate curl_setopt($this->curl, CURLOPT_SSLCERT, $sslCertificate); // setting the path where cURL can find the client certificate’s // private key curl_setopt($this->curl, CURLOPT_SSLKEY, $sslKey); // setting the key password curl_setopt($this->curl, CURLOPT_SSLKEYPASSWD, $sslKeyPassword); // setting the request type to POST curl_setopt($this->curl, CURLOPT_POST, 1); // setting the content type curl_setopt($this->curl, CURLOPT_HTTPHEADER, $headers); // setting the authorization method to BASIC curl_setopt($this->curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); // supplying your credentials curl_setopt($this->curl, CURLOPT_USERPWD, $userName . ':' . $password); // telling cURL to return the HTTP response body as operation result // value when calling curl_exec curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, 1); return $this->curl; } public function sendData($data) { // // Do it with PHP Native Curl // $curl = $this->buildCurlClient(); // Create the XML body $xmlBody = $this->xmlTemplate; foreach ($data as $key => $value) { $xmlBody = str_replace('%' . $key . '%', $value, $xmlBody); } // Substitute the XML body into the template $soapBody = str_replace('%xmlBody%', $xmlBody, $this->soapTemplate); // fill the request body with the SOAP message curl_setopt($curl, CURLOPT_POSTFIELDS, $soapBody); // echo "SOAP Body\n"; // echo $soapBody; // echo "\nEND SOAP Body\n"; // Send the request $result = curl_exec($curl); // close cURL curl_close($curl); // echo "SOAP Response\n"; // echo $result; // echo "\nEND SOAP Response\n"; // Create and return a response object return $this->createResponse($result); } /** * Get the endpoint URL for the request. * * @return string */ public function getEndpoint() { return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint; } /** * Create the response object. * * Create a structure by parsing the XML data and returning a simplified * array that our WebserviceResponse class can easily pull data from. * * @param string $data XML * @return WebserviceResponse */ public function createResponse($data) { // echo "XML Data = $data\n"; // Parse the XML $parser = xml_parser_create_ns(); $intermediate_data = array(); $parsed_data = array(); xml_parse_into_struct($parser, $data, $intermediate_data); // echo "Intermediate data =\n"; // print_r($intermediate_data); // echo "\nEnd intermediate data\n"; // Invert the parsed array from this type of structure: /* [4] => Array ( [tag] => HTTP://SECURE.LINKPT.NET/FDGGWSAPI/SCHEMAS_US/FDGGWSAPI:COMMERCIALSERVICEPROVIDER [type] => complete [level] => 4 [value] => CSI ) */ // To this, which we want for our internal purposes // [COMMERCIALSERVICEPROVIDER] => CSI // We basically just strip out everything before the final ':' of the // tag and attach any value to that, ignoring any fields that come through // from the XML parser without any values. foreach ($intermediate_data as $item) { if (! empty($item['value'])) { $parsed_tag = explode(':', $item['tag']); $tag = array_pop($parsed_tag); $parsed_data[$tag] = $item['value']; } } return $this->response = new WebserviceResponse($this, $parsed_data); } } src/Message/CompletePurchaseRequest.php 0000604 00000003242 15174251217 0014246 0 ustar 00 <?php /** * First Data Connect Complete Purchase Request */ namespace Omnipay\FirstData\Message; use Omnipay\Common\Exception\InvalidResponseException; /** * First Data Connect Complete Purchase Request */ class CompletePurchaseRequest extends PurchaseRequest { public function getData() { $theirHash = (string) $this->httpRequest->request->get('response_hash'); $dateTime = (string) $this->httpRequest->request->get('txndatetime'); $amount = (string) $this->httpRequest->request->get('chargetotal'); $code = (string) $this->httpRequest->request->get('approval_code'); $ourHash = $this->createResponseHash($amount, $dateTime, $code); if ($theirHash !== $ourHash) { throw new InvalidResponseException("Callback hash does not match expected value"); } return $this->httpRequest->request->all(); } public function sendData($data) { return $this->response = new CompletePurchaseResponse($this, $data); } /** * Generate a hash string that matches the format of the one returned by the payment gateway * * @param string $amount * @param string $dateTime * @param string $code * @return string */ public function createResponseHash($amount, $dateTime, $code) { $this->validate('storeId', 'sharedSecret', 'currency'); $storeId = $this->getStoreId(); $sharedSecret = $this->getSharedSecret(); $currency = $this->getCurrencyNumeric(); $stringToHash = $sharedSecret . $code . $amount . $currency . $dateTime . $storeId; $ascii = bin2hex($stringToHash); return sha1($ascii); } } src/Message/PayeezyPurchaseRequest.php 0000604 00000005554 15174251217 0014134 0 ustar 00 <?php /** * First Data Payeezy Purchase Request */ namespace Omnipay\FirstData\Message; /** * First Data Payeezy Purchase Request * * ### Example * * <code> * // Create a gateway for the First Data Payeezy Gateway * // (routes to GatewayFactory::create) * $gateway = Omnipay::create('FirstData_Payeezy'); * * // Initialise the gateway * $gateway->initialize(array( * 'gatewayId' => '12341234', * 'password' => 'thisISmyPASSWORD', * 'testMode' => true, // Or false when you are ready for live transactions * )); * * // Create a credit card object * $card = new CreditCard(array( * 'firstName' => 'Example', * 'lastName' => 'Customer', * 'number' => '4222222222222222', * 'expiryMonth' => '01', * 'expiryYear' => '2020', * 'cvv' => '123', * 'email' => 'customer@example.com', * 'billingAddress1' => '1 Scrubby Creek Road', * 'billingCountry' => 'AU', * 'billingCity' => 'Scrubby Creek', * 'billingPostcode' => '4999', * 'billingState' => 'QLD', * )); * * // Do a purchase transaction on the gateway * $transaction = $gateway->purchase(array( * 'description' => 'Your order for widgets', * 'amount' => '10.00', * 'transactionId' => 12345, * 'clientIp' => $_SERVER['REMOTE_ADDR'], * 'card' => $card, * )); * $response = $transaction->send(); * if ($response->isSuccessful()) { * echo "Purchase transaction was successful!\n"; * $sale_id = $response->getTransactionReference(); * echo "Transaction reference = " . $sale_id . "\n"; * } * </code> */ class PayeezyPurchaseRequest extends PayeezyAbstractRequest { protected $action = self::TRAN_PURCHASE; public function getData() { $data = parent::getData(); $this->validate('amount', 'card'); $data['amount'] = $this->getAmount(); $data['currency_code'] = $this->getCurrency(); $data['reference_no'] = $this->getTransactionId(); // add credit card details $data['credit_card_type'] = self::getCardType($this->getCard()->getBrand()); $data['cc_number'] = $this->getCard()->getNumber(); $data['cardholder_name'] = $this->getCard()->getName(); $data['cc_expiry'] = $this->getCard()->getExpiryDate('my'); $data['cc_verification_str2'] = $this->getCard()->getCvv(); $data['cc_verification_str1'] = $this->getAVSHash(); $data['cvd_presence_ind'] = 1; $data['cvd_code'] = $this->getCard()->getCvv(); $data['client_ip'] = $this->getClientIp(); $data['client_email'] = $this->getCard()->getEmail(); $data['language'] = strtoupper($this->getCard()->getCountry()); return $data; } } src/Message/PayeezyResponse.php 0000604 00000007442 15174251217 0012605 0 ustar 00 <?php /** * First Data Payeezy Response */ namespace Omnipay\FirstData\Message; use Omnipay\Common\Message\AbstractResponse; use Omnipay\Common\Message\RequestInterface; /** * First Data Payeezy Response * * ### Quirks * * This gateway requires both a transaction reference (aka an authorization number) * and a transaction tag to implement either voids or refunds. These are referred * to in the documentation as "tagged refund" and "tagged voids". * * The transaction reference returned by this class' getTransactionReference is a * concatenated value of the authorization number and the transaction tag. */ class PayeezyResponse extends AbstractResponse { public function __construct(RequestInterface $request, $data) { $this->request = $request; parse_str($data, $this->data); } public function isSuccessful() { return ($this->data['transaction_approved'] == '1') ? true : false; } /** * Get an item from the internal data array * * This is a short cut function to ensure that we test that the item * exists in the data array before we try to retrieve it. * * @param $itemname * @return mixed|null */ public function getDataItem($itemname) { if (isset($this->data[$itemname])) { return $this->data[$itemname]; } return null; } /** * Get the authorization number * * This is the authorization number returned by the cardholder’s financial * institution when a transaction has been approved. This value overrides any * value sent for the Request Property of the same name. * * @return integer */ public function getAuthorizationNumber() { return $this->getDataItem('authorization_num'); } /** * Get the transaction tag. * * A unique identifier to associate with a tagged transaction. This value overrides * any value sent for the Request Property of the same name. * * @return string */ public function getTransactionTag() { return $this->getDataItem('transaction_tag'); } /** * Get the transaction reference * * Because refunding or voiding a transaction requires both the authorization number * and the transaction tag, we concatenate them together to make the transaction * reference. * * @return string */ public function getTransactionReference() { return $this->getAuthorizationNumber() . '::' . $this->getTransactionTag(); } /** * Get the transaction sequence number. * * A digit sequentially incremented number generated by Global Gateway e4 and passed * through to the financial institution. It is also passed back to the client in the * transaction response. This number can be used for tracking and audit purposes. * * @return string */ public function getSequenceNo() { return $this->getDataItem('sequence_no'); } /** * Get the credit card reference for a completed transaction. * * This is only provided if TransArmor processing is turned on for the gateway. * * @return string */ public function getCardReference() { return $this->getDataItem('transarmor_token'); } public function getMessage() { return $this->getDataItem('exact_message'); } /** * Get the error code. * * This property indicates the processing status of the transaction. Please refer * to the section on Exception Handling for further information. The Transaction_Error * property will return True if this property is not “00”. * * @return string */ public function getCode() { return $this->getDataItem('exact_resp_code'); } } src/Message/PurchaseResponse.php 0000604 00000001440 15174251217 0012721 0 ustar 00 <?php /** * First Data Connect Purchase Response */ namespace Omnipay\FirstData\Message; use Omnipay\Common\Message\AbstractResponse; use Omnipay\Common\Message\RedirectResponseInterface; /** * First Data Connect Purchase Response */ class PurchaseResponse extends AbstractResponse implements RedirectResponseInterface { public function isSuccessful() { // FIXME: This makes no sense. return false; } public function isRedirect() { return true; } public function getRedirectUrl() { // FIXME: This makes no sense. return $this->getRequest()->getEndpoint(); } public function getRedirectMethod() { return 'POST'; } public function getRedirectData() { return $this->data; } } src/Message/PayeezyRefundRequest.php 0000604 00000001241 15174251217 0013572 0 ustar 00 <?php /** * First Data Payeezy Refund Request */ namespace Omnipay\FirstData\Message; /** * First Data Payeezy Refund Request */ class PayeezyRefundRequest extends PayeezyAbstractRequest { protected $action = self::TRAN_TAGGEDREFUND; public function getData() { $data = parent::getData(); $this->validate('transactionReference', 'amount'); $data['amount'] = $this->getAmount(); $transaction_reference = $this->getTransactionReference(); list($auth, $tag) = explode('::', $transaction_reference); $data['authorization_num'] = $auth; $data['transaction_tag'] = $tag; return $data; } } src/Message/PurchaseRequest.php 0000604 00000012603 15174251217 0012556 0 ustar 00 <?php /** * First Data Connect Purchase Request */ namespace Omnipay\FirstData\Message; use Omnipay\Common\Message\AbstractRequest; use Omnipay\Common\Exception\InvalidCreditCardException; /** * First Data Connect Purchase Request */ class PurchaseRequest extends AbstractRequest { protected $liveEndpoint = 'https://www.ipg-online.com/connect/gateway/processing'; protected $testEndpoint = 'https://test.ipg-online.com/connect/gateway/processing'; protected function getDateTime() { return date("Y:m:d-H:i:s"); } /** * Set Store ID * * Calls to the Connect Gateway API are secured with a store ID and * shared secret. * * @return PurchaseRequest provides a fluent interface */ public function setStoreId($value) { return $this->setParameter('storeId', $value); } /** * Get Store ID * * Calls to the Connect Gateway API are secured with a store ID and * shared secret. * * @return string */ public function getStoreId() { return $this->getParameter('storeId'); } /** * Set Shared Secret * * Calls to the Connect Gateway API are secured with a store ID and * shared secret. * * @return PurchaseRequest provides a fluent interface */ public function setSharedSecret($value) { return $this->setParameter('sharedSecret', $value); } /** * Get Shared Secret * * Calls to the Connect Gateway API are secured with a store ID and * shared secret. * * @return string */ public function getSharedSecret() { return $this->getParameter('sharedSecret'); } public function setHostedDataId($value) { return $this->setParameter('hostedDataId', $value); } public function getHostedDataId() { return $this->getParameter('hostedDataId'); } public function setCustomerId($value) { return $this->setParameter('customerId', $value); } public function getCustomerId() { return $this->getParameter('customerId'); } public function getData() { $this->validate('amount', 'card'); $data = array(); $data['storename'] = $this->getStoreId(); $data['txntype'] = 'sale'; $data['timezone'] = 'GMT'; $data['chargetotal'] = $this->getAmount(); $data['txndatetime'] = $this->getDateTime(); $data['hash'] = $this->createHash($data['txndatetime'], $data['chargetotal']); $data['currency'] = $this->getCurrencyNumeric(); $data['mode'] = 'payonly'; $data['full_bypass'] = 'true'; $data['oid'] = $this->getParameter('transactionId'); // If no hosted data, or a number is passed, validate the whole card if (is_null($this->getHostedDataId()) || !is_null($this->getCard()->getNumber())) { $this->getCard()->validate(); } elseif (is_null($this->getCard()->getCvv())) { // Else we only require the cvv when using hosted data throw new InvalidCreditCardException("The CVV parameter is required when using hosteddataid"); } $data['cardnumber'] = $this->getCard()->getNumber(); $data['cvm'] = $this->getCard()->getCvv(); $data['expmonth'] = $this->getCard()->getExpiryDate('m'); $data['expyear'] = $this->getCard()->getExpiryDate('y'); $data['bname'] = $this->getCard()->getBillingName(); $data['baddr1'] = $this->getCard()->getBillingAddress1(); $data['baddr2'] = $this->getCard()->getBillingAddress2(); $data['bcity'] = $this->getCard()->getBillingCity(); $data['bstate'] = $this->getCard()->getBillingState(); $data['bcountry'] = $this->getCard()->getBillingCountry(); $data['bzip'] = $this->getCard()->getBillingPostcode(); $data['sname'] = $this->getCard()->getShippingName(); $data['saddr1'] = $this->getCard()->getShippingAddress1(); $data['saddr2'] = $this->getCard()->getShippingAddress2(); $data['scity'] = $this->getCard()->getShippingCity(); $data['sstate'] = $this->getCard()->getShippingState(); $data['scountry'] = $this->getCard()->getShippingCountry(); $data['szip'] = $this->getCard()->getShippingPostcode(); $data['phone'] = $this->getCard()->getPhone(); $data['email'] = $this->getCard()->getEmail(); $data['responseSuccessURL'] = $this->getParameter('returnUrl'); $data['responseFailURL'] = $this->getParameter('returnUrl'); $data['customerid'] = $this->getCustomerId(); $data['hosteddataid'] = $this->getHostedDataId(); return $data; } /** * Returns a SHA-1 hash of the transaction data. * * @param $dateTime * @param $amount * @return string */ public function createHash($dateTime, $amount) { $storeId = $this->getStoreId(); $sharedSecret = $this->getSharedSecret(); $currency = $this->getCurrencyNumeric(); $stringToHash = $storeId . $dateTime . $amount . $currency . $sharedSecret; $ascii = bin2hex($stringToHash); return sha1($ascii); } public function sendData($data) { return $this->response = new PurchaseResponse($this, $data); } public function getEndpoint() { return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint; } } src/Message/WebserviceCaptureRequest.php 0000604 00000004724 15174251217 0014433 0 ustar 00 <?php /** * First Data Webservice Capture Request */ namespace Omnipay\FirstData\Message; /** * First Data Webservice Capture Request * * ### Example * * <code> * // Create a gateway for the First Data Webservice Gateway * // (routes to GatewayFactory::create) * $gateway = Omnipay::create('FirstData_Webservice'); * * // Initialise the gateway * $gateway->initialize(array( * 'sslCertificate' => 'WS9999999._.1.pem', * 'sslKey' => 'WS9999999._.1.key', * 'sslKeyPassword' => 'sslKEYpassWORD', * 'userName' => 'WS9999999._.1', * 'password' => 'passWORD', * 'testMode' => true, * )); * * // Do a capture transaction on the gateway. This assumes that an authorize * // request has been successful, and that the transactionReference from the * // authorize request is stored in $sale_id. * $transaction = $gateway->capture(array( * 'transactionReference' => $sale_id, * )); * $response = $transaction->send(); * if ($response->isSuccessful()) { * echo "Capture transaction was successful!\n"; * $sale_id = $response->getTransactionReference(); * echo "Transaction reference = " . $sale_id . "\n"; * } * </code> */ class WebserviceCaptureRequest extends WebserviceAbstractRequest { /** @var string XML template for the capture request */ protected $xmlTemplate =' <fdggwsapi:FDGGWSApiOrderRequest xmlns:v1="http://secure.linkpt.net/fdggwsapi/schemas_us/v1" xmlns:fdggwsapi="http://secure.linkpt.net/fdggwsapi/schemas_us/fdggwsapi"> <v1:Transaction> <v1:CreditCardTxType> <v1:Type>%txn_type%</v1:Type> </v1:CreditCardTxType> <v1:TransactionDetails> <v1:OrderId>%reference_no%</v1:OrderId> </v1:TransactionDetails> </v1:Transaction> </fdggwsapi:FDGGWSApiOrderRequest> '; /** @var string Transaction type */ protected $txn_type = 'postAuth'; public function getData() { $data = parent::getData(); $data['txn_type'] = $this->txn_type; $this->validate('transactionReference'); // Fetch the original transaction reference and tdate from the // concatenated transactionReference returned by the authorize() // request. $transaction_reference = $this->getTransactionReference(); list($orderid, $tdate) = explode('::', $transaction_reference); $data['reference_no'] = $orderid; return $data; } } src/Message/PayeezyCaptureRequest.php 0000604 00000000400 15174251217 0013746 0 ustar 00 <?php /** * First Data Payeezy Capture Request */ namespace Omnipay\FirstData\Message; /** * First Data Payeezy Capture Request */ class PayeezyCaptureRequest extends PayeezyRefundRequest { protected $action = self::TRAN_TAGGEDPREAUTHCOMPLETE; } src/Message/CompletePurchaseResponse.php 0000604 00000001415 15174251217 0014414 0 ustar 00 <?php /** * First Data Connect Complete Purchase Response */ namespace Omnipay\FirstData\Message; use Omnipay\Common\Message\AbstractResponse; /** * First Data Connect Complete Purchase Response */ class CompletePurchaseResponse extends AbstractResponse { public function isSuccessful() { return isset($this->data['status']) && $this->data['status'] == 'APPROVED'; } public function getTransactionId() { return isset($this->data['oid']) ? $this->data['oid'] : null; } public function getTransactionReference() { return isset($this->data['refnumber']) ? $this->data['refnumber'] : null; } public function getMessage() { return isset($this->data['status']) ? $this->data['status'] : null; } } src/Message/WebserviceResponse.php 0000604 00000003023 15174251217 0013244 0 ustar 00 <?php /** * First Data Webservice Response */ namespace Omnipay\FirstData\Message; use Omnipay\Common\Message\AbstractResponse; /** * First Data Webservice Response * * ### Quirks * * This is a SOAP gateway and there are numerous XML issues with the data transfer * and receipt. See the gateway class for details. */ class WebserviceResponse extends AbstractResponse { /** * Get an item from the internal data array * * This is a short cut function to ensure that we test that the item * exists in the data array before we try to retrieve it. * * @param $itemname * @return mixed|null */ public function getDataItem($itemname) { if (isset($this->data[$itemname])) { return $this->data[$itemname]; } return null; } public function isSuccessful() { return ($this->getDataItem('TRANSACTIONRESULT') == 'APPROVED') ? true : false; } /** * Get the transaction reference * * Because refunding or voiding a transaction requires both the order ID * and the TDATE, we concatenate them together to make the transaction * reference. * * @return string */ public function getTransactionReference() { return $this->getDataItem('ORDERID') . '::' . $this->getDataItem('TDATE'); } public function getMessage() { return $this->getDataItem('ERRORMESSAGE'); } public function getCode() { return $this->getDataItem('TRANSACTIONRESULT'); } } src/Message/WebservicePurchaseRequest.php 0000604 00000012676 15174251217 0014607 0 ustar 00 <?php /** * First Data Webservice Purchase Request */ namespace Omnipay\FirstData\Message; /** * First Data Webservice Purchase Request * * ### Example * * <code> * // Create a gateway for the First Data Webservice Gateway * // (routes to GatewayFactory::create) * $gateway = Omnipay::create('FirstData_Webservice'); * * // Initialise the gateway * $gateway->initialize(array( * 'sslCertificate' => 'WS9999999._.1.pem', * 'sslKey' => 'WS9999999._.1.key', * 'sslKeyPassword' => 'sslKEYpassWORD', * 'userName' => 'WS9999999._.1', * 'password' => 'passWORD', * 'testMode' => true, * )); * * // Create a credit card object * $card = new CreditCard(array( * 'firstName' => 'Example', * 'lastName' => 'Customer', * 'number' => '4222222222222222', * 'expiryMonth' => '01', * 'expiryYear' => '2020', * 'cvv' => '123', * 'email' => 'customer@example.com', * 'billingAddress1' => '1 Scrubby Creek Road', * 'billingCountry' => 'AU', * 'billingCity' => 'Scrubby Creek', * 'billingPostcode' => '4999', * 'billingState' => 'QLD', * )); * * // Do a purchase transaction on the gateway * $transaction = $gateway->purchase(array( * 'accountId' => '12345', * 'amount' => '10.00', * 'transactionId' => 12345, * 'clientIp' => $_SERVER['REMOTE_ADDR'], * 'card' => $card, * )); * $response = $transaction->send(); * if ($response->isSuccessful()) { * echo "Purchase transaction was successful!\n"; * $sale_id = $response->getTransactionReference(); * echo "Transaction reference = " . $sale_id . "\n"; * } * </code> */ class WebservicePurchaseRequest extends WebserviceAbstractRequest { /** @var string XML template for the purchase request */ protected $xmlTemplate =' <fdggwsapi:FDGGWSApiOrderRequest xmlns:v1="http://secure.linkpt.net/fdggwsapi/schemas_us/v1" xmlns:fdggwsapi="http://secure.linkpt.net/fdggwsapi/schemas_us/fdggwsapi"> <v1:Transaction> <v1:CreditCardTxType> <v1:Type>%txn_type%</v1:Type> </v1:CreditCardTxType> <v1:CreditCardData> <v1:CardNumber>%card_number%</v1:CardNumber> <v1:ExpMonth>%card_expiry_month%</v1:ExpMonth> <v1:ExpYear>%card_expiry_year%</v1:ExpYear> </v1:CreditCardData> <v1:Payment> <v1:ChargeTotal>%amount%</v1:ChargeTotal> </v1:Payment> <v1:TransactionDetails> <v1:OrderId>%reference_no%</v1:OrderId> <v1:Ip>%ip%</v1:Ip> <v1:Recurring>No</v1:Recurring> </v1:TransactionDetails> <v1:Billing> <v1:CustomerID>%account_id%</v1:CustomerID> <v1:Name>%card_name%</v1:Name> <v1:Address1>%card_address1%</v1:Address1> <v1:City>%card_city%</v1:City> <v1:State>%card_state%</v1:State> <v1:Zip>%card_postcode%</v1:Zip> <v1:Country>%card_country%</v1:Country> <v1:Email>%card_email%</v1:Email> </v1:Billing> </v1:Transaction> </fdggwsapi:FDGGWSApiOrderRequest> '; /** @var string Transaction type */ protected $txn_type = 'sale'; /** * Get the request accountId * * @return string */ public function getAccountId() { return $this->getParameter('accountId'); } /** * Set the request accountId * * @param string $value * @return WebserviceAbstractRequest provides a fluent interface. */ public function setAccountId($value) { return $this->setParameter('accountId', $value); } public function getData() { $data = parent::getData(); $data['txn_type'] = $this->txn_type; // We have to make the transactionId a required parameter because // it is returned as the transactionReference, and required for // voids, refunds, and captures. The accountId parameter is also // required by First Data. $this->validate('amount', 'card', 'transactionId', 'accountId'); $data['amount'] = $this->getAmount(); $data['reference_no'] = $this->getTransactionId(); $data['ip'] = $this->getClientIp(); // Add account details $data['account_id'] = $this->getAccountId(); // add credit card details $data['card_number'] = $this->getCard()->getNumber(); $data['card_name'] = $this->getCard()->getName(); $data['card_expiry_month'] = $this->getCard()->getExpiryDate('m'); $data['card_expiry_year'] = $this->getCard()->getExpiryDate('y'); $data['card_address1'] = $this->getCard()->getBillingAddress1(); $data['card_address2'] = $this->getCard()->getBillingAddress2(); $data['card_city'] = $this->getCard()->getBillingCity(); $data['card_state'] = $this->getCard()->getBillingState(); $data['card_postcode'] = $this->getCard()->getBillingPostcode(); $data['card_country'] = $this->getCard()->getBillingCountry(); $data['card_email'] = $this->getCard()->getEmail(); $data['cvd_code'] = $this->getCard()->getCvv(); return $data; } } src/Message/WebserviceRefundRequest.php 0000604 00000005714 15174251217 0014253 0 ustar 00 <?php /** * First Data Webservice Refund Request */ namespace Omnipay\FirstData\Message; /** * First Data Webservice Refund Request * * ### Example * * <code> * // Create a gateway for the First Data Webservice Gateway * // (routes to GatewayFactory::create) * $gateway = Omnipay::create('FirstData_Webservice'); * * // Initialise the gateway * $gateway->initialize(array( * 'sslCertificate' => 'WS9999999._.1.pem', * 'sslKey' => 'WS9999999._.1.key', * 'sslKeyPassword' => 'sslKEYpassWORD', * 'userName' => 'WS9999999._.1', * 'password' => 'passWORD', * 'testMode' => true, * )); * * // Do a refund transaction on the gateway. This assumes that a purchase * // request has been successful, and that the transactionReference from the * // purchase request is stored in $sale_id. * $transaction = $gateway->refund(array( * 'transactionReference' => $sale_id, * 'amount' => 5.00, * )); * $response = $transaction->send(); * if ($response->isSuccessful()) { * echo "Refund transaction was successful!\n"; * $sale_id = $response->getTransactionReference(); * echo "Transaction reference = " . $sale_id . "\n"; * } * </code> * * ### Quirks * * In the case of a captured authorization, the transaction reference passed * to refund() must be the transaction reference returned from the capture() * request and not the transaction reference from the original authorize() * request. */ class WebserviceRefundRequest extends WebserviceAbstractRequest { /** @var string XML template for the refund request */ protected $xmlTemplate =' <fdggwsapi:FDGGWSApiOrderRequest xmlns:v1="http://secure.linkpt.net/fdggwsapi/schemas_us/v1" xmlns:fdggwsapi="http://secure.linkpt.net/fdggwsapi/schemas_us/fdggwsapi"> <v1:Transaction> <v1:CreditCardTxType> <v1:Type>%txn_type%</v1:Type> </v1:CreditCardTxType> <v1:Payment> <v1:ChargeTotal>%amount%</v1:ChargeTotal> </v1:Payment> <v1:TransactionDetails> <v1:OrderId>%reference_no%</v1:OrderId> </v1:TransactionDetails> </v1:Transaction> </fdggwsapi:FDGGWSApiOrderRequest> '; /** @var string Transaction type */ protected $txn_type = 'return'; public function getData() { $data = parent::getData(); $data['txn_type'] = $this->txn_type; $this->validate('amount', 'transactionReference'); // Fetch the original transaction reference and tdate from the // concatenated transactionReference returned by the purchase() // request. $transaction_reference = $this->getTransactionReference(); list($orderid, $tdate) = explode('::', $transaction_reference); $data['reference_no'] = $orderid; $data['tdate'] = $tdate; $data['amount'] = $this->getAmount(); return $data; } } src/Message/PayeezyAbstractRequest.php 0000604 00000014020 15174251217 0014111 0 ustar 00 <?php /** * First Data Payeezy Abstract Request */ namespace Omnipay\FirstData\Message; /** * First Data Payeezy Abstract Request */ abstract class PayeezyAbstractRequest extends \Omnipay\Common\Message\AbstractRequest { /** API version to use. See the note about the hashing requirements for v12 or higher. */ const API_VERSION = 'v11'; /** @var string live endpoint URL base */ protected $liveEndpoint = 'https://api.globalgatewaye4.firstdata.com/transaction/'; /** @var string test endpoint URL base */ protected $testEndpoint = 'https://api.demo.globalgatewaye4.firstdata.com/transaction/'; /** @var int api transaction type */ protected $transactionType = '00'; // // Transaction types // const TRAN_PURCHASE = '00'; const TRAN_PREAUTH = '01'; const TRAN_PREAUTHCOMPLETE = '02'; const TRAN_FORCEDPOST = '03'; const TRAN_REFUND = '04'; const TRAN_PREAUTHONLY = '05'; const TRAN_PAYPALORDER = '07'; const TRAN_VOID = '13'; const TRAN_TAGGEDPREAUTHCOMPLETE = '32'; const TRAN_TAGGEDVOID = '33'; const TRAN_TAGGEDREFUND = '34'; const TRAN_CASHOUT = '83'; const TRAN_ACTIVATION = '85'; const TRAN_BALANCEINQUIRY = '86'; const TRAN_RELOAD = '88'; const TRAN_DEACTIVATION = '89'; /** @var array Names of the credit card types. */ protected static $cardTypes = array( 'visa' => 'Visa', 'mastercard' => 'Mastercard', 'discover' => 'Discover', 'amex' => 'American Express', 'diners_club' => 'Diners Club', 'jcb' => 'JCB', ); /** * Get Gateway ID * * Calls to the Payeezy Gateway API are secured with a gateway ID and * password. * * @return string */ public function getGatewayId() { return $this->getParameter('gatewayid'); } /** * Set Gateway ID * * Calls to the Payeezy Gateway API are secured with a gateway ID and * password. * * @return PayeezyAbstractRequest provides a fluent interface. */ public function setGatewayId($value) { return $this->setParameter('gatewayid', $value); } /** * Get Password * * Calls to the Payeezy Gateway API are secured with a gateway ID and * password. * * @return string */ public function getPassword() { return $this->getParameter('password'); } /** * Set Password * * Calls to the Payeezy Gateway API are secured with a gateway ID and * password. * * @return PayeezyAbstractRequest provides a fluent interface. */ public function setPassword($value) { return $this->setParameter('password', $value); } /** * Set transaction type * * @param int $transactionType * @return PayeezyAbstractRequest provides a fluent interface. */ public function setTransactionType($transactionType) { $this->transactionType = $transactionType; return $this; } /** * Get transaction type * * @return int */ public function getTransactionType() { return $this->transactionType; } /** * Get the base transaction data. * * @return array */ protected function getBaseData() { $data = array(); $data['gateway_id'] = $this->getGatewayID(); $data['password'] = $this->getPassword(); $data['transaction_type'] = $this->getTransactionType(); return $data; } /** * Get the transaction headers. * * @return array */ protected function getHeaders() { return array( 'Content-Type: application/json; charset=UTF-8;', 'Accept: application/json' ); } /** * Get the card type name, from the card type code. * * @param string $type * @return string */ public static function getCardType($type) { if (isset(self::$cardTypes[$type])) { return self::$cardTypes[$type]; } return $type; } /** * Get the AVS Hash. * * Important Note about v12 or higher of the Web Service API: Merchants wishing to use * V12 or higher of the API must implement the API HMAC hash security calculation. * Further information on this subject can be found at the link below. * * @link https://support.payeezy.com/entries/22069302-api-security-hmac-hash * * @return string */ public function getAVSHash() { $parts = array(); $parts[] = $this->getCard()->getAddress1(); $parts[] = $this->getCard()->getPostcode(); $parts[] = $this->getCard()->getCity(); $parts[] = $this->getCard()->getState(); $parts[] = $this->getCard()->getCountry(); return implode('|', $parts); } public function getData() { $this->setTransactionType($this->action); $data = $this->getBaseData(); return $data; } public function sendData($data) { $client = $this->httpClient->post( $this->getEndpoint(), $this->getHeaders(), $data ); $client->getCurlOptions()->set(CURLOPT_PORT, 443); $httpResponse = $client->send(); return $this->createResponse($httpResponse->getBody()); } /** * Get the endpoint URL for the request. * * @return string */ protected function getEndpoint() { return $this->getTestMode() ? $this->testEndpoint.self::API_VERSION : $this->liveEndpoint.self::API_VERSION; } /** * Create the response object. * * @param $data * @return PayeezyResponse */ protected function createResponse($data) { return $this->response = new PayeezyResponse($this, $data); } } src/Message/WebserviceVoidRequest.php 0000604 00000005421 15174251217 0013724 0 ustar 00 <?php /** * First Data Webservice Void Request */ namespace Omnipay\FirstData\Message; /** * First Data Webservice Void Request * * ### Example * * <code> * // Create a gateway for the First Data Webservice Gateway * // (routes to GatewayFactory::create) * $gateway = Omnipay::create('FirstData_Webservice'); * * // Initialise the gateway * $gateway->initialize(array( * 'sslCertificate' => 'WS9999999._.1.pem', * 'sslKey' => 'WS9999999._.1.key', * 'sslKeyPassword' => 'sslKEYpassWORD', * 'userName' => 'WS9999999._.1', * 'password' => 'passWORD', * 'testMode' => true, * )); * * // Do a void transaction on the gateway. This assumes that a purchase * // request has been successful, and that the transactionReference from the * // purchase request is stored in $sale_id. * $transaction = $gateway->void(array( * 'transactionReference' => $sale_id, * )); * $response = $transaction->send(); * if ($response->isSuccessful()) { * echo "Void transaction was successful!\n"; * $sale_id = $response->getTransactionReference(); * echo "Transaction reference = " . $sale_id . "\n"; * } * </code> * * ### Quirks * * In the case of a captured authorization, the transaction reference passed * to void() must be the transaction reference returned from the capture() * request and not the transaction reference from the original authorize() * request. */ class WebserviceVoidRequest extends WebserviceAbstractRequest { /** @var string XML template for the void request */ protected $xmlTemplate =' <fdggwsapi:FDGGWSApiOrderRequest xmlns:v1="http://secure.linkpt.net/fdggwsapi/schemas_us/v1" xmlns:fdggwsapi="http://secure.linkpt.net/fdggwsapi/schemas_us/fdggwsapi"> <v1:Transaction> <v1:CreditCardTxType> <v1:Type>%txn_type%</v1:Type> </v1:CreditCardTxType> <v1:TransactionDetails> <v1:OrderId>%reference_no%</v1:OrderId> <v1:TDate>%tdate%</v1:TDate> </v1:TransactionDetails> </v1:Transaction> </fdggwsapi:FDGGWSApiOrderRequest> '; /** @var string Transaction type */ protected $txn_type = 'void'; public function getData() { $data = parent::getData(); $data['txn_type'] = $this->txn_type; $this->validate('transactionReference'); // Fetch the original transaction reference and tdate from the // concatenated transactionReference returned by the purchase() // request. $transaction_reference = $this->getTransactionReference(); list($orderid, $tdate) = explode('::', $transaction_reference); $data['reference_no'] = $orderid; $data['tdate'] = $tdate; return $data; } } src/Message/PayeezyAuthorizeRequest.php 0000604 00000000372 15174251217 0014325 0 ustar 00 <?php /** * First Data Payeezy Authorize Request */ namespace Omnipay\FirstData\Message; /** * First Data Payeezy Authorize Request */ class PayeezyAuthorizeRequest extends PayeezyPurchaseRequest { protected $action = self::TRAN_PREAUTH; } src/Message/PayeezyVoidRequest.php 0000604 00000000354 15174251217 0013254 0 ustar 00 <?php /** * First Data Payeezy Void Request */ namespace Omnipay\FirstData\Message; /** * First Data Payeezy Void Request */ class PayeezyVoidRequest extends PayeezyRefundRequest { protected $action = self::TRAN_TAGGEDVOID; } src/Message/WebserviceAuthorizeRequest.php 0000604 00000004211 15174251217 0014771 0 ustar 00 <?php /** * First Data Webservice Authorize Request */ namespace Omnipay\FirstData\Message; /** * First Data Webservice Authorize Request * * ### Example * * <code> * // Create a gateway for the First Data Webservice Gateway * // (routes to GatewayFactory::create) * $gateway = Omnipay::create('FirstData_Webservice'); * * // Initialise the gateway * $gateway->initialize(array( * 'sslCertificate' => 'WS9999999._.1.pem', * 'sslKey' => 'WS9999999._.1.key', * 'sslKeyPassword' => 'sslKEYpassWORD', * 'userName' => 'WS9999999._.1', * 'password' => 'passWORD', * 'testMode' => true, * )); * * // Create a credit card object * $card = new CreditCard(array( * 'firstName' => 'Example', * 'lastName' => 'Customer', * 'number' => '4222222222222222', * 'expiryMonth' => '01', * 'expiryYear' => '2020', * 'cvv' => '123', * 'email' => 'customer@example.com', * 'billingAddress1' => '1 Scrubby Creek Road', * 'billingCountry' => 'AU', * 'billingCity' => 'Scrubby Creek', * 'billingPostcode' => '4999', * 'billingState' => 'QLD', * )); * * // Do an authorize transaction on the gateway * $transaction = $gateway->authorize(array( * 'accountId' => '12345', * 'amount' => '10.00', * 'currency' => 'USD', * 'description' => 'Super Deluxe Excellent Discount Package', * 'transactionId' => 12345, * 'clientIp' => $_SERVER['REMOTE_ADDR'], * 'card' => $card, * )); * $response = $transaction->send(); * if ($response->isSuccessful()) { * echo "Authorize transaction was successful!\n"; * $sale_id = $response->getTransactionReference(); * echo "Transaction reference = " . $sale_id . "\n"; * } * </code> */ class WebserviceAuthorizeRequest extends WebservicePurchaseRequest { /** @var string Transaction type */ protected $txn_type = 'preAuth'; } src/WebserviceGateway.php 0000604 00000034546 15174251217 0011501 0 ustar 00 <?php /** * First Data Webservice Gateway */ namespace Omnipay\FirstData; use Omnipay\Common\AbstractGateway; /** * First Data Webservice Gateway * * The Webservice Gateway was originally called the LinkPoint Gateway but since First Data's * acquisition of LinkPoint it is now known as the First Data Global Gateway Web Service API. * As of this writing the Global Gateway Web Service API version 9.0 is supported. It is * referred to here as the "First Data Webservice" gateway. * * ### Quirks * * #### WSDL * * There is currently a roadblock with the implementation of this gateway in that the * WSDL is not recognised as valid by PHP's SOAP client. * * See this bug: https://bugs.php.net/bug.php?id=43868 * * PHP Fatal error: SOAP-ERROR: Parsing Schema: element * 'http://secure.linkpt.net/fdggwsapi/schemas_us/fdggwsapi:FDGGWSApiOrderRequest' * already defined in omnipay-firstdata/src/Soap/BaseSoapClient.php on line 121 * * In this gateway code we have ignored the SOAP thing completely and just constructed XML * messages to send to the gateway POST URL directly, using templates and lots of string * substitution. * * https://ws.firstdataglobalgateway.com:443/fdggwsapi/services * * Neither the native PHP SOAP client nor the BeSimple SOAP client work at all dealing * with the WSDL. * * In addition, sending a properly formed SOAP message with an XML header (of * the type <?xml ... ?>) throws an error message. The XML header must be * omitted. * * To be honest I have better things to spend my time on than dealing with such * nonsense. If people can't drag themselves out of the 19th century and use * REST APIs instead of SOAP then they can at least have the good grace and * common courtesy to get their XML handling and formatting correct. * * #### Transaction ID * * A user supplied transaction ID (transactionId parameter) must be supplied for each * purchase() or authorize() request. This is known as "OrderId" in the Webservice Gateway. * * The First Data Webservice Gateway Web Service API only accepts ASCII characters. The Order * ID cannot contain the following characters: &, %, /, or exceed 100 characters in length. * The Order ID will be restricted in such a way so that it can only accepts alpha numeric * (a-z, A-Z, 0-9) and some special characters for merchants convenience. * * #### Voids and Refunds * * Voids and Refunds require both the transactionId and the TDATE parameter returned * from the purchase (or capture) call. To make things cleaner for calling applicatons, * the transactionReference returned by getTransactionReference() after the purhcase * or capture call is the transactionId and the TDATE concatenated together and * separated by '::'. * * Refunds require an amount parameter. The amount parameter is ignored by the void * call. * * ### Authentication * * Within the SSL connection (see below), authentication is done via HTTP Basic Auth. * * First Data should provide you, as part of the connection package, a username and a * password. The username will be of the form WS*******._.1 and the password will be * a string containing letters and numbers. Provide these as the userName and password * parameters when initializing the gateway. * * ### SSL Connection Security * * The Web Service API requires an SSL connection with client and server exchanging * certificates to guarantee this level of security. The client and server certificates * each uniquely identify the party. * * First Data should provide you, as part of the connection package, at least the * following files: * * * WS____.pem (certificate file) * * WS____.key (key file) * * WS____.key.pw.txt (text file containing the password for the key) * * ... where WS___ is your username also provided by First Data (see above). * * You need to store the certificate file and the key file on disk somewhere and * pass the following parameters when initializing the gateway: * * * sslCertificate -- on disk location of the .pem certificate file. * * sslKey -- on disk location of the .key file. * * sslKeyPassword -- the password for the key (not the file name) * * In case First Data provide you with a .p12 (PKCS-12) file for the certificate * instead of a PEM file, you will need to convert the .p12 file to a .pem file * using this command: * * ``` * openssl pkcs12 -in WS____.p12 -out WS____.1.pem -clcerts -nokeys * ``` * * ### Test Accounts * * To obtain a test account, use this form: * http://www.firstdata.com/gg/apply_test_account.htm * * ### Example * * This is an example of a purchase request. * * <code> * // Create a gateway for the First Data Webservice Gateway * // (routes to GatewayFactory::create) * $gateway = Omnipay::create('FirstData_Webservice'); * * // Initialise the gateway * $gateway->initialize(array( * 'sslCertificate' => 'WS9999999._.1.pem', * 'sslKey' => 'WS9999999._.1.key', * 'sslKeyPassword' => 'sslKEYpassWORD', * 'userName' => 'WS9999999._.1', * 'password' => 'passWORD', * 'testMode' => true, * )); * * // Create a credit card object * $card = new CreditCard(array( * 'firstName' => 'Example', * 'lastName' => 'Customer', * 'number' => '4222222222222222', * 'expiryMonth' => '01', * 'expiryYear' => '2020', * 'cvv' => '123', * 'email' => 'customer@example.com', * 'billingAddress1' => '1 Scrubby Creek Road', * 'billingCountry' => 'AU', * 'billingCity' => 'Scrubby Creek', * 'billingPostcode' => '4999', * 'billingState' => 'QLD', * )); * * // Do a purchase transaction on the gateway * $transaction = $gateway->purchase(array( * 'accountId' => '12345', * 'amount' => '10.00', * 'currency' => 'USD', * 'description' => 'Super Deluxe Excellent Discount Package', * 'transactionId' => 12345, * 'clientIp' => $_SERVER['REMOTE_ADDR'], * 'card' => $card, * )); * $response = $transaction->send(); * if ($response->isSuccessful()) { * echo "Purchase transaction was successful!\n"; * $sale_id = $response->getTransactionReference(); * echo "Transaction reference = " . $sale_id . "\n"; * } * </code> * * @link https://www.firstdata.com/downloads/pdf/FDGG_Web_Service_API_v9.0.pdf */ class WebserviceGateway extends AbstractGateway { public function getName() { return 'First Data Webservice'; } public function getDefaultParameters() { return array( 'sslCertificate' => '', 'sslKey' => '', 'sslKeyPassword' => '', 'userName' => '', 'password' => '', 'testMode' => false, ); } /** * Get SSL Certificate file name * * You must establish a secure communication channel to send the HTTP request. * This ensures that the data sent between your client application and the First * Data Webservice Gateway Web Service API is encrypted and that both parties can * be sure they are communicating with each other and no one else. * * The Web Service API requires an SSL connection with client and server exchanging * certificates to guarantee this level of security. The client and server certificates * each uniquely identify the party. * * @return string */ public function getSslCertificate() { return $this->getParameter('sslCertificate'); } /** * Set SSL Certificate file name * * You must establish a secure communication channel to send the HTTP request. * This ensures that the data sent between your client application and the First * Data Webservice Gateway Web Service API is encrypted and that both parties can * be sure they are communicating with each other and no one else. * * The Web Service API requires an SSL connection with client and server exchanging * certificates to guarantee this level of security. The client and server certificates * each uniquely identify the party. * * @param string $value * @return WebserviceGateway provides a fluent interface. */ public function setSslCertificate($value) { return $this->setParameter('sslCertificate', $value); } /** * Get SSL Key file name * * You must establish a secure communication channel to send the HTTP request. * This ensures that the data sent between your client application and the First * Data Webservice Gateway Web Service API is encrypted and that both parties can * be sure they are communicating with each other and no one else. * * The Web Service API requires an SSL connection with client and server exchanging * certificates to guarantee this level of security. The client and server certificates * each uniquely identify the party. * * @return string */ public function getSslKey() { return $this->getParameter('sslKey'); } /** * Set SSL Key file name * * You must establish a secure communication channel to send the HTTP request. * This ensures that the data sent between your client application and the First * Data Webservice Gateway Web Service API is encrypted and that both parties can * be sure they are communicating with each other and no one else. * * The Web Service API requires an SSL connection with client and server exchanging * certificates to guarantee this level of security. The client and server certificates * each uniquely identify the party. * * @param string $value * @return WebserviceGateway provides a fluent interface. */ public function setSslKey($value) { return $this->setParameter('sslKey', $value); } /** * Get SSL Key password * * You must establish a secure communication channel to send the HTTP request. * This ensures that the data sent between your client application and the First * Data Global Gateway Web Service API is encrypted and that both parties can * be sure they are communicating with each other and no one else. * * The Web Service API requires an SSL connection with client and server exchanging * certificates to guarantee this level of security. The client and server certificates * each uniquely identify the party. * * @return string */ public function getSslKeyPassword() { return $this->getParameter('sslKeyPassword'); } /** * Set SSL Key password * * You must establish a secure communication channel to send the HTTP request. * This ensures that the data sent between your client application and the First * Data Global Gateway Web Service API is encrypted and that both parties can * be sure they are communicating with each other and no one else. * * The Web Service API requires an SSL connection with client and server exchanging * certificates to guarantee this level of security. The client and server certificates * each uniquely identify the party. * * @param string $value * @return WebserviceGateway provides a fluent interface. */ public function setSslKeyPassword($value) { return $this->setParameter('sslKeyPassword', $value); } /** * Get Username * * Calls to the Global Gateway API are secured with a username and * password sent via HTTP Basic Authentication. * * @return string */ public function getUserName() { return $this->getParameter('userName'); } /** * Set Username * * Calls to the Global Gateway API are secured with a username and * password sent via HTTP Basic Authentication. * * @param string $value * @return WebserviceGateway provides a fluent interface. */ public function setUserName($value) { return $this->setParameter('userName', $value); } /** * Get Password * * Calls to the Global Gateway API are secured with a username and * password sent via HTTP Basic Authentication. * * @return string */ public function getPassword() { return $this->getParameter('password'); } /** * Set Password * * Calls to the Global Gateway API are secured with a username and * password sent via HTTP Basic Authentication. * * @param string $value * @return WebserviceGateway provides a fluent interface. */ public function setPassword($value) { return $this->setParameter('password', $value); } /** * Create a purchase request. * * @param array $parameters * @return \Omnipay\FirstData\Message\WebservicePurchaseRequest */ public function purchase(array $parameters = array()) { return $this->createRequest('\Omnipay\FirstData\Message\WebservicePurchaseRequest', $parameters); } /** * Create an authorize request. * * @param array $parameters * @return \Omnipay\FirstData\Message\WebserviceAuthorizeRequest */ public function authorize(array $parameters = array()) { return $this->createRequest('\Omnipay\FirstData\Message\WebserviceAuthorizeRequest', $parameters); } /** * Create a capture request. * * @param array $parameters * @return \Omnipay\FirstData\Message\WebserviceCaptureRequest */ public function capture(array $parameters = array()) { return $this->createRequest('\Omnipay\FirstData\Message\WebserviceCaptureRequest', $parameters); } /** * Create a void request. * * @param array $parameters * @return \Omnipay\FirstData\Message\WebserviceVoidRequest */ public function void(array $parameters = array()) { return $this->createRequest('\Omnipay\FirstData\Message\WebserviceVoidRequest', $parameters); } /** * Create a refund request. * * @param array $parameters * @return \Omnipay\FirstData\Message\WebserviceRefundRequest */ public function refund(array $parameters = array()) { return $this->createRequest('\Omnipay\FirstData\Message\WebserviceRefundRequest', $parameters); } } tests/PayeezyGatewayTest.php 0000604 00000003377 15174251217 0012242 0 ustar 00 <?php namespace Omnipay\FirstData; use Omnipay\Tests\GatewayTestCase; class PayeezyGatewayTest extends GatewayTestCase { /** @var PayeezyGateway */ protected $gateway; /** @var array */ protected $options; public function setUp() { parent::setUp(); $this->gateway = new PayeezyGateway($this->getHttpClient(), $this->getHttpRequest()); $this->gateway->setGatewayId('1234'); $this->gateway->setPassword('abcde'); $this->options = array( 'amount' => '13.00', 'card' => $this->getValidCard(), 'transactionId' => 'order2', 'currency' => 'USD', 'testMode' => true, ); } public function testProperties() { $this->assertEquals('1234', $this->gateway->getGatewayId()); $this->assertEquals('abcde', $this->gateway->getPassword()); } public function testPurchaseSuccess() { $this->setMockHttpResponse('PurchaseSuccess.txt'); $response = $this->gateway->purchase($this->options)->send(); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertEquals('ET181147::28513493', $response->getTransactionReference()); $this->assertEquals('000056', $response->getSequenceNo()); $this->assertEmpty($response->getCardReference()); } public function testAuthorizeSuccess() { $this->setMockHttpResponse('PurchaseSuccess.txt'); $response = $this->gateway->authorize($this->options)->send(); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertEquals('ET181147::28513493', $response->getTransactionReference()); } } tests/Mock/WebservicePurchaseSuccess.txt 0000604 00000002430 15174251217 0014462 0 ustar 00 <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><fdggwsapi:FDGGWSApiOrderResponse xmlns:fdggwsapi="http://secure.linkpt.net/fdggwsapi/schemas_us/fdggwsapi"><fdggwsapi:CommercialServiceProvider>CSI</fdggwsapi:CommercialServiceProvider><fdggwsapi:TransactionTime>Sun Jan 10 23:34:04 2016</fdggwsapi:TransactionTime><fdggwsapi:TransactionID>21840362</fdggwsapi:TransactionID><fdggwsapi:ProcessorReferenceNumber>OK242C</fdggwsapi:ProcessorReferenceNumber><fdggwsapi:ProcessorResponseMessage>APPROVED</fdggwsapi:ProcessorResponseMessage><fdggwsapi:ErrorMessage/><fdggwsapi:OrderId>259611</fdggwsapi:OrderId><fdggwsapi:ApprovalCode>OK242C0021840362:XXRnull:</fdggwsapi:ApprovalCode><fdggwsapi:AVSResponse>XXRnull</fdggwsapi:AVSResponse><fdggwsapi:TDate>1452486844</fdggwsapi:TDate><fdggwsapi:TransactionResult>APPROVED</fdggwsapi:TransactionResult><fdggwsapi:ProcessorResponseCode>A</fdggwsapi:ProcessorResponseCode><fdggwsapi:ProcessorApprovalCode/><fdggwsapi:CalculatedTax/><fdggwsapi:CalculatedShipping/><fdggwsapi:TransactionScore>ERROR</fdggwsapi:TransactionScore><fdggwsapi:FraudAction>Configuration Error.</fdggwsapi:FraudAction><fdggwsapi:AuthenticationResponseCode/></fdggwsapi:FDGGWSApiOrderResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> tests/Mock/PurchaseSuccess.txt 0000604 00000004706 15174251217 0012453 0 ustar 00 HTTP/1.1 201 OK Date: Tue, 11 Feb 2014 02:34:58 GMT Content-type: text/html; charset=utf-8 account_number=&amount=13.0&amount_requested=&authorization=&authorization_num=ET181147&avs=1&bank_id=&bank_message=Approved&bank_resp_code=100&bank_resp_code_2=&card_cost=&cardholder_name=Example+User&cavv=&cavv_algorithm=&cavv_response=&cc_expiry=0318&cc_number=%23%23%23%23%23%23%23%23%23%23%23%231111&cc_verification_str1=123+Billing+St%7C12345%7CBillstown%7CCA%7CUS&cc_verification_str2=208&check_number=&check_type=&clerk_id=&client_email=&client_ip=104.36.244.246&correlation_id=&credit_card_type=Visa&ctr=%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D+TRANSACTION+RECORD+%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0APriceWaiter+DEMO0243%0A426+Market+St%0AChattenooga%2C+TN+37402%0AUnited+States%0Ahttps%3A%2F%2Fwww.pricewaiter.com%2F%0A%0ATYPE%3A+Purchase%0A%0AACCT%3A+Visa++%24+13.00+USD%0A%0ACARDHOLDER+NAME+%3A+Example+User%0ACARD+NUMBER+++++%3A+%23%23%23%23%23%23%23%23%23%23%23%231111%0ADATE%2FTIME+++++++%3A+11+Aug+14+14%3A09%3A06%0AREFERENCE+%23+++++%3A++000056+M%0AAUTHOR.+%23+++++++%3A+ET181147%0ATRANS.+REF.+++++%3A+order2%0A%0A++++Approved+-+Thank+You+100%0A%0A%0APlease+retain+this+copy+for+your+records.%0A%0ACardholder+will+pay+above+amount+to+card%0Aissuer+pursuant+to+cardholder+agreement.%0A%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D¤cy_code=USD¤t_balance=&customer_id_number=&customer_id_type=&customer_name=&customer_ref=&cvd_presence_ind=0&cvv2=N&date_of_birth=&device_id=&ean=&ecommerce_flag=&error_description=&error_number=&exact_message=Transaction+Normal&exact_resp_code=00&fraud_suspected=&gateway_id=AF8163-05&gift_card_amount=&gross_amount_currency_id=&language=&logon_message=&merchant_address=426+Market+St&merchant_city=Chattenooga&merchant_country=United+States&merchant_name=PriceWaiter+DEMO0243&merchant_postal=37402&merchant_province=Tennessee&merchant_url=https%3A%2F%2Fwww.pricewaiter.com%2F&message=&micr=&pan=&partial_redemption=0&password=&payer_id=&previous_balance=&reference_3=&reference_no=order2®istration_date=®istration_no=&release_type=&retrieval_ref_no=7775501&secure_auth_required=&secure_auth_result=&sequence_no=000056&success=&surcharge_amount=&tax1_amount=&tax1_number=&tax2_amount=&tax2_number=×tamp=&track1=&track2=&transaction_approved=1&transaction_error=0&transaction_tag=28513493&transaction_type=00&transarmor_token=&user_name=&vip=&virtual_card=&xid=&zip_code= tests/Mock/RefundError.txt 0000604 00000003020 15174251217 0011571 0 ustar 00 HTTP/1.1 201 OK Date: Tue, 11 Feb 2014 02:34:58 GMT Content-type: text/html; charset=utf-8 account_number=&amount=13.0&amount_requested=&authorization=&authorization_num=&avs=&bank_id=&bank_message=&bank_resp_code=&bank_resp_code_2=&card_cost=&cardholder_name=&cavv=&cavv_algorithm=&cavv_response=&cc_expiry=9999&cc_number=&cc_verification_str1=&cc_verification_str2=&check_number=&check_type=&clerk_id=&client_email=&client_ip=&correlation_id=&credit_card_type=&ctr=¤cy_code=USD¤t_balance=&customer_id_number=&customer_id_type=&customer_name=&customer_ref=&cvd_presence_ind=0&cvv2=&date_of_birth=&device_id=&ean=&ecommerce_flag=&error_description=&error_number=&exact_message=Invalid+Refund&exact_resp_code=64&fraud_suspected=&gateway_id=AF8163-05&gift_card_amount=&gross_amount_currency_id=&language=&logon_message=&merchant_address=426+Market+St&merchant_city=Chattenooga&merchant_country=United+States&merchant_name=PriceWaiter+DEMO0243&merchant_postal=37402&merchant_province=Tennessee&merchant_url=https%3A%2F%2Fwww.pricewaiter.com%2F&message=&micr=&pan=&partial_redemption=0&password=&payer_id=&previous_balance=&reference_3=&reference_no=order2®istration_date=®istration_no=&release_type=&retrieval_ref_no=&secure_auth_required=&secure_auth_result=&sequence_no=000056&success=&surcharge_amount=&tax1_amount=&tax1_number=&tax2_amount=&tax2_number=×tamp=&track1=&track2=&transaction_approved=0&transaction_error=1&transaction_tag=28513493&transaction_type=34&transarmor_token=&user_name=&vip=&virtual_card=&xid=&zip_code= tests/Mock/RefundSuccess.txt 0000604 00000003146 15174251217 0012121 0 ustar 00 HTTP/1.1 201 OK Date: Tue, 11 Feb 2014 02:34:58 GMT Content-type: text/html; charset=utf-8 account_number=&amount=13.0&amount_requested=&authorization=&authorization_num=ET181147&avs=&bank_id=&bank_message=Approved&bank_resp_code=100&bank_resp_code_2=&card_cost=&cardholder_name=Example+User&cavv=&cavv_algorithm=&cavv_response=&cc_expiry=0318&cc_number=%23%23%23%23%23%23%23%23%23%23%23%231111&cc_verification_str1=&cc_verification_str2=&check_number=&check_type=&clerk_id=&client_email=&client_ip=&correlation_id=&credit_card_type=Visa&ctr=¤cy_code=USD¤t_balance=&customer_id_number=&customer_id_type=&customer_name=&customer_ref=&cvd_presence_ind=0&cvv2=&date_of_birth=&device_id=&ean=&ecommerce_flag=&error_description=&error_number=&exact_message=Transaction+Normal&exact_resp_code=00&fraud_suspected=&gateway_id=AF8163-05&gift_card_amount=&gross_amount_currency_id=&language=&logon_message=&merchant_address=426+Market+St&merchant_city=Chattenooga&merchant_country=United+States&merchant_name=PriceWaiter+DEMO0243&merchant_postal=37402&merchant_province=Tennessee&merchant_url=https%3A%2F%2Fwww.pricewaiter.com%2F&message=&micr=&pan=&partial_redemption=0&password=&payer_id=&previous_balance=&reference_3=&reference_no=order2®istration_date=®istration_no=&release_type=&retrieval_ref_no=7775501&secure_auth_required=&secure_auth_result=&sequence_no=000056&success=&surcharge_amount=&tax1_amount=&tax1_number=&tax2_amount=&tax2_number=×tamp=&track1=&track2=&transaction_approved=1&transaction_error=0&transaction_tag=28513493&transaction_type=34&transarmor_token=&user_name=&vip=&virtual_card=&xid=&zip_code= tests/Message/WebservicePurchaseRequestTest.php 0000604 00000002675 15174251217 0016020 0 ustar 00 <?php namespace Omnipay\FirstData\Message; use Omnipay\Tests\TestCase; class WebservicePurchaseRequestTest extends TestCase { public function testPurchaseSuccess() { $request = new WebservicePurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); $request->initialize( array( 'amount' => '12.00', 'transactionId' => '98765', 'accountId' => '67890', 'card' => $this->getValidCard(), 'testMode' => true, ) ); $data = $request->getData(); $this->assertEquals('sale', $data['txn_type']); $this->assertEquals('4111111111111111', $data['card_number']); $this->assertEquals('12.00', $data['amount']); $this->assertEquals('123 Billing St', $data['card_address1']); $this->assertEquals('Billstown', $data['card_city']); $this->assertEquals('12345', $data['card_postcode']); $this->assertEquals('CA', $data['card_state']); $this->assertEquals('US', $data['card_country']); $this->assertEquals('98765', $data['reference_no']); // Test request internals $curl = $request->buildCurlClient(); $this->assertTrue(is_resource($curl)); $endpoint = $request->getEndpoint(); $this->assertEquals('https://ws.merchanttest.firstdataglobalgateway.com:443/fdggwsapi/services', $endpoint); } } tests/Message/PayeezyAuthorizeRequestTest.php 0000604 00000001475 15174251217 0015545 0 ustar 00 <?php namespace Omnipay\FirstData\Message; use Omnipay\Tests\TestCase; class PayeezyAuthorizeRequestTest extends TestCase { public function testAuthorizeSuccess() { $request = new PayeezyAuthorizeRequest($this->getHttpClient(), $this->getHttpRequest()); $request->initialize( array( 'amount' => '12.00', 'card' => $this->getValidCard(), ) ); $data = $request->getData(); $this->assertEquals('01', $data['transaction_type']); $this->assertEquals('4111111111111111', $data['cc_number']); $this->assertEquals('Visa', $data['credit_card_type']); $this->assertEquals('12.00', $data['amount']); $this->assertEquals('123 Billing St|12345|Billstown|CA|US', $data['cc_verification_str1']); } } tests/Message/WebserviceCaptureRequestTest.php 0000604 00000001076 15174251217 0015643 0 ustar 00 <?php namespace Omnipay\FirstData\Message; use Omnipay\Tests\TestCase; class WebserviceCaptureRequestTest extends TestCase { public function testCaptureSuccess() { $request = new WebserviceCaptureRequest($this->getHttpClient(), $this->getHttpRequest()); $request->initialize( array( 'transactionReference' => '98765::ABCDEF', ) ); $data = $request->getData(); $this->assertEquals('postAuth', $data['txn_type']); $this->assertEquals('98765', $data['reference_no']); } } tests/Message/CompletePurchaseResponseTest.php 0000604 00000003136 15174251217 0015631 0 ustar 00 <?php namespace Omnipay\FirstData\Message; use Omnipay\Tests\TestCase; class CompletePurchaseResponseTest extends TestCase { public function testCompletePurchaseSuccess() { $response = new CompletePurchaseresponse( $this->getMockRequest(), array( 'chargetotal' => '110.00', 'response_hash' => '796d7ca236576256236e92900dedfd55be08567a', 'status' => 'APPROVED', 'oid' => 'abc123456', 'txndatetime' => '2013:09:27-16:06:26', 'approval_code' => 'Y:136432:0013649958:PPXM:0015' ) ); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('abc123456', $response->getTransactionId()); $this->assertSame('APPROVED', $response->getMessage()); } public function testCompletePurchaseFailure() { $response = new CompletePurchaseresponse( $this->getMockRequest(), array( 'chargetotal' => '110.00', 'response_hash' => '0dfe9e4b3c6306343926207a8814a48f72087cc7', 'status' => 'DECLINED', 'oid' => 'abc1234', 'txndatetime' => '2013:09:27-16:00:19', 'approval_code' => 'N:05:DECLINED' ) ); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('abc1234', $response->getTransactionId()); $this->assertSame('DECLINED', $response->getMessage()); } } tests/Message/WebserviceRefundRequestTest.php 0000604 00000001333 15174251217 0015457 0 ustar 00 <?php namespace Omnipay\FirstData\Message; use Omnipay\Tests\TestCase; class WebserviceRefundRequestTest extends TestCase { public function testRefundSuccess() { $request = new WebserviceRefundRequest($this->getHttpClient(), $this->getHttpRequest()); $request->initialize( array( 'amount' => '12.00', 'transactionReference' => '98765::ABCDEF', ) ); $data = $request->getData(); $this->assertEquals('return', $data['txn_type']); $this->assertEquals('12.00', $data['amount']); $this->assertEquals('98765', $data['reference_no']); $this->assertEquals('ABCDEF', $data['tdate']); } } tests/Message/PayeezyPurchaseRequestTest.php 0000604 00000002617 15174251217 0015344 0 ustar 00 <?php namespace Omnipay\FirstData\Message; use Omnipay\Tests\TestCase; use Omnipay\FirstData\Message\PayeezyPurchaseRequest; class PayeezyPurchaseRequestTest extends TestCase { public function testPurchaseSuccess() { $request = new PayeezyPurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); $request->initialize( array( 'amount' => '12.00', 'card' => $this->getValidCard(), ) ); $data = $request->getData(); $this->assertEquals('00', $data['transaction_type']); $this->assertEquals('4111111111111111', $data['cc_number']); $this->assertEquals('Visa', $data['credit_card_type']); $this->assertEquals('12.00', $data['amount']); $this->assertEquals('123 Billing St|12345|Billstown|CA|US', $data['cc_verification_str1']); } public function testPurchaseSuccessMaestroType() { $options = array( 'amount' => '12.00', 'card' => $this->getValidCard(), ); $options['card']['number'] = '6304000000000000'; $request = new PayeezyPurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); $request->initialize($options); $data = $request->getData(); $this->assertEquals('00', $data['transaction_type']); $this->assertEquals('maestro', $data['credit_card_type']); } } tests/Message/PayeezyRefundRequestTest.php 0000604 00000001244 15174251217 0015010 0 ustar 00 <?php namespace Omnipay\FirstData\Message; use Omnipay\Tests\TestCase; class PayeezyRefundRequestTest extends TestCase { public function testRefundSuccess() { $request = new PayeezyRefundRequest($this->getHttpClient(), $this->getHttpRequest()); $request->initialize( array( 'amount' => '12.00', 'transactionReference' => '9999::DATADATADATA', ) ); $data = $request->getData(); $this->assertEquals('9999', $data['authorization_num']); $this->assertEquals('DATADATADATA', $data['transaction_tag']); $this->assertEquals('12.00', $data['amount']); } } tests/Message/PurchaseResponseTest.php 0000604 00000001204 15174251217 0014132 0 ustar 00 <?php namespace Omnipay\FirstData\Message; use Omnipay\Tests\TestCase; class PurchaseResponseTest extends TestCase { public function testPurchaseSuccess() { $response = new PurchaseResponse($this->getMockRequest(), array( 'amount' => 1000, 'returnUrl' => 'https://www.example.com/return', )); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertNull($response->getMessage()); $this->assertSame('POST', $response->getRedirectMethod()); } } tests/Message/WebserviceVoidRequestTest.php 0000604 00000001150 15174251217 0015132 0 ustar 00 <?php namespace Omnipay\FirstData\Message; use Omnipay\Tests\TestCase; class WebserviceVoidRequestTest extends TestCase { public function testVoidSuccess() { $request = new WebserviceVoidRequest($this->getHttpClient(), $this->getHttpRequest()); $request->initialize( array( 'transactionReference' => '98765::ABCDEF', ) ); $data = $request->getData(); $this->assertEquals('void', $data['txn_type']); $this->assertEquals('98765', $data['reference_no']); $this->assertEquals('ABCDEF', $data['tdate']); } } tests/Message/PayeezyPurchaseResponseTest.php 0000604 00000004022 15174251217 0015502 0 ustar 00 <?php namespace Omnipay\FirstData\Message; use Omnipay\Tests\TestCase; use Omnipay\FirstData\Message\PayeezyPurchaseRequest; class PayeezyPurchaseResponseTest extends TestCase { public function testPurchaseSuccess() { $response = new PayeezyResponse($this->getMockRequest(), http_build_query(array( 'amount' => 1000, 'exact_resp_code' => 00, 'exact_message' => 'Transaction Normal', 'reference_no' => 'abc123', 'authorization_num' => 'auth1234', 'transaction_approved' => 1, ))); $this->assertTrue($response->isSuccessful()); $this->assertEquals('auth1234::', $response->getTransactionReference()); $this->assertSame('Transaction Normal', $response->getMessage()); $this->assertEquals('00', $response->getCode()); } public function testPurchaseError() { $response = new PayeezyResponse($this->getMockRequest(), http_build_query(array( 'amount' => 1000, 'exact_resp_code' => 22, 'exact_message' => 'Invalid Credit Card Number', 'reference_no' => 'abc123', 'authorization_num' => 'auth1234', 'transaction_approved' => 0, ))); $this->assertFalse($response->isSuccessful()); $this->assertEquals('auth1234::', $response->getTransactionReference()); $this->assertSame('Invalid Credit Card Number', $response->getMessage()); $this->assertEquals('22', $response->getCode()); } public function testBankError() { $response = new PayeezyResponse($this->getMockRequest(), http_build_query(array( 'amount' => 1000, 'exact_resp_code' => 00, 'reference_no' => 'abc123', 'authorization_num' => '', 'transaction_approved' => 0, ))); $this->assertFalse($response->isSuccessful()); $this->assertEquals('::', $response->getTransactionReference()); $this->assertEquals('00', $response->getCode()); } } tests/GatewayTest.php 0000604 00000014132 15174251217 0010662 0 ustar 00 <?php namespace Omnipay\FirstData; use Omnipay\Tests\GatewayTestCase; class GatewayTest extends GatewayTestCase { public function setUp() { parent::setUp(); $this->gateway = new ConnectGateway($this->getHttpClient(), $this->getHttpRequest()); $this->gateway->setSharedSecret('96MbdNvxTa'); $this->gateway->setStoreId('1120540155'); $this->options = array( 'amount' => '13.00', 'returnUrl' => 'https://www.example.com/return', 'card' => $this->getValidCard(), 'transactionId' => 'abc123', 'currency' => 'GBP', 'customerId' => 54321 ); } public function testPurchase() { $response = $this->gateway->purchase($this->options)->send(); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertContains('ipg-online.com/connect/gateway/processing', $response->getRedirectUrl()); } public function testCompletePurchaseSuccess() { $this->getHttpRequest()->request->replace( array( 'chargetotal' => '110.00', 'response_hash' => '796d7ca236576256236e92900dedfd55be08567a', 'status' => 'APPROVED', 'oid' => 'abc123456', 'txndatetime' => '2013:09:27-16:06:26', 'approval_code' => 'Y:136432:0013649958:PPXM:0015' ) ); $response = $this->gateway->completePurchase($this->options)->send(); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertEquals('abc123456', $response->getTransactionId()); $this->assertSame('APPROVED', $response->getMessage()); $this->assertNull($response->getTransactionReference()); } /** * @expectedException \Omnipay\Common\Exception\InvalidResponseException */ public function testCompletePurchaseInvalidCallbackPassword() { $this->getHttpRequest()->request->replace( array( 'chargetotal' => '110.00', 'response_hash' => 'FAKE', 'status' => 'APPROVED', 'oid' => 'abc123456', 'txndatetime' => '2013:09:27-16:06:26', 'approval_code' => 'Y:136432:0013649958:PPXM:0015' ) ); $response = $this->gateway->completePurchase($this->options)->send(); } public function testCompletePurchaseError() { $this->getHttpRequest()->request->replace( array( 'chargetotal' => '110.00', 'response_hash' => '0dfe9e4b3c6306343926207a8814a48f72087cc7', 'status' => 'DECLINED', 'oid' => 'abc1234', 'txndatetime' => '2013:09:27-16:00:19', 'approval_code' => 'N:05:DECLINED' ) ); $response = $this->gateway->completePurchase($this->options)->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertEquals('abc1234', $response->getTransactionId()); $this->assertSame('DECLINED', $response->getMessage()); } /** * testPurchaseWithHostedDataId. * * Simulates a purchase with "save this card" selected */ public function testPurchaseWithHostedDataId() { $dataId = rand(); $this->options['hostedDataId'] = $dataId; $response = $this->gateway->purchase($this->options)->send(); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); $requestData = $response->getRedirectData(); $this->assertEquals($dataId, $requestData['hosteddataid']); } /** * testPurchaseWithHostedDataIdAndWithoutCardFailsWithoutCVV. * * Simulates paying using a saved card, rather than passing card data * This example is checking that an exception occurs if missing the CVV number * * @expectedException \Omnipay\Common\Exception\InvalidCreditCardException */ public function testPurchaseWithHostedDataIdAndWithoutCardFailsWithoutCVV() { $dataId = rand(); $this->options['hostedDataId'] = $dataId; // Remove number to simulate repeat purchase unset($this->options['card']['number']); // Also remove required cvv to check for error unset($this->options['card']['cvv']); $response = $this->gateway->purchase($this->options)->send(); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); $requestData = $response->getRedirectData(); $this->assertEquals($dataId, $requestData['hosteddataid']); } /** * testPurchaseWithHostedDataIdAndWithoutCard. * * Simulates paying using a saved card, rather than passing card data */ public function testPurchaseWithHostedDataIdAndWithoutCard() { $dataId = rand(); $this->options['hostedDataId'] = $dataId; unset($this->options['card']); $this->options['card']['cvv'] = 123; $response = $this->gateway->purchase($this->options)->send(); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); $requestData = $response->getRedirectData(); $this->assertEquals($dataId, $requestData['hosteddataid']); } /** * testPurchaseErrorWhenMissingHostedDataIdAndWithoutCardNumber. * * Simulates neither hosteddataid or card data being passed, should be caught in app. * * @expectedException \Omnipay\Common\Exception\InvalidCreditCardException */ public function testPurchaseErrorWhenMissingHostedDataIdAndWithoutCardNumber() { unset($this->options['card']); $this->options['card']['cvv'] = 123; $response = $this->gateway->purchase($this->options)->send(); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); } } tests/WebserviceGatewayTest.php 0000604 00000004434 15174251217 0012705 0 ustar 00 <?php namespace Omnipay\FirstData; use Omnipay\Tests\GatewayTestCase; class WebserviceGatewayTest extends GatewayTestCase { /** @var WebserviceGateway */ protected $gateway; /** @var array */ protected $options; public function setUp() { parent::setUp(); $this->gateway = new WebserviceGateway($this->getHttpClient(), $this->getHttpRequest()); $this->gateway->setSslCertificate('my.pem'); $this->gateway->setSslKey('my.key'); $this->gateway->setSslKeyPassword('thisISaPASSWORD'); $this->gateway->setUserName('1234'); $this->gateway->setPassword('abcde'); $this->options = array( 'accountId' => '12345', 'transactionId' => '259611', 'amount' => '10.00', 'currency' => 'USD', 'clientIp' => '127.0.0.1', 'card' => $this->getValidCard(), 'testMode' => true, ); } public function testProperties() { $this->assertEquals('my.pem', $this->gateway->getSslCertificate()); $this->assertEquals('my.key', $this->gateway->getSslKey()); $this->assertEquals('thisISaPASSWORD', $this->gateway->getSslKeyPassword()); $this->assertEquals('1234', $this->gateway->getUserName()); $this->assertEquals('abcde', $this->gateway->getPassword()); } public function testPurchaseSuccess() { // Mocks don't work on this gateway because it has to call cURL directly. // $this->setMockHttpResponse('WebservicePurchaseSuccess.txt'); $data = file_get_contents(__DIR__ . '/Mock/WebservicePurchaseSuccess.txt'); $purchase = $this->gateway->purchase($this->options); $response = $purchase->createResponse($data); // echo "Response data =\n"; // print_r($response->getData()); // echo "\nEnd Response data\n"; $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertEquals('259611::1452486844', $response->getTransactionReference()); $this->assertNull($response->getMessage()); $this->assertEquals('APPROVED', $response->getCode()); } } runtests.sh 0000604 00000001356 15174251217 0006775 0 ustar 00 #!/bin/sh # # Command line runner for unit tests for composer projects # (c) Del 2015 http://www.babel.com.au/ # No Rights Reserved # # # Ensure that dependencies are installed (including codeception and phpunit) # if [ -f composer.lock ]; then /usr/local/bin/composer install else /usr/local/bin/composer update fi # # Clean up after any previous test runs # mkdir -p documents rm -rf documents/coverage-html-new rm -f documents/coverage.xml # # Run phpunit # vendor/bin/phpunit --coverage-html documents/coverage-html-new --coverage-clover documents/coverage.xml --log-junit documents/phpunit.xml if [ -d documents/coverage-html-new ]; then rm -rf documents/coverage-html mv documents/coverage-html-new documents/coverage-html fi .travis.yml 0000604 00000000317 15174251217 0006657 0 ustar 00 language: php php: - 5.3 - 5.4 - 5.5 - 5.6 - hhvm before_script: - composer install -n --dev --prefer-source script: vendor/bin/phpcs --standard=PSR2 src && vendor/bin/phpunit --coverage-text phpunit.xml.dist 0000604 00000001512 15174251217 0007717 0 ustar 00 <?xml version="1.0" encoding="UTF-8"?> <phpunit backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" syntaxCheck="false"> <testsuites> <testsuite name="Omnipay Test Suite"> <directory>./tests/</directory> </testsuite> </testsuites> <listeners> <listener class="Mockery\Adapter\Phpunit\TestListener" file="vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/TestListener.php" /> </listeners> <filter> <whitelist> <directory>./src</directory> </whitelist> </filter> </phpunit>
| ver. 1.4 |
Github
|
.
| PHP 8.3.23 | Generation time: 0 |
proxy
|
phpinfo
|
Settings