Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remove gateways without tests or gatewasys that fail in tests. update…

… README. add CHANGELOG
  • Loading branch information...
commit 77fd85d30ff826a50985a4f53028a0778d755151 1 parent 56eb634
@akDeveloper authored
View
2  CHANGELOG.md
@@ -0,0 +1,2 @@
+* 1.0.0 (2012-10-05)
+ * Initial release
View
12 README.md
@@ -7,26 +7,24 @@ The aim is to develop a PHP application to includes payments gateway under a com
## Supported Gateways
* [Authorize.net](http://www.authorize.net)
-* [Centinel 3D Secure](http://www.cardinalcommerce.com)
* [CardStream](http://www.cardstream.com)
-* [Eurobank Payment](http://www.eurobank.gr/online/home/generic.aspx?id=79&mid=635)
+* [Eway](http://www.eway.com.au/)
* [Hsbc Secure e-Payment](http://www.hsbc.co.uk/1/2/business/cards-payments/secure-epayments)
* [Paypal Express Checkout](https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECGettingStarted)
* [PayPal Website Payments Pro](https://merchant.paypal.com/cgi-bin/marketingweb?cmd=_render-content&content_ID=merchant/wp_pro)
-* [PayPal Payflow Pro](https://www.paypal.com/cgi-bin/webscr?cmd=_payflow-pro-overview-outside)
-* [Barclay's ePDQ Gateway](http://www.barclaycard.co.uk)
-* [Realex](http://www.realexpayments.com)
* [Piraeus Paycenter](http://www.piraeusbank.gr)
+* [Realex](http://www.realexpayments.com)
## Requirements
-* PHP 5.3+ ( Test it on php 5.4.4 :P)
+* PHP 5.3.3+
* cUrl
* SimpleXML
## Usage
- require_once('path/to/lib/merchant.php');
+ require_once('path/to/lib/autoload.php');
+ // or require_once('path/to/vendor/autoload.php') if you use composer
use AktiveMerchant\Billing\Base;
use AktiveMerchant\Billing\CreditCard;
View
202 lib/AktiveMerchant/Billing/Gateways/Centinel.php
@@ -1,202 +0,0 @@
-<?php
-
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-namespace AktiveMerchant\Billing\Gateways;
-
-use AktiveMerchant\Billing\Gateway;
-use AktiveMerchant\Billing\CreditCard;
-use AktiveMerchant\Billing\Response;
-
-/**
- * Description of Centinel gateway
- *
- * @package Aktive-Merchant
- * @author Andreas Kollaros
- * @license http://www.opensource.org/licenses/mit-license.php
- */
-require_once dirname(__FILE__) . "/centinel/CentinelResponse.php";
-
-class Centinel extends Gateway
-{
- const TEST_URL = 'https://centineltest.cardinalcommerce.com/maps/txns.asp';
- const LIVE_URL = 'https://centinel.cardinalcommerce.com/maps/txns.asp';
-
- # The countries the gateway supports merchants from as 2 digit ISO country codes
-
- public static $supported_countries = array('US', 'GR');
-
- # The card types supported by the payment gateway
- public static $homepage_url = 'http://www.cardinalcommerce.com';
-
- # The homepage URL of the gateway
- public static $display_name = 'Centinel 3D Secure';
- public static $money_format = 'cents';
- public static $default_currency = 'EUR';
- private $options;
- private $post;
- private $VERSION = '1.7';
-
- public function __construct($options = array())
- {
- $this->required_options('login, password, processor_id', $options);
-
- if (isset($options['currency']))
- self::$default_currency = $options['currency'];
-
- $this->options = $options;
- }
-
- public function lookup($money, CreditCard $creditcard, $options=array())
- {
- $this->required_options('order_id', $options);
-
- $this->add_invoice($money, $options);
- $this->add_creditcard($creditcard);
-
- return $this->commit('cmpi_lookup', $money, array());
- }
-
- public function authenticate($options=array())
- {
- $this->required_options('payload, transaction_id', $options);
- $this->add_cmpi_lookup_data($options);
-
- return $this->commit('cmpi_authenticate', null, array());
- }
-
- /* Private */
-
- private function add_cmpi_lookup_data($options)
- {
- $this->post .= <<<XML
- <TransactionId>{$options['transaction_id']}</TransactionId>
- <PAResPayload>{$options['payload']}</PAResPayload>
-XML;
- }
-
- private function add_invoice($money, $options)
- {
- $order_number = isset($options['order_id']) ? $options['order_id'] : null;
-
- $amount = $this->is_test() ? $this->amount("1") : $this->amount($money);
- $default_currency = self::$default_currency;
- $this->post .= <<<XML
- <OrderNumber>{$order_number}</OrderNumber>
- <CurrencyCode>{$this->currency_lookup($default_currency)}</CurrencyCode>
- <Amount>{$amount}</Amount>
-XML;
- }
-
- private function add_creditcard(CreditCard $creditcard)
- {
- $month = $this->cc_format($creditcard->month, 'two_digits');
- $year = $this->cc_format($creditcard->year, 'four_digits');
- $this->post .= <<<XML
- <CardNumber>{$creditcard->number}</CardNumber>
- <CardExpMonth>{$month}</CardExpMonth>
- <CardExpYear>{$year}</CardExpYear>
-XML;
- }
-
- private function parse($body)
- {
- $response = array();
-
- $response['avs_result_code'] = "";
- $response['card_code'] = "";
- return $response;
- }
-
- private function parse_cmpi_lookup($body)
- {
- $xml = simplexml_load_string($body);
-
- $response = array();
- $response['transaction_id'] = (string) $xml->TransactionId;
- $response['error_no'] = (string) $xml->ErrorNo;
- $response['error_desc'] = (string) $xml->ErrorDesc;
- $response['eci_flag'] = (string) $xml->EciFlag;
- $response['payload'] = (string) $xml->Payload;
- $response['acs_url'] = (string) $xml->ACSUrl;
- $response['order_id'] = (string) $xml->OrderId;
- $response['transaction_type'] = (string) $xml->TransactionType;
- $response['enrolled'] = (string) $xml->Enrolled;
- return $response;
- }
-
- private function parse_cmpi_authenticate($body)
- {
- $xml = simplexml_load_string($body);
-
- $response = array();
-
- $response['eci_flag'] = (string) $xml->EciFlag;
- $response['pares_status'] = (string) $xml->PAResStatus;
- $response['signature_verification'] = (string) $xml->SignatureVerification;
- $response['xid'] = (string) $xml->Xid;
- $response['error_desc'] = (string) $xml->ErrorDesc;
- $response['error_no'] = (string) $xml->ErrorNo;
- $response['cavv'] = (string) $xml->Cavv;
-
- return $response;
- }
-
- private function commit($action, $money, $parameters)
- {
- $url = $this->is_test() ? self::TEST_URL : self::LIVE_URL;
-
- $data = $this->ssl_post($url, $this->post_data($action, $parameters, array('timeout' => '10')));
-
- $options = array('test' => $this->is_test());
-
- switch ($action) {
- case 'cmpi_lookup':
- $response = $this->parse_cmpi_lookup($data);
- $options['authorization'] = $response['transaction_id'];
- break;
- case 'cmpi_authenticate':
- $response = $this->parse_cmpi_authenticate($data);
- break;
-
- default:
- $response = $this->parse($data);
- break;
- }
-
- return new CentinelResponse($this->success_from($response),
- $this->message_from($response), $response, $options);
- }
-
- private function success_from($response)
- {
- return $response['error_no'] == '0';
- }
-
- private function message_from($response)
- {
- return $response['error_desc'];
- }
-
- private function post_data($action, $parameters = array())
- {
- $data = <<<XML
- <?xml version="1.0" encoding="UTF-8"?>
- <CardinalMPI>
- <MsgType>{$action}</MsgType>
- <Version>{$this->VERSION}</Version>
- <ProcessorId>{$this->options['processor_id']}</ProcessorId>
- <MerchantId>{$this->options['login']}</MerchantId>
- <TransactionPwd>{$this->options['password']}</TransactionPwd>
- <TransactionType>C</TransactionType>
-XML;
- $data .= $this->post;
- $data .= <<<XML
- </CardinalMPI>
-XML;
- return "cmpi_msg=" . urlencode(trim($data));
- }
-
-}
-
-?>
View
273 lib/AktiveMerchant/Billing/Gateways/Eurobank.php
@@ -1,273 +0,0 @@
-<?php
-
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-namespace AktiveMerchant\Billing\Gateways;
-
-use AktiveMerchant\Billing\Interfaces as Interfaces;
-use AktiveMerchant\Billing\Gateway;
-use AktiveMerchant\Billing\CreditCard;
-use AktiveMerchant\Billing\Response;
-
-/**
- * Description of Eurobank gateway
- *
- * @package Aktive-Merchant
- * @author Andreas Kollaros
- * @license http://www.opensource.org/licenses/mit-license.php
- */
-class Eurobank extends Gateway implements
- Interfaces\Charge,
- Interfaces\Credit
-{
- const TEST_URL = 'https://eptest.eurocommerce.gr/proxypay/apacsonline';
- const LIVE_URL = 'https://ep.eurocommerce.gr/proxypay/apacsonline';
-
- private $options = array();
- private $xml;
- public static $default_currency = 'EUR';
- public static $supported_countries = array('GR');
- public static $supported_cardtypes = array('visa', 'master');
- public static $homepage_url = 'http://www.eurobank.gr/online/home/generic.aspx?id=79&mid=635';
- public static $display_name = 'Eurobank Euro-Commerce';
- public static $money_format = 'cents';
-
- /**
- *
- * @param array $options
- * Options
- * 'login' - Your merchan id. (REQUIRED)
- * 'password' - Your encrypted password. (REQUIRED)
- */
- public function __construct($options)
- {
- $this->required_options('login, password', $options);
-
- if (isset($options['currency']))
- self::$default_currency = $options['currency'];
-
- $this->options = $options;
- }
-
- /**
- *
- * @param number $money - Total order amount. (REQUIRED)
- * @param CreditCard $creditcard - A creditcard class object (REQUIRED)
- * @param array $options
- *
- * @return Response
- */
- public function authorize($money, CreditCard $creditcard, $options=array())
- {
- $this->required_options('customer_email', $options);
- $this->build_xml($money, 'PreAuth', $creditcard, $options);
- return $this->commit();
- }
-
- public function purchase($money, CreditCard $creditcard, $options = array())
- {
-
- }
-
- /**
- *
- * @param number $money
- * @param string $authorization
- * @param array $options
- *
- * @return Merchant_Billing_Response
- */
- public function capture($money, $authorization, $options=array())
- {
- $options = array_merge($options, array('authorization' => $authorization));
- $this->build_xml($money, 'Capture', null, $options);
- return $this->commit();
- }
-
- /**
- *
- * @param number $money
- * @param string $identification
- * @param array $options
- *
- * @return Merchant_Billing_Response
- */
- public function credit($money, $identification, $options=array())
- {
- $options = array_merge($options, array('authorization' => $identification));
- $this->build_xml($money, 'Refund', null, $options);
- return $this->commit();
- }
-
- /**
- *
- * @param string $identification
- * @param array $options
- *
- * @return Merchant_Billing_Response
- */
- public function void($identification, $options = array())
- {
- $options = array_merge($options, array('authorization' => $identification));
- $this->build_xml(0, 'Cancel', null, $options);
- return $this->commit();
- }
-
- /**
- *
- * @return Merchant_Billing_Response
- */
- private function commit()
- {
- $url = $this->is_test() ? self::TEST_URL : self::LIVE_URL;
-
- $post_data = 'APACScommand=NewRequest&data=' . trim($this->xml);
- $response = $this->parse($this->ssl_post($url, $post_data));
-
- /*
- * Sample of response
- <?xml version="1.0" encoding="UTF-8"?>
- <RESPONSE>
- <ERRORCODE>0</ERRORCODE>
- <ERRORMESSAGE>0</ERRORMESSAGE>
- <REFERENCE>or5342-CD</REFERENCE>
- <PROXYPAYREF>34543</PROXYPAYREF>
- <SEQUENCE>4562</SEQUENCE>
- </RESPONSE>
- */
-
- return new Response(
- $this->success_from($response),
- $this->message_from($response),
- $response,
- $this->options_from($response)
- );
- }
-
- /**
- *
- * @param string $response_xml
- *
- * @return array
- */
- private function parse($response_xml)
- {
- $xml = simplexml_load_string($response_xml);
- $response = array();
-
- $response['error_code'] = (string) $xml->ERRORCODE;
- $response['message'] = (string) $xml->ERRORMESSAGE;
- $response['reference'] = (string) $xml->REFERENCE;
- $response['proxypay_ref'] = (string) $xml->PROXYPAYREF;
- $response['sequence'] = (string) $xml->SEQUENCE;
-
- return $response;
- }
-
- private function success_from($response)
- {
- return $response['error_code'] == '0';
- }
-
- /**
- *
- * @param string $response
- *
- * @return boolean
- */
- private function message_from($response)
- {
- return $response['message'];
- }
-
- /**
- *
- * @param string $response
- *
- * @return array
- */
- private function options_from($response)
- {
- $options = array();
- $options['test'] = $this->is_test();
- $options['authorization'] = $response['reference'];
- $options['proxypay_ref'] = $response['proxypay_ref'];
- $options['sequence'] = $response['sequence'];
-
- return $options;
- }
-
- /**
- *
- * @param CreditCard $creditcard
- */
- private function build_payment_info(CreditCard $creditcard)
- {
- $month = $this->cc_format($creditcard->month, 'two_digits');
- $year = $this->cc_format($creditcard->year, 'two_digits');
-
- $this->xml .= <<<XML
- <PaymentInfo>
- <CCN>{$creditcard->number}</CCN>
- <Expdate>{$month}{$year}</Expdate>
- <CVCCVV>{$creditcard->verification_value}</CVCCVV>
- <InstallmentOffset>0</InstallmentOffset>
- <InstallmentPeriod>0</InstallmentPeriod>
- </PaymentInfo>
-XML;
- }
-
- /**
- *
- * @param number $money
- * @param string $type
- * @param CreditCard $creditcard
- * @param array $options
- */
- private function build_xml(
- $money,
- $type,
- CreditCard $creditcard = null,
- $options=array()
- ) {
- $merchant_desc = isset($options['merchant_desc']) ? $options['merchant_desc'] : null;
- $merchant_ref = isset($options['authorization']) ? $options['authorization'] : "REF " . date("YmdH:i:s", time());
- $customer_email = isset($options['customer_email']) ? $options['customer_email'] : "";
-
- $this->xml = <<<XML
- <?xml version="1.0" encoding="UTF-8"?>
- <JProxyPayLink>
- <Message>
- <Type>{$type}</Type>
- <Authentication>
- <MerchantID>{$this->options['login']}</MerchantID>
- <Password>{$this->options['password']}</Password>
- </Authentication>
- <OrderInfo>
- <Amount>{$this->amount($money)}</Amount>
- <MerchantRef>{$merchant_ref}</MerchantRef>
- <MerchantDesc>{$merchant_desc}</MerchantDesc>
- <Currency>{$this->currency_lookup(self::$default_currency)}</Currency>
- <CustomerEmail>{$customer_email}</CustomerEmail>
- <Var1 />
- <Var2 />
- <Var3 />
- <Var4 />
- <Var5 />
- <Var6 />
- <Var7 />
- <Var8 />
- <Var9 />
- </OrderInfo>
-XML;
- if ($creditcard != null)
- $this->build_payment_info($creditcard);
- $this->xml .= <<<XML
- </Message>
- </JProxyPayLink>
-XML;
- }
-
-}
-
-?>
View
219 lib/AktiveMerchant/Billing/Gateways/Payflow.php
@@ -1,219 +0,0 @@
-<?php
-
-namespace AktiveMerchant\Billing\Gateways;
-
-require_once 'payflow/PayflowCommon.php';
-require_once 'payflow/PayflowResponse.php';
-
-use AktiveMerchant\Billing\Interfaces as Interfaces;
-
-class Payflow extends PayflowCommon
-{
-
- public static $supported_cardtypes = array('add', 'modify', 'cancel', 'inquiry', 'reactivate', 'payment');
- public static $homepage_url = 'https://www.paypal.com/cgi-bin/webscr?cmd=_payflow-pro-overview-outside';
- public static $display_name = 'PayPal Payflow Pro';
-
- function authorize($money, $credit_card_or_reference, $options = array())
- {
- $request = $this->build_sale_or_authorization_request(
- 'Authorization',
- $money,
- $credit_card_or_reference,
- $options
- );
-
- return $this->commit($request);
- }
-
- function purchase($money, $credit_card_or_reference, $options = array())
- {
- $request = $this->build_sale_or_authorization_request(
- 'Purchase',
- $money,
- $credit_card_or_reference,
- $options
- );
-
- return $this->commit($request);
- }
-
- private function build_sale_or_authorization_request(
- $action,
- $money,
- $credit_card_or_reference,
- $options
- ) {
- return is_string($credit_card_or_reference)
- ? $this->build_reference_sale_or_authorization_request(
- $action,
- $money,
- $credit_card_or_reference,
- $options
- )
- : $this->build_credit_card_request(
- $action,
- $money,
- $credit_card_or_reference,
- $options
- );
- }
-
- private function build_reference_sale_or_authorization_request(
- $action,
- $money,
- $reference,
- $options
- ) {
- $default_currency = self::$default_currency;
- $bodyXml = <<<XML
- <{$action}>
- <PayData>
- <Invoice>
- <TotalAmt Currency="{$default_currency}">
- {$this->amount($money)}
- </TotalAmt>
- </Invoice>
- <Tender>
- <Card>
- <ExtData Name="ORIGID" Value="{$reference}"></ExtData>
- </Card>
- </Tender>
- </PayData>
- </{$action}>
-XML;
- return $this->build_request($bodyXml);
- }
-
- private function build_credit_card_request(
- $action,
- $money,
- $credit_card,
- $options
- ) {
- $default_currency = static::$default_currency;
-
- $bodyXml = <<<XML
- <{$action}>
- <PayData>
- <Invoice>
-XML;
- if (isset($options['ip']))
- $bodyXml .= "<CustIp>" . $options['ip'] . "</CustIp>";
-
- if (isset($options['order_id'])) {
- $bodyXml .= "<InvNum>" . $options['order_id'] . "</InvNum>";
- $bodyXml .= "<Comment>" . $options['order_id'] . "</Comment>";
- }
-
- if (isset($options['description']))
- $bodyXml .= "<Description>"
- . $options['description']
- . "</Description>";
-
- if (isset($options['billing_address']))
- $bodyXml .= "<BillTo>"
- . $this->add_address($options, $options['billing_address'])
- . "</BillTo>";
-
- if (isset($options['shipping_address']))
- $bodyXml .= "<ShipTo>"
- . $this->add_address($options, $options['shipping_address'])
- . "</ShipTo>";
-
- $bodyXml .= <<<XML
- <TotalAmt Currency="{$default_currency}">
- {$this->amount($money)}
- </TotalAmt>
- </Invoice>
- <Tender>
-XML;
-
- if (isset($options['order_items'])) {
- $bodyXml .= "<Items>";
-
- foreach ($options['order_items'] as $key => $item) {
- $count = $key + 1;
- $bodyXml .= <<<XML
- <Item Number="{$count}">
- <SKU>{$item['id']}</SKU>
- <UPC>{$item['id']}</UPC>
- <Description>{$item['description']}</Description>
- <Quantity>{$item['quantity']}</Quantity>
- <UnitPrice>{$item['unit_price']}</UnitPrice>
- <TotalAmt>{$item['total']}</TotalAmt>
- </Item>
-XML;
- }
-
- $bodyXml .= "</Items>";
- }
-
- $bodyXml .= $this->add_credit_card($credit_card, $options);
-
- $bodyXml .= <<<XML
- </Tender>
- </PayData>
- </{$action}>
-XML;
- return $this->build_request($bodyXml);
- }
-
- private function add_credit_card($creditcard, $options = array())
- {
- $month = $this->cc_format($creditcard->month, 'two_digits');
- $year = $this->cc_format($creditcard->year, 'four_digits');
-
- $xml = <<<XML
- <Card>
- <CardType>{$this->credit_card_type($creditcard)}</CardType>
- <CardNum>{$creditcard->number}</CardNum>
- <ExpDate>{$year}{$month}</ExpDate>
- <NameOnCard>{$creditcard->first_name}</NameOnCard>
- <CVNum>{$creditcard->verification_value}</CVNum>
-XML;
-
- if ($this->requires_start_date_or_issue_number($creditcard)) {
- if (!is_null($creditcard->start_month)) {
- $startMonth = $this->cc_format($creditcard->start_month, 'two_digits');
- $startYear = $this->cc_format($creditcard->start_year, 'four_digits');
- $xml .= '<ExtData Name="CardStart" Value="' . $startYear . $startMonth . '"></ExtData>';
- }
-
- if (!is_null($creditcard->issue_number)) {
- $xml .= '<ExtData Name="CardIssue" Value="'
- . $this->cc_format(
- $creditcard->issue_number,
- 'two_digits'
- )
- . '"></ExtData>';
- }
- }
-
- $xml .= "<ExtData Name=\"LASTNAME\" Value=\"{$creditcard->last_name}\"></ExtData>";
-
- if (isset($options['three_d_secure'])) {
- $tds = $options['three_d_secure'];
- $xml .= <<<XML
- <BuyerAuthResult>
- <AUTHSTATUS3DS>{$tds['pares_status']}</AUTHSTATUS3DS>
- <MPIVENDOR3DS>{$tds['enrolled']}</MPIVENDOR3DS>
- <ECI>{$tds['eci_flag']}</ECI>
- <CAVV>{$tds['cavv']}</CAVV>
- <XID>{$tds['xid']}</XID>
- </BuyerAuthResult>
-XML;
- }
-
- $xml .= "</Card>";
- return $xml;
- }
-
- private function credit_card_type($credit_card)
- {
- return is_null($this->card_brand($credit_card))
- ? ''
- : $this->CARD_MAPPING[$this->card_brand($credit_card)];
- }
-
-}
View
17 lib/AktiveMerchant/Billing/Gateways/PayflowUk.php
@@ -1,17 +0,0 @@
-<?php
-
-namespace AktiveMerchant\Billing\Gateways;
-
-class PayflowUk extends Payflow
-{
-
- public static $default_currency = 'GBP';
- protected $partner = 'PayPalUk';
- public static $supported_cardtypes = array('visa', 'master', 'american_express', 'discover', 'solo', 'switch');
- public static $supported_countries = array('GB');
- public static $homepage_url = 'https://www.paypal.com/uk/cgi-bin/webscr?cmd=_wp-pro-overview-outside';
- public static $display_name = 'PayPal Payflow Pro (UK)';
-
-}
-
-?>
View
360 lib/AktiveMerchant/Billing/Gateways/Psigate.php
@@ -1,360 +0,0 @@
-<?php
-
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-namespace AktiveMerchant\Billing\Gateways;
-
-use AktiveMerchant\Billing\Interfaces as Interfaces;
-use AktiveMerchant\Billing\Gateway;
-use AktiveMerchant\Billing\CreditCard;
-use AktiveMerchant\Billing\Exception;
-use AktiveMerchant\Billing\Response;
-
-/**
- * Merchant driver for {link http://www.psigate.com/ PSiGate}.
- *
- * @package Aktive-Merchant
- * @author Scott Gifford
- * @license http://www.opensource.org/licenses/mit-license.php
- * @see http://www.psigate.com/
- */
-class Psigate extends Gateway implements
- Interfaces\Charge,
- Interfaces\Credit
-{
-
- const LIVE_URL = "https://secure.psigate.com:7934/Messenger/XMLMessenger";
- const TEST_URL = "https://dev.psigate.com:7989/Messenger/XMLMessenger";
-
- const SUCCESS_MESSAGE = "Success";
- const UNKNOWN_ERROR_MESSAGE = "The transaction was declined";
- const AUTHSTR_VERSION = 1;
-
- const TEST_MODE_ALWAYS_AUTH = 'A';
- const TEST_MODE_ALWAYS_DECLINE = 'D';
- const TEST_MODE_RANDOM = 'R';
- const TEST_MODE_FRAUD = 'F';
-
- public static $supported_countries = array('CA');
- public static $supported_cardtypes = array('visa', 'master', 'american_express');
- public static $homepage_url = 'http://www.psigate.com/';
- public static $display_name = 'Psigate';
-
- private $options = array();
- private $test_mode = 0;
-
- public function __construct($options)
- {
- $this->required_options('login, password', $options);
- $this->options = $options;
- }
-
- /**
- * Configure how the gateway will respond to test requests.
- *
- * The gateway can be configured to always allow requests (the default), to always fail,
- * etc. You can call this function to set the mode. You must also call {@see mode()} to
- * set the mode to 'test'.
- *
- * Values are:
- * <ul>
- * <li>Psigate::TEST_MODE_ALWAYS_AUTH - Authorize every request (default)
- * <li>Psigate::TEST_MODE_ALWAYS_DECLINE - Decline every request
- * <li>Psigate::TEST_MODE_RANDOM - Randomly authorize or decline requests
- * <li>Psigate::TEST_MODE_FRAUD - Treat every request as a fraud alert
- * </ul>
- *
- * @param string $mode New value for test mode (unset or NULL to keep current value)
- * @return string Current value for test mode, or previous value if $mode is set
- */
- public function test_mode($mode = NULL)
- {
- $last_mode = $this->test_mode;
- if ($mode !== NULL) $this->test_mode = $mode;
- return $last_mode;
- }
-
- public function authorize($money, CreditCard $creditcard, $options = array())
- {
- // Ruby code required order_id, but PSiGate doesn't require this, so we don't either
- $options['CardAction'] = 1;
- return $this->commit($money, $creditcard, $options);
- }
-
- public function purchase($money, CreditCard $creditcard, $options = array())
- {
- // Ruby code required order_id, but PSiGate doesn't require this, so we don't either
- $options['CardAction'] = 0;
- return $this->commit($money, $creditcard, $options);
- }
-
- public function capture($money, $authorization, $options = array())
- {
- $options['CardAction'] = 2;
- $authdata = $this->unpack_authorization_string($authorization);
- $options['order_id'] = $authdata['order_id'];
- return $this->commit($money, NULL, $options);
- }
-
- public function credit($money, $authorization, $options = array())
- {
- $options['CardAction'] = 3;
- $authdata = $this->unpack_authorization_string($authorization);
- $options['order_id'] = $authdata['order_id'];
- return $this->commit($money, NULL, $options);
- }
-
- public function void($authorization, $options = array())
- {
- $options['CardAction'] = 9;
- $authdata = $this->unpack_authorization_string($authorization);
- $options['transaction_id'] = $authdata['transaction_id'];
- $options['order_id'] = $authdata['order_id'];
- return $this->commit(NULL, NULL, $options);
- }
-
- /**
- * Create a string with required transaction data.
- *
- * PSiGate always requires the order ID to complete or modify past transactions,
- * and sometimes requires the transaction ID. This function packs them both into
- * one string, which can be used for any of these purposes.
- *
- * @param unknown_type $orderid
- * @param unknown_type $transactionid
- */
- private function pack_authorization_values($orderid, $transactionid)
- {
- return join("&", array(self::AUTHSTR_VERSION,urlencode($orderid), urlencode($transactionid)));
- }
-
- private function unpack_authorization_string($authstr)
- {
-
- $split = split("&",$authstr);
-
- if ($split === FALSE) {
- throw new Exception("Invalid authorization string");
- }
-
- if ($split[0] != self::AUTHSTR_VERSION) {
- throw new Exception("Invalid authorization string version");
- }
-
- if (count($split) != 3) {
- throw new Exception("Error parsing authorization string");
- }
-
- return array(
- 'order_id' => urldecode($split[1]),
- 'transaction_id' => urldecode($split[2]),
- );
- }
-
- private function commit($money, CreditCard $creditcard = NULL, $options = array())
- {
- $url = $this->isTest() ? self::TEST_URL : self::LIVE_URL;
-
- // Log request, but mask real user information
- if ($creditcard === NULL) {
- $log_card = NULL;
- } else {
- $log_card = clone $creditcard;
- $log_card->number = $this->mask_cardnum($log_card->number);
-
- if ($log_card->verification_value) {
- $log_card->verification_value = $this->mask_cvv($log_card->verification_value);
- }
- }
-
- // Make the request
- $data = $this->ssl_post($url, $this->post_data($money, $creditcard, $options));
- $response = $this->parse($data);
-
- // Make sure the response is valid and doesn't contain an error
- if (empty($response['approved'])) {
- throw new Exception("Error parsing merchant response: No status information");
- }
-
- if ($response['approved'] == 'ERROR') {
- throw new Exception("Merchant error: " . (isset($response['errmsg']) ? $response['errmsg'] : 'Unknown error'));
- }
-
- if ( $response['approved'] != 'APPROVED'
- && $response['approved'] != 'DECLINED'
- ) {
- throw new Exception("Merchant error: Unknown status '$response[approved]'");
- }
-
- return new Response(
- $this->success_from($response),
- $this->message_from($response),
- $response,
- array(
- 'test' => $this->isTest(),
- 'authorization' => (isset($response['orderid']) && isset($response['transrefnumber']))
- ? $this->pack_authorization_values($response['orderid'],$response['transrefnumber'])
- : NULL,
- 'avs_result' => isset($response['avsresult'])
- ? array('code' => $response['avsresult'])
- : NULL,
- 'cvv_result' => isset($response['cardidresult'])
- ? $response['cardidresult']
- : NULL,
- ));
- }
-
- private function message_from($response)
- {
- if ($this->success_from($response)) {
- return self::SUCCESS_MESSAGE;
- } else {
- if (isset($response['errmsg'])) {
- return $response['errmsg'];
- } else {
- return self::UNKNOWN_ERROR_MESSAGE;
- }
- }
- }
-
- private function success_from($response)
- {
- return $response['approved'] == "APPROVED";
- }
-
- private function parse($response_xml)
- {
- $response = array(
- 'errmsg' => 'Unknown Error',
- 'complete' => false,
- );
-
- try {
- // This will throw an exception in case of a severe error
- $xml = simplexml_load_string($response_xml);
- $results = $xml->xpath('//Result/*');
- if ($results === FALSE) {
- throw new Exception("Xpath parsing failed");
- }
- foreach ($results as $elt) {
- $response[strtolower($elt->getName())] = (string) $elt;
- }
- } catch (\Exception $ex) {
- throw new Exception("Error parsing XML response from merchant", 0, $ex);
- }
-
- return $response;
- }
-
- protected function post_data($money, $creditcard, $options)
- {
- $params = $this->parameters($money, $creditcard, $options);
- $xml = new \SimpleXMLElement("<Order />");
- foreach ($params as $k => $v) {
- if ($v !== NULL) $xml->addChild($k, $v);
- }
- return $xml->asXML();
- }
-
- private function parameters($money, CreditCard $creditcard = NULL, $options = array())
- {
- $params = array(
- 'StoreID' => $this->options['login'],
- 'Passphrase' => $this->options['password'],
- 'TestResult' => isset($options['test_result']) ? $options['test_result'] : NULL,
- 'OrderID' => isset($options['order_id']) ? $options['order_id'] : NULL,
- 'UserID' => isset($options['user_id']) ? $options['user_id'] : NULL,
- 'Phone' => isset($options['phone']) ? $options['phone'] : NULL,
- 'Fax' => isset($options['fax']) ? $options['fax'] : NULL,
- 'Email' => isset($options['email']) ? $options['email'] : NULL,
-
- 'PaymentType' => 'CC',
- 'CardAction' => isset($options['CardAction']) ? $options['CardAction'] : NULL,
-
- 'CustomerIP' => isset($options['ip']) ? $options['ip'] : NULL,
- 'SubTotal' => isset($money) ? $this->amount($money) : NULL,
- 'Tax1' => isset($options['tax1']) ? $options['tax1'] : NULL,
- 'Tax2' => isset($options['tax2']) ? $options['tax2'] : NULL,
- 'ShippingTotal' => isset($options['shipping_total']) ? $options['shipping_total'] : NULL,
- );
-
- if (isset($creditcard)) {
- $params['CardNumber'] = $creditcard->number;
- if (isset($creditcard->month)) $params['CardExpMonth'] = sprintf("%02d", $creditcard->month);
- if (isset($creditcard->year)) $params['CardExpYear'] = substr($creditcard->year,-2);
- if (isset($creditcard->verification_value)) {
- $params['CardIDNumber'] = $creditcard->verification_value;
- $params['CardIDCode'] = '1';
- }
- }
-
- // Copy address information into request
- // psigate_name => options_name
- $addrfields = array(
- 'name' => 'name',
- 'address1' => 'address1',
- 'address2' => 'address2',
- 'city' => 'city',
- 'province' => 'state',
- 'postalcode' => 'zip',
- 'country' => 'country',
- 'company' => 'company',
- );
-
- if (isset($options['billing_address'])) {
- foreach($addrfields as $p => $o) {
- if (isset($options['billing_address'][$o])) $params['B'.$p] = $options['billing_address'][$o];
- }
- }
-
- if (isset($options['shipping_address'])) {
- foreach($addrfields as $o => $p) {
- if (isset($options['shipping_address'][$o])) $params['S'.$p] = $options['shipping_address'][$o];
- }
- }
-
- if (isset($options['transaction_id'])) {
- $params['TransRefNumber'] = $options['transaction_id'];
- }
-
- if ($this->isTest()) {
- if (empty($this->test_mode)) $this->test_mode = self::TEST_MODE_ALWAYS_AUTH;
- switch($this->test_mode) {
- case self::TEST_MODE_ALWAYS_AUTH: $params['TestResult'] = 'A'; break;
- case self::TEST_MODE_ALWAYS_DECLINE: $params['TestResult'] = 'D'; break;
- case self::TEST_MODE_FRAUD: $params['TestResult'] = 'F'; break;
- case self::TEST_MODE_RANDOM: $params['TestResult'] = 'R'; break;
- default: throw new Exception("Invalid test mode");
- }
- }
-
- return $params;
- }
-
- /**
- * Mask a credit card number.
- *
- * Makes the card safe for logging and storing, by replacing all but the
- * first 2 and last 4 digits with x's.
- *
- * @param string $cardnum Card number to mask
- * @return string Masked card number
- */
- protected function mask_cardnum($cardnum) {
- return substr($cardnum,0,2) . preg_replace('/./','x',substr($cardnum,2,-4)) . substr($cardnum,-4,4);
- }
-
- /**
- * Mask a card verification value;
- *
- * Makes a card verification value safe for logging and storing, by replacing all
- * characters with x's.
- *
- * @param string $cardverifier Card verification value to mask
- * @return string Masked card verification value
- */
- protected function mask_cvv($cvv) {
- return preg_replace('/./','x',$cvv);
- }
-}
-
View
28 lib/AktiveMerchant/Billing/Gateways/centinel/CentinelResponse.php
@@ -1,28 +0,0 @@
-<?php
-
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-namespace AktiveMerchant\Billing\Gateways;
-
-use AktiveMerchant\Billing\Response;
-
-/**
- * Description of CentinelResponse
- *
- * @package Aktive-Merchant
- * @author Andreas Kollaros
- * @license http://www.opensource.org/licenses/mit-license.php
- */
-class CentinelResponse extends Response
-{
-
- public function message()
- {
- if ($this->enrolled == 'N')
- return 'Cardholder not enrolled! ';
- return $this->error_no . ": " . $this->message;
- }
-
-}
-
-?>
View
523 lib/AktiveMerchant/Billing/Gateways/ePDQ.php
@@ -1,523 +0,0 @@
-<?php
-
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-namespace AktiveMerchant\Billing\Gateways;
-
-use AktiveMerchant\Billing\Interfaces as Interfaces;
-use AktiveMerchant\Billing\Gateway;
-use AktiveMerchant\Billing\CreditCard;
-use AktiveMerchant\Billing\Response;
-
-/**
- * AktiveMerchant Barclay's ePDQ Gateway Library
- *
- * @package Aktive-Merchant
- * @author Kieran Graham (AirPOS Ltd.)
- */
-class ePDQ extends Gateway implements Interfaces\Charge
-{
- const TEST_URL = 'https://secure2.mde.epdq.co.uk:11500';
- const LIVE_URL = 'https://secure2.mde.epdq.co.uk:11500';
-
- private $CARD_TYPE_MAPPINGS = array
- (
- 'visa' => 1,
- 'master' => 2,
- 'american_express' => 8,
- 'discover' => 3,
- );
- private $COUNTRY_CODE_MAPPINGS = array
- (
- 'GB' => 826,
- 'US' => 840,
- );
- private $CVV_RESPONSE_MAPPINGS = array
- (
- '0' => 'X',
- '1' => 'M',
- '2' => 'N',
- '3' => 'P',
- '4' => 'S',
- '5' => 'X',
- '6' => 'I',
- '7' => 'U',
- );
- private $TRANSACTION_STATUS_MAPPINGS = array
- (
- 'accepted' => "A",
- 'declined' => "D",
- 'fraud' => "F",
- 'error' => "E",
- 'void' => "V",
- 'reserved' => "U"
- );
-
- const APPROVED = 1;
- const DECLINED = 50;
- const DECLINED_FRAUDULENT = 500;
- const DECLINED_FRAUDULENT_VOIDED = 501;
- const DECLINED_FRAUDULENT_REVIEW = 502;
- const CVV_FAILURE = 1055;
-
- private $FRAUDULENT = array
- (
- 'DECLINED_FRAUDULENT',
- 'DECLINED_FRAUDULENT_VOIDED',
- 'DECLINED_FRAUDULENT_REVIEW',
- 'CVV_FAILURE'
- );
- private $options = array();
- private $xml;
- private $payment_mode = "P"; #Production
- private $payment_mech_type = "CreditCard";
- public static $default_currency = 'GBP';
- public static $supported_countries = array('US', 'GB');
- public static $supported_cardtypes = array('visa', 'master', 'american_express', 'discover');
- public static $homepage_url = 'http://www.barclaycard.co.uk/';
- public static $display_name = 'ePDQ';
- public static $money_format = 'cents';
-
- /**
- * __constructor
- */
- public function __construct($options = array())
- {
- $this->required_options('login, password, client_id', $options);
-
- if (isset($options['currency'])) {
- self::$default_currency = $options['currency'];
- }
-
- $this->options = $options;
- }
-
- /**
- * Authorize
- *
- * @param int - Amount to charge for authorize.
- * @param CreditCard - Credit card to charge.
- * @param array - Options to pass.
- * @return Response
- */
- public function authorize($amount, CreditCard $creditcard, $options = array())
- {
- $this->build_xml($amount, $creditcard, 'PreAuth', $options);
- return $this->commit(__FUNCTION__);
- }
-
- /**
- * Purchase
- *
- * @param int - Amount to charge for purchase.
- * @param Merchant_billing_CreditCard - Credit card to charge.
- * @param array - Options to pass.
- * @return Response
- */
- public function purchase($amount, CreditCard $creditcard, $options = array())
- {
- $this->build_xml($amount, $creditcard, 'Auth', $options);
- return $this->commit(__FUNCTION__);
- }
-
- /**
- * Capture
- *
- * @param int - Amount to capture.
- * @param -
- * @param array - Options to pass.
- */
- public function capture($amount, $authorization, $options = array())
- {
- $options = array_merge($options, array('authorization', $authorization));
- $this->build_xml($amount, $creditcard, 'PostAuth', $options);
- }
-
- /**
- * Void
- *
- * @param string - Payment identification.
- * @param array - Options to pass.
- */
- public function void($identification, $options = array())
- {
- $this->build_xml($amount, $creditcard, 'Void', $options);
- }
-
- /**
- * Build XML
- *
- * @param int
- * @param CreditCard
- * @param string
- * @param array
- */
- private function build_xml($amount, CreditCard $creditcard, $type, $options=array())
- {
- $this->start_xml();
- $this->insert_data($amount, $creditcard, $type, $options);
- $this->end_xml();
- }
-
- /**
- * Insert Data
- *
- * @param int
- * @param CreditCard
- * @param string
- * @param array
- */
- private function insert_data($amount, CreditCard $creditcard, $type, $options=array())
- {
- $month = $this->cc_format($creditcard->month, 'two_digits');
- $year = $this->cc_format($creditcard->year, 'two_digits');
-
- $this->xml .= <<<XML
- <OrderFormDoc>
- <Mode DataType="String">{$this->payment_mode}</Mode>
- <Consumer>
- <PaymentMech>
- <Type DataType="String">{$this->payment_mech_type}</Type>
- <CreditCard>
- <Number DataType="String">{$creditcard->number}</Number>
- <Expires DataType="ExpirationDate">{$month}/{$year}</Expires>
- <Cvv2Val DataType="String">{$creditcard->verification_value}</Cvv2Val>
- <Cvv2Indicator DataType="String">1</Cvv2Indicator>
- </CreditCard>
- </PaymentMech>
- </Consumer>
-XML;
- $this->add_transaction_element($amount, $type, $options);
- $this->add_billing_address($options);
- $this->add_shipping_address($options);
- }
-
- /**
- * Add Transaction Element
- *
- * @param int
- * @param string
- * @param array
- */
- private function add_transaction_element($amount, $type, $options)
- {
-
- if ($type == 'PreAuth' || $type == 'Auth') {
- $this->xml .= <<<XML
- <Transaction>
- <Type DataType="String">{$type}</Type>
- <CurrentTotals>
- <Totals>
- <Total DataType="Money" Currency="{$this->currency_lookup(self::$default_currency)}">{$amount}</Total>
- </Totals>
- </CurrentTotals>
- </Transaction>
-XML;
- } elseif ($type == 'PostAuth' || $type == 'Void') {
- $this->xml .= <<<XML
- <Transaction>
- <Type DataType="String">{$type}</Type>
- <Id DataType="String">{$options['authorization']}</Id>
- <CurrentTotals>
- <Totals>
- <Total DataType="Money" Currency="{$this->currency_lookup(self::$default_currency)}">{$amount}</Total>
- </Totals>
- </CurrentTotals>
- </Transaction>
-XML;
- }
- }
-
- /**
- * Add Billing Address
- *
- * @param array
- */
- private function add_billing_address($options)
- {
- if (isset($options['billing_address'])) {
- $this->xml .= <<<XML
- <BillTo>
- <Location>
- <Email DataType="String">{$options['email']}</Email>
-XML;
- $this->add_address($options['billing_address']);
- $this->xml .= <<<XML
- <TelVoice DataType="String">{$options['billing_address']['phone']}</TelVoice>
- </Location>
- </BillTo>
-XML;
- }
- }
-
- /**
- * Add Shipping Address
- *
- * @param array
- */
- private function add_shipping_address($options)
- {
- if (isset($options['shipping_address'])) {
- $this->xml .= <<<XML
- <ShipTo>
- <Location>
- <Email DataType="String">{$options['email']}</Email>
-XML;
- $this->add_address($options['shipping_address']);
- $this->xml .= <<<XML
- <TelVoice DataType="String">{$options['shipping_address']['phone']}</TelVoice>
- </Location>
- </ShipTo>
-XML;
- }
- }
-
- /**
- * Add Address
- *
- * @param array
- */
- private function add_address($options)
- {
- $this->xml .= <<<XML
- <Address>
- <Name DataType="String">{$options['name']}</Name>
- <Company DataType="String">{$options['company']}</Company>
- <Street1 DataType="String">{$options['address1']}</Street1>
- <Street2 DataType="String">{$options['address2']}</Street2>
- <City DataType="String" >{$options['city']}</City>
- <StateProv DataType="String" >{$options['state']}</StateProv>
- <Country DataType="String">{$this->COUNTRY_CODE_MAPPINGS[$options['country']]}</Country>
- <PostalCode DataType="String">{$options['zip']}</PostalCode>
- </Addresss>
-XML;
- }
-
- /**
- * Start XML
- */
- private function start_xml()
- {
- $this->xml = <<<XML
- <?xml version="1.0" encoding="UTF-8"?>
- <EngineDocList>
- <DocVersion DataType="String">1.0</DocVersion>
- <EngineDoc>
- <ContentType DataType="String">OrderFormDoc</ContentType>
- <User>
- <Alias DataType="String">{$this->options['client_id']}</Alias>
- <Name DataType="String">{$this->options['login']}</Name>
- <Password DataType="String">{$this->options['password']}</Password>
- </User>
- <Instructions>
- <Pipeline DataType="String">Payment</Pipeline>
- </Instructions>
-XML;
- }
-
- /**
- * End XML
- */
- private function end_xml()
- {
- $this->xml .= <<<XML
- </OrderFormDoc>
- </EngineDoc>
- </EngineDocList>
-XML;
- }
-
- /**
- * Commit
- *
- * @param string - Action.
- */
- private function commit($action)
- {
- $url = $this->isTest() ? self::TEST_URL : self::LIVE_URL;
- $response = $this->parse($this->ssl_post($url, $this->xml));
-
- return new Response($this->success_from($action, $response), $this->message_from($response), $response, $this->options_from($response));
- }
-
- /**
- * Parse
- *
- * @param string
- * @return string
- */
- private function parse($response_xml)
- {
- $xml = simplexml_load_string($response_xml);
-
- $response = array();
-
- $messages = $xml->EngineDoc->MessageList;
- $overview = $xml->EngineDoc->Overview;
- $transaction = $xml->EngineDoc->OrderFormDoc->Transaction;
-
- /**
- * Parse messages
- */
- if (!empty($messages)) {
- if (isset($messages->MaxSev))
- $response['severity'] = (string) $messages->MaxSev;
-
- if (count($messages->Message) == 2) {
- $message = $messages->Message[1];
- } else {
- $message = $messages->Message;
- }
-
- if (isset($message->AdvisedAction))
- $response['advised_action'] = (string) $message->AdvisedAction;
-
- if (isset($message->Text))
- $response['error_message'] = (string) $message->Text;
- }
-
- /**
- * Parse overview
- */
- if (!empty($overview)) {
- if (isset($overview->CcErrCode)) :
- $response['return_code'] = (string) $overview->CcErrCode;
- endif;
-
- if (isset($overview->CcReturnMsg)) :
- $response['return_message'] = (string) $overview->CcReturnMsg;
- endif;
-
- if (isset($overview->TransactionId)) :
- $response['transaction_id'] = (string) $overview->TransactionId;
- endif;
-
- if (isset($overview->AuthCode)) :
- $response['auth_code'] = (string) $overview->AuthCode;
- endif;
-
- if (isset($overview->TransactionStatus)) :
- $response['transaction_status'] = (string) $overview->TransactionStatus;
- endif;
-
- if (isset($overview->Mode)) :
- $response['mode'] = (string) $overview->Mode;
- endif;
- }
-
- /**
- * Parse transaction
- */
- if (!empty($transaction->CardProcResp)) {
- if (isset($transaction->CardProcResp->AvsRespCode)) :
- $response['avs_code'] = (string) $transaction->CardProcResp->AvsRespCode;
- endif;
-
- if (isset($transaction->CardProcResp->AvsDisplay)) :
- $response['avs_display'] = (string) $transaction->CardProcResp->AvsDisplay;
- endif;
-
- if (isset($transaction->CardProcResp->Cvv2Resp)) :
- $response['cvv2_resp'] = (string) $transaction->CardProcResp->Cvv2Resp;
- endif;
- }
-
- return $response;
- }
-
- /**
- * Options from Response
- *
- * @param array
- */
- private function options_from($response)
- {
- $options = array();
- $options['authorization'] = $response['transaction_id'];
- $options['test'] = empty($response['mode']) || $response['mode'] != 'P';
- $options['fraud_review'] = in_array($response['return_code'], $this->FRAUDULENT);
-
- if (!empty($response['cvv2_resp'])) {
- $options['cvv_result'] = $this->CVV_RESPONSE_MAPPINGS[$response['cvv2_resp']];
- }
- $options['avs_result'] = $this->avs_code_from($response);
- }
-
- /**
- * Success From
- *
- * @param string
- * @param array
- * @return bool
- */
- private function success_from($action, $response)
- {
- if ($action == 'authorize' || $action == 'purchase' || $action == 'capture') {
- $transaction_status = $this->TRANSACTION_STATUS_MAPPINGS['accepted'];
- } elseif ($action == 'void') {
- $transaction_status = $this->TRANSACTION_STATUS_MAPPINGS['void'];
- } else {
- $transaction_status = null;
- }
-
- return
- (
- $response['return_code'] == self::APPROVED &&
- $response['transaction_id'] != null &&
- $response['auth_code'] != null &&
- $response['transaction_status'] == $transaction_status
- );
- }
-
- /**
- * Message From
- *
- * @param array
- * @return string
- */
- private function message_from($response)
- {
- return (isset($response['return_message']) ? $response['return_message'] : $response['error_message']);
- }
-
- /**
- * AVS Code From
- *
- * @param array
- * @return array
- */
- private function avs_code_from($response)
- {
- if (empty($response['avs_display']))
- return array('code' => 'U');
-
- switch ($response['avs_display']) {
- case 'YY':
- $code = "Y";
- break;
-
- case 'YN':
- $code = "A";
- break;
-
- case 'NY':
- $code = "W";
- break;
-
- case 'NN':
- $code = "C";
- break;
-
- case 'FF':
- $code = "G";
- break;
-
- default:
- $code = "R";
- break;
- }
-
- return array('code' => $code);
- }
-
-}
View
214 lib/AktiveMerchant/Billing/Gateways/payflow/PayflowCommon.php
@@ -1,214 +0,0 @@
-<?php
-
-namespace AktiveMerchant\Billing\Gateways;
-
-use AktiveMerchant\Billing\Gateway;
-
-class PayflowCommon extends Gateway
-{
- const TEST_URL = 'https://pilot-payflowpro.paypal.com';
- const LIVE_URL = 'https://payflowpro.paypal.com';
- protected $XMLNS = 'http://www.paypal.com/XMLPay';
- protected $CARD_MAPPING = array(
- 'visa' => 'Visa',
- 'master' => 'MasterCard',
- 'discover' => 'Discover',
- 'american_express' => 'Amex',
- 'jcb' => 'JCB',
- 'diners_club' => 'DinersClub',
- 'switch' => 'Switch',
- 'solo' => 'Solo'
- );
- protected $CVV_CODE = array(
- 'Match' => 'M',
- 'No Match' => 'N',
- 'Service Not Available' => 'U',
- 'Service Not Requested' => 'P'
- );
- public static $default_currency = 'USD';
- public static $supported_countries = array('US', 'CA', 'SG', 'AU');
- protected $options;
- protected $partner = 'PayPal';
- protected $timeout = 60;
- private $xml = '';
-
- function __construct($options = array())
- {
- $this->required_options('login, password', $options);
-
- $this->options = $options;
- if (isset($options['partner']))
- $this->partner = $options['partner'];
-
- if (isset($options['currency']))
- self::$default_currency = $options['currency'];
- }
-
- function capture($money, $authorization, $options)
- {
- $request = $this->build_reference_request('Capture', $money, $authorization, $options);
- return $this->commit($request);
- }
-
- function void($authorization, $options)
- {
- $request = $this->build_reference_request('Void', null, $authorization, $options);
- return $this->commit($request);
- }
-
- protected function build_request($body)
- {
- $this->xml .= <<<XML
-<?xml version="1.0" encoding="UTF-8"?>
-<XMLPayRequest Timeout="{$this->timeout}" version="2.1" xmlns="{$this->XMLNS}">
- <RequestData>
- <Vendor>{$this->options['login']}</Vendor>
- <Partner>{$this->partner}</Partner>
- <Transactions>
- <Transaction>
- <Verbosity>MEDIUM</Verbosity>
-XML;
- $this->xml .= $body;
-
- $user = isset($this->options['user']) ? $this->options['user'] : $this->options['login'];
-
- $this->xml .= <<<XML
- </Transaction>
- </Transactions>
- </RequestData>
- <RequestAuth>
- <UserPass>
- <User>{$user}</User>
- <Password>{$this->options['password']}</Password>
- </UserPass>
- </RequestAuth>
-</XMLPayRequest>
-XML;
- }
-
- private function build_reference_request($action, $money, $authorization, $options)
- {
- $bodyXml = <<<XML
- <{$action}>
- <PNRef>{$authorization}</PNRef>
-XML;
- if (!is_null($money)) {
- $default_currency = self::$default_currency;
- $bodyXml .= <<< XML
- <Invoice>
- <TotalAmt Currency="{$default_currency}">{$this->amount($money)}</TotalAmt>
- </Invoice>
-XML;
- }
-
- $bodyXml .= "</{$action}>";
-
- return $this->build_request($bodyXml);
- }
-
- protected function add_address($options, $address)
- {
- $xml = '';
-
- if (isset($address['name']))
- $xml .= "<Name>{$address['name']}</Name>";
-
- if (isset($options['email']))
- $xml .= "<EMail>{$options['email']}</EMail>";
-
- if (isset($address['phone']))
- $xml .= "<Phone>" . $address['phone'] . "</Phone>";
-
- $xml .= <<<XML
- <Address>
- <Street>{$address['address1']}</Street>
- <City>{$address['city']}</City>
- <State>{$address['state']}</State>
- <Zip>{$address['zip']}</Zip>
- <Country>{$address['country']}</Country>
- </Address>
-XML;
- return $xml;
- }
-
- private function parse($response_xml)
- {
- $xml = simplexml_load_string($response_xml);
-
- $response = array();
-
- $root = $xml->ResponseData;
- $transactionAttrs = $root->TransactionResults->TransactionResult->attributes();
-
- if (isset($transactionAttrs['Duplicate']) && $transactionAttrs['Duplicate'] == 'true')
- $response['duplicate'] = true;
-
- foreach ($root->children() as $node)
- $this->parse_element($response, $node);
-
- return $response;
- }
-
- private function parse_element($response, $node)
- {
- $nodeName = $node->getName();
-
- switch (true) {
- case $nodeName == 'RPPaymentResult':
- if (!isset($response[$nodeName]))
- $response[$nodeName] = array();
-
- $payment_result_response = array();
-
- foreach ($node->children() as $child)
- $this->parse_element($payment_result_response, $child);
-
- foreach ($payment_result_response as $key => $value)
- $response[$nodeName][$key] = $value;
- break;
-
- case $node->children()->count() > 0:
- foreach ($node->children() as $child)
- $this->parse_element($response, $child);
- break;
-
- case preg_match('/amt$/', $nodeName):
- $response[$nodeName] = $node->attributes()->Currency;
- break;
-
- case $nodeName == 'ExtData':
- $response[$node->attributes()->Name] = $node->attributes()->Value;
- break;
-
- default:
- $response[$nodeName] = (string) $node;
- }
- }
-
- protected function commit()
- {
- $url = $this->isTest() ? self::TEST_URL : self::LIVE_URL;
- $response = $this->parse($this->ssl_post($url, $this->xml));
- $this->xml = null;
-
- return new Merchant_Billing_Response(
- $response['Result'] == 0,
- $response['Message'],
- $response,
- $this->options_from($response));
- }
-
- private function options_from($response)
- {
- $options = array();
- $options['authorization'] = isset($response['PNRef']) ? $response['PNRef'] : null;
- $options['test'] = $this->isTest();
- if (isset($response['CVResult']))
- $options['cvv_result'] = $this->CVV_CODE[$response['CVResult']];
- if (isset($response['AVSResult']))
- $options['avs_result'] = array('code' => $response['AVSResult']);
-
- return $options;
- }
-
-}
View
24 lib/AktiveMerchant/Billing/Gateways/payflow/PayflowResponse.php
@@ -1,24 +0,0 @@
-<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-namespace AktiveMerchant\Billing\Gateways;
-
-use AktiveMerchant\Billing\Response;
-
-class PayflowResponse extends Response
-{
-
- function profileId()
- {
- return $this->params['profileId'];
- }
-
- function paymentHistory()
- {
- if (is_array($this->params['rpPaymentResult']))
- return $this->params['rpPaymentResult'];
- else
- return array();
- }
-
-}
View
96 unit_tests/AktiveMerchant/Billing/Gateways/PayflowUkTest.php
@@ -1,96 +0,0 @@
-<?php
-
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-require_once'config.php';
-
-use AktiveMerchant\Billing\Gateways\PayflowUk;
-use AktiveMerchant\Billing\Base;
-use AktiveMerchant\Billing\CreditCard;
-
-class PayflowUkTest extends AktiveMerchant\TestCase
-{
-
- public $gateway;
- public $amount;
- public $options;
- public $creditcard;
-
- protected function setUp()
- {
- Base::mode('test');
-
- $login_info = $this->getFixtures()->offsetGet('payflowuk');
-
- $this->gateway = new PayflowUk($login_info);
-
- $this->amount = 100.00;
-
- $this->creditcard = new CreditCard(array(
- 'number' => '5105105105105100',
- 'month' => 11,
- 'year' => 2009,
- 'first_name' => 'Cody',
- 'last_name' => 'Fauser',
- 'verification_value' => '000',
- 'type' => 'master'
- ));
-
- $this->options = array(
- 'billing_address' => array(
- 'name' => 'Cody Fauser',
- 'address1' => '1234 Shady Brook Lane',
- 'city' => 'Ottawa',
- 'state' => 'ON',
- 'country' => 'CA',
- 'zip' => '90210',
- 'phone' => '555-555-5555'
- ),
- 'email' => 'cody@example.com'
- );
- }
-
- public function testInitialization()
- {
- $this->assertNotNull($this->gateway);
- $this->assertNotNull($this->creditcard);
- }
-
- function testAuthorizationAndCapture()
- {
- $this->mock_request($this->successful_authorize_response());
-
- $auth = $this->gateway->authorize(
- $this->amount,
- $this->creditcard,
- $this->options
- );
-
- $this->assertTrue($auth->success());
- $this->assertEquals('Approved', $auth->message());
-
- //$capture = $this->gateway->capture($this->amount, $auth->authorization(), $this->options);
- //$this->assertTrue($capture->success());
- }
-
- private function successful_authorize_response()
- {
- return '<?xml version="1.0" encoding="UTF-8"?>
- <ResponseData>
- <Result>0</Result>
- <Message>Approved</Message>
- <Partner>verisign</Partner>
- <HostCode>000</HostCode>
- <ResponseText>AP</ResponseText>
- <PnRef>VUJN1A6E11D9</PnRef>
- <IavsResult>N</IavsResult>
- <ZipMatch>Match</ZipMatch>
- <AuthCode>094016</AuthCode>
- <Vendor>ActiveMerchant</Vendor>
- <AvsResult>Y</AvsResult>
- <StreetMatch>Match</StreetMatch>
- <CvResult>Match</CvResult>
- </ResponseData>';
- }
-
-}
View
235 unit_tests/AktiveMerchant/Billing/Gateways/PsigateTest.php
@@ -1,235 +0,0 @@
-<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-use AktiveMerchant\Billing\Gateways\Psigate;
-use AktiveMerchant\Billing\Base;
-use AktiveMerchant\Billing\CreditCard;
-use AktiveMerchant\Billing\Exception;
-
-/**
- * Test file for PsiGate merchant
- *
- * @package Aktive-Merchant
- * @author Scott Gifford <sgifford@suspectclass.com>
- * @license http://www.opensource.org/licenses/mit-license.php
- *
- */
-require_once 'config.php';
-
-class TestPsigate extends Psigate {
- protected static $URL = "https://dev.psigate.com:7989/Messenger/XMLMessenger";
-}
-
-class BadNetwork extends TestPsigate {
- // Bad host and port numbers to simulate network failure
- static $URL = "https://localhost:7777/Messenger/XMLMessenger";
-}
-
-class BadRequest extends TestPsigate {
- protected function post_data($money, $creditcard, $options) {
- return "<" . parent::post_data($money, $creditcard, $options);
- }
-}
-
-class BadResponse extends TestPsigate {
- protected function ssl_post($endpoint, $data, $options = array()) {
- // Prepend a character to make parsing fail
- return "<" . parent::ssl_post($endpoint, $data, $options);
- }
-}
-
-
-class PsigateTest extends AktiveMerchant\TestCase
-{
- public $gateway;
- public $amount;
- public $options;
- public $creditcard;
- public $ordernum;
- public $base_amount;
- public $ordername;
- private $login_info;
-
- function __construct() {
- $this->ordernum = 0;
- }
-
- /**
- * Setup
- */
- function setUp()
- {
- $this->login_info = $this->getFixtures()->offsetGet('psigate');
-
- $this->gateway = new TestPsigate($this->login_info);
-
- Base::mode('test');
- $this->gateway->test_mode(Psigate::TEST_MODE_ALWAYS_AUTH);
-
- $this->creditcard = new CreditCard(array(
- "first_name" => "John",
- "last_name" => "Doe",
- "number