Converted files with CR/LF to LF only.
authorChuck Scott <cscott@gaslightmedia.com>
Tue, 10 Apr 2018 15:45:27 +0000 (11:45 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Tue, 10 Apr 2018 15:45:27 +0000 (11:45 -0400)
lib/paymentProcessors/Authorize.Net/paymentGateway.php
lib/paymentProcessors/MerchantSolutions/paymentGateway.php
lib/paymentProcessors/PayPal/paymentGateway.php
lib/paymentProcessors/PayPal/test.php
lib/paymentProcessors/TestByCardNumber/paymentGateway.php
lib/paymentProcessors/TestGood/paymentGateway.php

index c7034e0..e998e8d 100644 (file)
@@ -16,19 +16,19 @@ use net\authorize\api\controller as AnetController;
 // use net\authorize\api\contract\v1\CustomerProfileIdType;
 
 // Uncomment the following line to activate log - DO NOT KEEP THIS ENABLED FOR NORMAL PRODUCTION!
-// define("AUTHORIZENET_LOG_FILE", "phplog");\r
-
-/**\r
- * Authorize.net PaymentGateway class\r
- *\r
- * PHP version 5\r
- *\r
- * @category Event Management Admin Tickets\r
- * @package  EventManagement\r
- * @author   Chuck Scott <cscott@gaslightmedia.com>\r
- * @license  http://www.gaslightmedia.com Gaslightmedia\r
- * @release  SVN: $Id: AuthorizeNet.php,v 1.0 2011/01/25 19:31:47 cscott Exp $\r
- * @link     <>\r
+// define("AUTHORIZENET_LOG_FILE", "phplog");
+
+/**
+ * Authorize.net PaymentGateway class
+ *
+ * PHP version 5
+ *
+ * @category Event Management Admin Tickets
+ * @package  EventManagement
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: AuthorizeNet.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ * @link     <>
  */
 
 /*
@@ -37,24 +37,24 @@ use net\authorize\api\controller as AnetController;
  * See following URL for API documentation (hover over "API" at top of page).
  *  https://developer.authorize.net/api/
  *
- */\r
-\r
-class PaymentGateway\r
-{\r
-    /**\r
-     * account\r
-     *\r
-     * @var array\r
-     * @access public\r
-     */\r
-    var $account;\r
-    /**\r
-     * Merchant API Credentials\r
-     *\r
-     * @var object\r
-     * @acess private\r
-     */\r
-    private $merchantAuthentication;\r
+ */
+
+class PaymentGateway
+{
+    /**
+     * account
+     *
+     * @var array
+     * @access public
+     */
+    var $account;
+    /**
+     * Merchant API Credentials
+     *
+     * @var object
+     * @acess private
+     */
+    private $merchantAuthentication;
     /**
      * Test Mode
      *
@@ -63,32 +63,32 @@ class PaymentGateway
      */
     private $testMode;
 
-    /**\r
-     * Constructor\r
-     *\r
-     * @param array $account Account information\r
-     *\r
-     * @access public\r
-     *\r
-      * Information provided\r
-     *\r
-     * $account\r
-     *        login                 Authorize.net login\r
-     *        key                   Authorize.net login key\r
-     *        test                  Test mode\r
-     *                                  0 = Production Mode (PRODUCTION)\r
-     *                                  1 = Local Transaction Approval Test\r
-     *                                  2 = Local Transaction Decline Test\r
-     *                                  3 = On-Line Transaction Test (SANDBOX)\r
-     *        conf                  True if Authorize.net should send confirmation E-Mail to customer - Not used by Authroize.net API\r
-     *        email                 Merchant E-Mail address to receive notices - Not used by Authorize.net API\r
-     *\r
-     * API Access for Authorize.net SANDBOX\r
-     *         API Login ID:        44pvQ8D7d\r
-     *         Transaction Key:     8rj6ME772K9Pe9pJ\r
-     *         Secret Question:     Simon\r
-     *\r
-     */\r
+    /**
+     * Constructor
+     *
+     * @param array $account Account information
+     *
+     * @access public
+     *
+      * Information provided
+     *
+     * $account
+     *        login                 Authorize.net login
+     *        key                   Authorize.net login key
+     *        test                  Test mode
+     *                                  0 = Production Mode (PRODUCTION)
+     *                                  1 = Local Transaction Approval Test
+     *                                  2 = Local Transaction Decline Test
+     *                                  3 = On-Line Transaction Test (SANDBOX)
+     *        conf                  True if Authorize.net should send confirmation E-Mail to customer - Not used by Authroize.net API
+     *        email                 Merchant E-Mail address to receive notices - Not used by Authorize.net API
+     *
+     * API Access for Authorize.net SANDBOX
+     *         API Login ID:        44pvQ8D7d
+     *         Transaction Key:     8rj6ME772K9Pe9pJ
+     *         Secret Question:     Simon
+     *
+     */
     public function __construct($account)
     {
 
@@ -105,138 +105,138 @@ class PaymentGateway
         $this->merchantAuthentication->setName($account['login']);
         $this->merchantAuthentication->setTransactionKey($account['key']);
 
-    }\r
-\r
-    /**\r
-     * Process a Payment\r
-     *\r
-     * @param payment Array payment information\r
-     * @param contact Array contact information\r
-     *\r
-     * @access public\r
-     * @return array\r
-     *\r
-     * Information provided\r
-     *\r
+    }
+
+    /**
+     * Process a Payment
+     *
+     * @param payment Array payment information
+     * @param contact Array contact information
+     *
+     * @access public
+     * @return array
+     *
+     * Information provided
+     *
      * $payment array
-     *        transOpt            Transaction option: 0 = Charge Card, 1 = Charge Card and stroe as Profile, 2 = Charge using Stored Profile\r
+     *        transOpt            Transaction option: 0 = Charge Card, 1 = Charge Card and stroe as Profile, 2 = Charge using Stored Profile
      *        name                Name of Venue
      *        customerProfileId   Customer Profile ID from stored profile - if using transOpt = 2
-     *        paymentProfileId    Payment Profile ID from stored profile - if using transOpt = 2\r
-     *        charge              Total to be charged\r
-     *        cctype              Card type (not used for Authorize.net)        Not Required\r
-     *        ccname              Name on card (not used for Authorize.net)\r
-     *        ccnumb              Card number\r
-     *        ccexp               Expiration date (m/y)\r
-     *        cccode              Security code on back of card\r
-     *        invoice             Invoice # is session ID (or some part thereof)\r
-     *                                Max 20 chars, letters and digits only\r
-     *                                Only last 20 chars used if longer\r
-     *\r
+     *        paymentProfileId    Payment Profile ID from stored profile - if using transOpt = 2
+     *        charge              Total to be charged
+     *        cctype              Card type (not used for Authorize.net)        Not Required
+     *        ccname              Name on card (not used for Authorize.net)
+     *        ccnumb              Card number
+     *        ccexp               Expiration date (m/y)
+     *        cccode              Security code on back of card
+     *        invoice             Invoice # is session ID (or some part thereof)
+     *                                Max 20 chars, letters and digits only
+     *                                Only last 20 chars used if longer
+     *
      * $customer array
      *        id                  Customer ID - Must be unique for all customers
-     *        fname               Customer first name\r
-     *        lname               Customer last name\r
-     *        addr1               Address Line 1\r
-     *        addr2               Address Line 2\r
-     *        city                City\r
-     *        state               State\r
-     *        country             Country\r
-     *        zip                 ZIP/Postal code\r
-     *        phone               Customer phone number\r
-     *        email               Customer E-Mail address\r
-     *\r
+     *        fname               Customer first name
+     *        lname               Customer last name
+     *        addr1               Address Line 1
+     *        addr2               Address Line 2
+     *        city                City
+     *        state               State
+     *        country             Country
+     *        zip                 ZIP/Postal code
+     *        phone               Customer phone number
+     *        email               Customer E-Mail address
+     *
      * return array
-     *        gateway             Name of this gateway\r
-     *        status              Numeric return status code\r
-     *                                 1        Approved\r
-     *                                 2        Bad data supplied\r
-     *                                 3        Communications failure\r
-     *                                 4        Bad response\r
-     *                                 5        Transaction not valid\r
-     *                                 6        Merchant account problem\r
-     *                                 7        Card declined\r
-     *        statusText          Short name of status\r
+     *        gateway             Name of this gateway
+     *        status              Numeric return status code
+     *                                 1        Approved
+     *                                 2        Bad data supplied
+     *                                 3        Communications failure
+     *                                 4        Bad response
+     *                                 5        Transaction not valid
+     *                                 6        Merchant account problem
+     *                                 7        Card declined
+     *        statusText          Short name of status
      *        authCode            Authorization code - blank if card not accepted
      *        transId             Authorize.Net Transaction ID for reference to this transaction
-     *        refId               Our reference ID for this request - this is also sent to Authorize.net for them to store with the transaction\r
+     *        refId               Our reference ID for this request - this is also sent to Authorize.net for them to store with the transaction
      *        description         Text description of result
      *        customerProfileId   Customer Profile ID - Required to use stored payment profile for future charges
      *        paymentProfileId    Payment Profile ID - Required to use stored payment profile for future charges
      *        profileStatus       Status of stored profile request - True if stored profile information is returned
      *        profileStatusText   Text descibing status of request to store payment profile
-     *\r
-     * Authorize.net test card numbers\r
-     *        American Express    370000000000002\r
-     *        Discover            6011000000000012\r
-     *        Visa                4007000000027\r
-     *                            4012888818888\r
-     *        JCB                 3088000000000017\r
-     *        Diners Club         38000000000006\r
-     *        Carte Blanche       38000000000006\r
-     */\r
-    public function processPayment($payment = false, $customer = false)\r
-    {\r
+     *
+     * Authorize.net test card numbers
+     *        American Express    370000000000002
+     *        Discover            6011000000000012
+     *        Visa                4007000000027
+     *                            4012888818888
+     *        JCB                 3088000000000017
+     *        Diners Club         38000000000006
+     *        Carte Blanche       38000000000006
+     */
+    public function processPayment($payment = false, $customer = false)
+    {
 
         $errorMsg = array();
 
         // Set the transaction's refId using timestamp
         $refId = 'ref' . time();
-\r
-        // Check for required data ***** NEED TO ADD TO THIS TO TEST ALL NEEDED FIELDS *****\r
-        if (!is_array($payment) || !is_array($payment)) {\r
-            $resp = array(\r
-                'gateway'           => 'Authorize.Net',\r
-                'status'            => 2,\r
-                'statusText'        => 'Bad Data Supplied',\r
+
+        // Check for required data ***** NEED TO ADD TO THIS TO TEST ALL NEEDED FIELDS *****
+        if (!is_array($payment) || !is_array($payment)) {
+            $resp = array(
+                'gateway'           => 'Authorize.Net',
+                'status'            => 2,
+                'statusText'        => 'Bad Data Supplied',
                 'authCode'          => '',
                 'transId'           => '',
-                'refId'             => $refId,\r
-                'description'       => 'The required payment and contact information was not supplied.'\r
-            );\r
-            return $resp;\r
-        }\r
-\r
-        // Check for specified test mode\r
-        switch ($this->account['test']) {\r
-\r
+                'refId'             => $refId,
+                'description'       => 'The required payment and contact information was not supplied.'
+            );
+            return $resp;
+        }
+
+        // Check for specified test mode
+        switch ($this->account['test']) {
+
             // Production Mode
             case 0:
                 break;
 
-            // Local Test\r
-            case 1:\r
-                // Always return a card approval\r
-                $resp = array(\r
-                    'gateway'       => 'Authorize.Net',\r
-                    'status'        => 1,\r
-                    'statusText'    => 'Card Approved',\r
-                    'authCode'      => '12345678',\r
+            // Local Test
+            case 1:
+                // Always return a card approval
+                $resp = array(
+                    'gateway'       => 'Authorize.Net',
+                    'status'        => 1,
+                    'statusText'    => 'Card Approved',
+                    'authCode'      => '12345678',
                     'transId'       => '0',
                     'refId'             => $refId,
-                    'description'   => '(TESTMODE) Local Test - Card Approved'\r
-                );\r
-                return $resp;\r
-                break;\r
-\r
-            // Fail Test\r
-            case 2:\r
-                $resp = array(\r
-                    'gateway'       => 'Authorize.Net',\r
-                    'status'        => 7,\r
-                    'statusText'    => 'Card Declined',\r
-                    'authCode'      => '',\r
+                    'description'   => '(TESTMODE) Local Test - Card Approved'
+                );
+                return $resp;
+                break;
+
+            // Fail Test
+            case 2:
+                $resp = array(
+                    'gateway'       => 'Authorize.Net',
+                    'status'        => 7,
+                    'statusText'    => 'Card Declined',
+                    'authCode'      => '',
                     'transId'       => '',
                     'refId'             => $refId,
-                    'description'   => '(TESTMODE) Local Test - Card Declined'\r
-                );\r
-                return $resp;\r
-                break;\r
-\r
-            // Online Test\r
-            case 3:\r
-                // Force Use of Authorize.net SANDBOX\r
-                $this->account['environment'] = 'SANDBOX';\r
+                    'description'   => '(TESTMODE) Local Test - Card Declined'
+                );
+                return $resp;
+                break;
+
+            // Online Test
+            case 3:
+                // Force Use of Authorize.net SANDBOX
+                $this->account['environment'] = 'SANDBOX';
                 break;
 
             // Invalid test setting
@@ -252,8 +252,8 @@ class PaymentGateway
                 );
                 return $resp;
                 break;
-\r
-        }\r
+
+        }
 
         // Test for certain required data or data content issues
         if (isset($customer['id']) && trim($customer['id']) != '') {
@@ -337,19 +337,19 @@ class PaymentGateway
             );
             return $resp;
         }
-\r
-        // Create order information\r
+
+        // Create order information
         $order = new AnetAPI\OrderType();
         if (isset($payment['invoice']) && trim($payment['invoice']) != '') {
             $order->setInvoiceNumber(substr($payment['invoice'], -20));
-        }\r
-        $order->setDescription($payment['name']);\r
+        }
+        $order->setDescription($payment['name']);
 
-        // Set the customer's identifying information\r
+        // Set the customer's identifying information
         $customerIdent = new AnetAPI\CustomerDataType();
         if (isset($customer['email']) && trim($customer['email']) != '') {
             $customerIdent->setEmail($customer['email']);
-        }\r
+        }
         //        $customerIdentData->setType("individual");             // "individual" or "business" - Not required
         if (isset($customer['id']) && trim($customer['id']) != '') {
             $customerIdent->setId($customer['id']);
@@ -408,7 +408,7 @@ class PaymentGateway
 
         }
 
-        // Payment reference ID (up to 20 characters) for this request - Possibly supplied\r
+        // Payment reference ID (up to 20 characters) for this request - Possibly supplied
         $request = new AnetAPI\CreateTransactionRequest();
         $request->setMerchantAuthentication($this->merchantAuthentication);
         $request->setRefId($refId);
@@ -434,9 +434,9 @@ class PaymentGateway
                 die('Authorise.Net Payment Gateway: Serious error - processing environment not specified in calling code!');
                 break;
 
-        }\r
+        }
 
-        // echo "TRANSACTION RESPONSE<br><pre>".print_r($response,1)."</pre>";\r
+        // echo "TRANSACTION RESPONSE<br><pre>".print_r($response,1)."</pre>";
 
         // Assume the worst
         $respCode = 0;
@@ -488,86 +488,86 @@ class PaymentGateway
             }
 
         }
-\r
-        /*\r
-         * Possible returned Authorize.net status codes\r
-         *     1 = approved\r
-         *     2 = declined\r
-         *     3 = error\r
-         *     4 = held for review\r
+
+        /*
+         * Possible returned Authorize.net status codes
+         *     1 = approved
+         *     2 = declined
+         *     3 = error
+         *     4 = held for review
          */
-\r
-        // Determine response method\r
+
+        // Determine response method
         switch ($respCode) {
 
-            // Approved\r
-            case 1:\r
-                $resp = array(\r
-                    'gateway'       => 'Authorize.Net',\r
-                    'status'        => 1,\r
-                    'statusText'    => 'Card Approved',\r
+            // Approved
+            case 1:
+                $resp = array(
+                    'gateway'       => 'Authorize.Net',
+                    'status'        => 1,
+                    'statusText'    => 'Card Approved',
                     'authCode'      => $transResponse->getAuthCode(),
-                    'transId'       => $transResponse->getTransId(),\r
+                    'transId'       => $transResponse->getTransId(),
                     'refId'         => $refId,
-                    'description'   => $respDescr\r
-                );\r
-                break;\r
+                    'description'   => $respDescr
+                );
+                break;
 
             // Declined
-\r
-            case 2:\r
-                $resp = array(\r
-                    'gateway'       => 'Authorize.Net',\r
-                    'status'        => 7,\r
-                    'statusText'    => 'Card Declined',\r
+
+            case 2:
+                $resp = array(
+                    'gateway'       => 'Authorize.Net',
+                    'status'        => 7,
+                    'statusText'    => 'Card Declined',
                     'authCode'      => '',
-                    'transId'       => '',\r
+                    'transId'       => '',
                     'refId'         => $refId,
-                    'description'   => $respDescr\r
-                );\r
-                break;\r
-
-            // Error\r
-            case 3:\r
-                $resp = array(\r
-                    'gateway'       => 'Authorize.Net',\r
-                    'status'        => 3,\r
-                    'statusText'    => 'Transaction Error',\r
-                    'authCode'      => '',\r
+                    'description'   => $respDescr
+                );
+                break;
+
+            // Error
+            case 3:
+                $resp = array(
+                    'gateway'       => 'Authorize.Net',
+                    'status'        => 3,
+                    'statusText'    => 'Transaction Error',
+                    'authCode'      => '',
                     'transId'       => '',
                     'refId'         => $refId,
-                    'description'   => $respDescr\r
-                );\r
-                break;\r
-
-            // Held for Review\r
-            case 4:\r
-                $resp = array(\r
-                    'gateway'       => 'Authorize.Net',\r
-                    'status'        => 7,\r
-                    'statusText'    => 'Held for review',\r
-                    'authCode'      => '',\r
+                    'description'   => $respDescr
+                );
+                break;
+
+            // Held for Review
+            case 4:
+                $resp = array(
+                    'gateway'       => 'Authorize.Net',
+                    'status'        => 7,
+                    'statusText'    => 'Held for review',
+                    'authCode'      => '',
                     'transId'       => '',
                     'refId'         => $refId,
-                    'description'   => $response->response_reason_text\r
-                );\r
-                break;\r
-
-            // Any other response code\r
-            default:\r
-                $resp = array(\r
-                    'gateway'       => 'Authorize.Net',\r
-                    'status'        => 4,\r
-                    'statusText'    => 'Bad Response',\r
-                    'authCode'      => '',\r
+                    'description'   => $response->response_reason_text
+                );
+                break;
+
+            // Any other response code
+            default:
+                $resp = array(
+                    'gateway'       => 'Authorize.Net',
+                    'status'        => 4,
+                    'statusText'    => 'Bad Response',
+                    'authCode'      => '',
                     'transId'       => '',
                     'refId'         => $refId,
-                    'description'   => $respDescr\r
-                );\r
-                break;\r
-\r
+                    'description'   => $respDescr
+                );
+                break;
+
         }
-\r
+
         // echo "Response before profile<br><pre>".print_r($resp,1)."</pre>";
 
         // Check if request to create a customer profile using this transaction
@@ -597,9 +597,9 @@ class PaymentGateway
             }
 
         }
-\r
-        return $resp;\r
-\r
+
+        return $resp;
+
     }
 
     /**
@@ -732,6 +732,6 @@ class PaymentGateway
         return $resp;
 
 
-    }\r
-\r
-}\r
+    }
+
+}
index 6968fe8..4621c97 100644 (file)
-<?php\r
-/**\r
- * Event Management System\r
- * Merchant Solutions PaymentGateway class\r
- *\r
- * @category Front-End\r
- * @package  EventManagement\r
- * @author   Chuck Scott <cscott@gaslightmedia.com>\r
- * @license  http://www.gaslightmedia.com Gaslightmedia\r
- * @release  SVN: $Id: classes/paymentProcessors/MerchantSolutions.php,v 1.0 2011/01/25 19:31:47 cscott Exp $\r
- * @link     <>\r
- */\r
-\r
-/**\r
- * MerchantSolutions PaymentGateway class\r
- *\r
- * PHP version 5\r
- *\r
- * @category Event Management Admin Tickets\r
- * @package  EventManagement\r
- * @author   Chuck Scott <cscott@gaslightmedia.com>\r
- * @license  http://www.gaslightmedia.com Gaslightmedia\r
- * @release  SVN: $Id: classes/paymentProcessors/MerchantSolutions.php,v 1.0 2011/01/25 19:31:47 cscott Exp $\r
- * @link     <>\r
- */\r
-\r
-define( "MS_WSDL", "https://trans.merchantsolution.com/Web/services/TransactionService?wsdl" );\r
-\r
-/**\r
- * Merchant Solutions Payment Gateway class\r
- *\r
- * PHP version 5\r
- */\r
-\r
-class PaymentGateway\r
-{\r
-    /**\r
-     * Transaction Result\r
-     *\r
-     * @var    $result\r
-     * @access public\r
-     */\r
-    public $result = false;\r
-    /**\r
-     * Raw response data\r
-     *\r
-     * @var    $response\r
-     * @access public\r
-     */\r
-    public $response = false;\r
-    /**\r
-     * XML Soap Client Object\r
-     *\r
-     * @var    $client\r
-     * @access public\r
-     */\r
-    public $client;\r
-    /**\r
-     * Request Object\r
-     *\r
-     * @var $request\r
-     * @access public\r
-     */\r
-    public $request;\r
-\r
-    /**\r
-     * Constructor\r
-     *\r
-     * @param array $account Account information\r
-     *\r
-     * @return boolean    Returns value of $success parameter\r
-     * @access public\r
-     *\r
-     * $account\r
-        *              acctid                  MerchantSolutions account ID - Use "TEST0" for texting\r
-        *              merchantpin             MerchantSolutions account PIN - Login to Merchant center, then "FRISK(TM) Management" and "Configure Options"\r
-        *              test                    Test mode\r
-        *                                                      0 = Production Mode\r
-        *                                                      1 = Local Transaction Approval Test\r
-        *                                                      2 = Local Transaction Decline Test\r
-        *                                                      3 = On-Line Transaction Test\r
-        *              conf                    (not used for Merchant Solutions)\r
-        *              email                   Merchant E-Mail address to receive notices from Merchant Solutions for the transaction\r
-        *\r
-     * Test Merchant Account\r
-     *                 AcctID:                 MSDMO\r
-     *                 Userid:                 Cscott\r
-     *                 Password:               Glm3Merch#Sol\r
-     *                 MerchantPin:    BVR0V3462V5GmZK03MXtWE5u9HeUJX62\r
-        *\r
-     */\r
-    public function __construct($account)\r
-    {\r
-\r
-       // Setup request object\r
-       $this->request = (object) array(\r
-                       'acctid' => false,\r
-                       'merchantpin' => false,\r
-                       'amount' => false,\r
-                       'ccnum' => false,\r
-                       'expmon' => false,\r
-                       'expyear' => false,\r
-                       'ccname' => false,\r
-                       'cardpresent' => 0,\r
-                       'cardreaderpresent' => 0,\r
-                       'cvv2' => false,\r
-                       'accttype' => 1,\r
-                       'profileactiontype' => 2,\r
-                       'manualrecurring' => 0,\r
-                       'avs_override' => 0,\r
-                       'cvv2_override' => 0,\r
-                       'loadbalance_override' => 0,\r
-                       'duplicate_override' => 0,\r
-                       'accountlookupflag' => 0,\r
-                       'billaddress' => (object) array(\r
-                               'addr1' => '',\r
-                               'addr2' => '',\r
-                               'city' => '',\r
-                               'state' => '',\r
-                               'zip' => '',\r
-                               'country' => ''\r
-                       )\r
-       );\r
-\r
-       $this->account = $account;\r
-       $this->request->acctid = $account['acctid'];\r
-       $this->request->merchantpin = $account['merchantpin'];\r
-\r
-       // Test to see if soap support has been installed\r
-       if (!extension_loaded('soap')) {\r
-           trigger_error('*** PHP SOAP not installed and required by MerchantSolutions payment gateway! ***', E_USER_ERROR);\r
-       }\r
-\r
-        // Setup options related to doing the SOAP calls\r
-        ini_set('soap.wsdl_cache_enabled', 1);\r
-        use_soap_error_handler(false);\r
-        $soapOptions = array(\r
-            "exceptions" => 1,\r
-            'connection_timeout' => 10\r
-        );\r
-\r
-        // Setup SOAP client and get WSDL for gateway\r
-        try {\r
-\r
-            // XDebug prevents catching fatal errors with the Soap calls\r
-            if (function_exists('xdebug_disable')) {\r
-                xdebug_disable();\r
-            }\r
-\r
-            // Create new soap client instance\r
-            $this->client = @new SoapClient(MS_WSDL, $soapOptions);\r
-\r
-            // If XDebug was dissabled, re-enable it\r
-            if (function_exists('xdebug_enable')) {\r
-                xdebug_enable();\r
-            }\r
-\r
-            // Indicate setup OK\r
-                       return true;\r
-\r
-        } catch (SoapFault $exception) {\r
-\r
-                       return false;\r
-        }\r
-\r
-        return false;\r
-    }\r
-\r
-    /**\r
-     * Process a Payment\r
-     *\r
-     * @param payment Array payment information\r
-     * @param contact Array contact information\r
-     *\r
-     * @access public\r
-     * @return array\r
-     *\r
-     * Information provided\r
-     *\r
-     * $payment array\r
-     *         name                            Name of Venue\r
-     *         charge                          Total to be charged\r
-     *         cctype                          Card type\r
-     *         ccname                          Name on card\r
-     *         ccnumb                          Card number\r
-     *         ccexp                           Expiration date (m/y)\r
-     *         cccode                          Security code on back of card\r
-     *         invoice                         Invoice # is session ID (or some part thereof)\r
-     *\r
-     * $contact array\r
-     *         fname                           Customer first name\r
-     *         lname                           Customer last name\r
-     *         addr1                           Address Line 1\r
-     *         addr2                           Address Line 2\r
-     *         city                            City\r
-     *         state                           State\r
-     *         country                         Country\r
-     *         zip                                     ZIP/Postal code\r
-     *         phone                           Customer phone number\r
-     *         email                           Customer E-Mail address\r
-     *\r
-     * return array\r
-     *                 status                          Numeric return status code\r
-     *                                                                 1               Approved\r
-     *                                                                 2               Bad data supplied\r
-     *                                                                 3               Communications failure\r
-     *                                                                 4               Bad response\r
-     *                                                                 5               Transaction not valid\r
-     *                                                                 6               Merchant account problem\r
-     *                                                                 7               Card declined\r
-     *         statusText                      Short name of status\r
-     *         authCode                        Authorization code - blank if card not accepted\r
-     *         description                     Longer description of result\r
-     *\r
-     *\r
-     */\r
-    public function processPayment($payment = false, $contact = false)\r
-    {\r
-\r
-       // Set data\r
-       $this->request->amount = $payment['charge'];\r
-       $this->request->ccnum = $payment['ccnumb'];\r
-       $exp = explode('/', $payment['ccexp']);\r
-       $this->request->expmon = $exp[0];\r
-       $this->request->expyear = $exp[1];\r
-       $this->request->ccname = $payment['ccname'];\r
-       $this->request->cvv2 = $payment['cccode'];\r
-       $this->request->memo = $payment['name'].' - Event Tickets';\r
-       $this->request->billaddress->addr1 = $contact['addr1'];\r
-       $this->request->billaddress->addr2 = $contact['addr2'];\r
-       $this->request->billaddress->city = $contact['city'];\r
-       $this->request->billaddress->state = $contact['state'];\r
-       $this->request->billaddress->zip = $contact['zip'];\r
-       $this->request->billaddress->addr1 = $contact['country'];\r
-       $this->request->phone = $contact['phone'];\r
-       $this->request->email = $contact['email'];\r
-       $this->request->merchantordernumber = substr($payment['invoice'], -20);\r
-\r
-       // Check for local tests that don't require communication with Authorize.net\r
-       switch ($this->account['test']) {\r
-\r
-               // Local Test\r
-               case 1:\r
-                       // Always return a card approval\r
-                       $resp = array(\r
-                    'gateway' => 'MerchantSolutions',\r
-                    'status' => 1,\r
-                    'statusText' => 'Card Approved',\r
-                    'authCode' => '000000',\r
-                    'description' => '(TESTMODE) Local Test - Card Approved'\r
-                       );\r
-                       return $resp;\r
-                       break;\r
-\r
-               // Fail Test\r
-               case 2:\r
-                       $resp = array(\r
-                    'gateway' => 'MerchantSolutions',\r
-                    'status' => 7,\r
-                    'statusText' => 'Card Declined',\r
-                    'authCode' => '',\r
-                    'description' => '(TESTMODE) Local Test - Card Declined'\r
-                       );\r
-                       return $resp;\r
-                       break;\r
-\r
-               // Online Test\r
-               case 3:\r
-                       $this->request->acctid = 'TEST0';\r
-                       break;\r
-\r
-                       // Production Mode\r
-               case 0:\r
-                       break;\r
-       }\r
-\r
-\r
-\r
-        // Try to process the transaction\r
-        try {\r
-\r
-            // Deal with XDebug if that's enabled\r
-            if (function_exists('xdebug_disable')) {\r
-                xdebug_disable();\r
-            }\r
-\r
-            // Send request to Merchant Solutions\r
-            $this->response = $this->client->processCCSale($this->request);\r
-\r
-            // Restore XDebug if that was enabled\r
-            if (function_exists('xdebug_enable')) {\r
-                xdebug_enable();\r
-            }\r
-\r
-            // If approved\r
-            if (strtoupper($this->result) == 'APPROVED') {\r
-\r
-               $resp = array(\r
-                    'gateway' => 'MerchantSolutions',\r
-                    'status' => 1,\r
-                    'statusText' => 'Card Approved',\r
-                    'authCode' => $this->response->authcode,\r
-                    'description' => $this->response->status\r
-               );\r
-               return $resp;\r
-\r
-            // Must be declined\r
-            } else {\r
-\r
-               $x = explode(":", $this->response->result);\r
-                               $resp = array(\r
-                    'gateway' => 'MerchantSolutions',\r
-                    'status' => 7,\r
-                    'statusText' => 'Card Declined',\r
-                    'authCode' => '',\r
-                    'description' => $x[2]\r
-                               );\r
-                               return $resp;\r
-\r
-\r
-            }\r
-\r
-        // If there's a communications failure\r
-        } catch (SoapFault $exception) {\r
-\r
-                       // Return communications failure\r
-               $resp = array(\r
-                'gateway' => 'MerchantSolutions',\r
-                'status' => 3,\r
-                'statusText' => 'Transaction Error',\r
-                'authCode' => '',\r
-                'description' => 'Unable to communicate with credit card processing service.'\r
-                       );\r
-               return $resp;\r
-\r
-        }\r
-\r
-        $resp = array(\r
-            'gateway' => 'MerchantSolutions',\r
-            'status' => 4,\r
-            'statusText' => 'Bad Response',\r
-            'authCode' => '',\r
-            'description' => 'Received unknown response from the credit card processing service.'\r
-        );\r
-        return $resp;\r
-\r
-    }\r
-\r
-}\r
+<?php
+/**
+ * Event Management System
+ * Merchant Solutions PaymentGateway class
+ *
+ * @category Front-End
+ * @package  EventManagement
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: classes/paymentProcessors/MerchantSolutions.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ * @link     <>
+ */
+
+/**
+ * MerchantSolutions PaymentGateway class
+ *
+ * PHP version 5
+ *
+ * @category Event Management Admin Tickets
+ * @package  EventManagement
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: classes/paymentProcessors/MerchantSolutions.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ * @link     <>
+ */
+
+define( "MS_WSDL", "https://trans.merchantsolution.com/Web/services/TransactionService?wsdl" );
+
+/**
+ * Merchant Solutions Payment Gateway class
+ *
+ * PHP version 5
+ */
+
+class PaymentGateway
+{
+    /**
+     * Transaction Result
+     *
+     * @var    $result
+     * @access public
+     */
+    public $result = false;
+    /**
+     * Raw response data
+     *
+     * @var    $response
+     * @access public
+     */
+    public $response = false;
+    /**
+     * XML Soap Client Object
+     *
+     * @var    $client
+     * @access public
+     */
+    public $client;
+    /**
+     * Request Object
+     *
+     * @var $request
+     * @access public
+     */
+    public $request;
+
+    /**
+     * Constructor
+     *
+     * @param array $account Account information
+     *
+     * @return boolean    Returns value of $success parameter
+     * @access public
+     *
+     * $account
+        *              acctid                  MerchantSolutions account ID - Use "TEST0" for texting
+        *              merchantpin             MerchantSolutions account PIN - Login to Merchant center, then "FRISK(TM) Management" and "Configure Options"
+        *              test                    Test mode
+        *                                                      0 = Production Mode
+        *                                                      1 = Local Transaction Approval Test
+        *                                                      2 = Local Transaction Decline Test
+        *                                                      3 = On-Line Transaction Test
+        *              conf                    (not used for Merchant Solutions)
+        *              email                   Merchant E-Mail address to receive notices from Merchant Solutions for the transaction
+        *
+     * Test Merchant Account
+     *                 AcctID:                 MSDMO
+     *                 Userid:                 Cscott
+     *                 Password:               Glm3Merch#Sol
+     *                 MerchantPin:    BVR0V3462V5GmZK03MXtWE5u9HeUJX62
+        *
+     */
+    public function __construct($account)
+    {
+
+       // Setup request object
+       $this->request = (object) array(
+                       'acctid' => false,
+                       'merchantpin' => false,
+                       'amount' => false,
+                       'ccnum' => false,
+                       'expmon' => false,
+                       'expyear' => false,
+                       'ccname' => false,
+                       'cardpresent' => 0,
+                       'cardreaderpresent' => 0,
+                       'cvv2' => false,
+                       'accttype' => 1,
+                       'profileactiontype' => 2,
+                       'manualrecurring' => 0,
+                       'avs_override' => 0,
+                       'cvv2_override' => 0,
+                       'loadbalance_override' => 0,
+                       'duplicate_override' => 0,
+                       'accountlookupflag' => 0,
+                       'billaddress' => (object) array(
+                               'addr1' => '',
+                               'addr2' => '',
+                               'city' => '',
+                               'state' => '',
+                               'zip' => '',
+                               'country' => ''
+                       )
+       );
+
+       $this->account = $account;
+       $this->request->acctid = $account['acctid'];
+       $this->request->merchantpin = $account['merchantpin'];
+
+       // Test to see if soap support has been installed
+       if (!extension_loaded('soap')) {
+           trigger_error('*** PHP SOAP not installed and required by MerchantSolutions payment gateway! ***', E_USER_ERROR);
+       }
+
+        // Setup options related to doing the SOAP calls
+        ini_set('soap.wsdl_cache_enabled', 1);
+        use_soap_error_handler(false);
+        $soapOptions = array(
+            "exceptions" => 1,
+            'connection_timeout' => 10
+        );
+
+        // Setup SOAP client and get WSDL for gateway
+        try {
+
+            // XDebug prevents catching fatal errors with the Soap calls
+            if (function_exists('xdebug_disable')) {
+                xdebug_disable();
+            }
+
+            // Create new soap client instance
+            $this->client = @new SoapClient(MS_WSDL, $soapOptions);
+
+            // If XDebug was dissabled, re-enable it
+            if (function_exists('xdebug_enable')) {
+                xdebug_enable();
+            }
+
+            // Indicate setup OK
+                       return true;
+
+        } catch (SoapFault $exception) {
+
+                       return false;
+        }
+
+        return false;
+    }
+
+    /**
+     * Process a Payment
+     *
+     * @param payment Array payment information
+     * @param contact Array contact information
+     *
+     * @access public
+     * @return array
+     *
+     * Information provided
+     *
+     * $payment array
+     *         name                            Name of Venue
+     *         charge                          Total to be charged
+     *         cctype                          Card type
+     *         ccname                          Name on card
+     *         ccnumb                          Card number
+     *         ccexp                           Expiration date (m/y)
+     *         cccode                          Security code on back of card
+     *         invoice                         Invoice # is session ID (or some part thereof)
+     *
+     * $contact array
+     *         fname                           Customer first name
+     *         lname                           Customer last name
+     *         addr1                           Address Line 1
+     *         addr2                           Address Line 2
+     *         city                            City
+     *         state                           State
+     *         country                         Country
+     *         zip                                     ZIP/Postal code
+     *         phone                           Customer phone number
+     *         email                           Customer E-Mail address
+     *
+     * return array
+     *                 status                          Numeric return status code
+     *                                                                 1               Approved
+     *                                                                 2               Bad data supplied
+     *                                                                 3               Communications failure
+     *                                                                 4               Bad response
+     *                                                                 5               Transaction not valid
+     *                                                                 6               Merchant account problem
+     *                                                                 7               Card declined
+     *         statusText                      Short name of status
+     *         authCode                        Authorization code - blank if card not accepted
+     *         description                     Longer description of result
+     *
+     *
+     */
+    public function processPayment($payment = false, $contact = false)
+    {
+
+       // Set data
+       $this->request->amount = $payment['charge'];
+       $this->request->ccnum = $payment['ccnumb'];
+       $exp = explode('/', $payment['ccexp']);
+       $this->request->expmon = $exp[0];
+       $this->request->expyear = $exp[1];
+       $this->request->ccname = $payment['ccname'];
+       $this->request->cvv2 = $payment['cccode'];
+       $this->request->memo = $payment['name'].' - Event Tickets';
+       $this->request->billaddress->addr1 = $contact['addr1'];
+       $this->request->billaddress->addr2 = $contact['addr2'];
+       $this->request->billaddress->city = $contact['city'];
+       $this->request->billaddress->state = $contact['state'];
+       $this->request->billaddress->zip = $contact['zip'];
+       $this->request->billaddress->addr1 = $contact['country'];
+       $this->request->phone = $contact['phone'];
+       $this->request->email = $contact['email'];
+       $this->request->merchantordernumber = substr($payment['invoice'], -20);
+
+       // Check for local tests that don't require communication with Authorize.net
+       switch ($this->account['test']) {
+
+               // Local Test
+               case 1:
+                       // Always return a card approval
+                       $resp = array(
+                    'gateway' => 'MerchantSolutions',
+                    'status' => 1,
+                    'statusText' => 'Card Approved',
+                    'authCode' => '000000',
+                    'description' => '(TESTMODE) Local Test - Card Approved'
+                       );
+                       return $resp;
+                       break;
+
+               // Fail Test
+               case 2:
+                       $resp = array(
+                    'gateway' => 'MerchantSolutions',
+                    'status' => 7,
+                    'statusText' => 'Card Declined',
+                    'authCode' => '',
+                    'description' => '(TESTMODE) Local Test - Card Declined'
+                       );
+                       return $resp;
+                       break;
+
+               // Online Test
+               case 3:
+                       $this->request->acctid = 'TEST0';
+                       break;
+
+                       // Production Mode
+               case 0:
+                       break;
+       }
+
+
+
+        // Try to process the transaction
+        try {
+
+            // Deal with XDebug if that's enabled
+            if (function_exists('xdebug_disable')) {
+                xdebug_disable();
+            }
+
+            // Send request to Merchant Solutions
+            $this->response = $this->client->processCCSale($this->request);
+
+            // Restore XDebug if that was enabled
+            if (function_exists('xdebug_enable')) {
+                xdebug_enable();
+            }
+
+            // If approved
+            if (strtoupper($this->result) == 'APPROVED') {
+
+               $resp = array(
+                    'gateway' => 'MerchantSolutions',
+                    'status' => 1,
+                    'statusText' => 'Card Approved',
+                    'authCode' => $this->response->authcode,
+                    'description' => $this->response->status
+               );
+               return $resp;
+
+            // Must be declined
+            } else {
+
+               $x = explode(":", $this->response->result);
+                               $resp = array(
+                    'gateway' => 'MerchantSolutions',
+                    'status' => 7,
+                    'statusText' => 'Card Declined',
+                    'authCode' => '',
+                    'description' => $x[2]
+                               );
+                               return $resp;
+
+
+            }
+
+        // If there's a communications failure
+        } catch (SoapFault $exception) {
+
+                       // Return communications failure
+               $resp = array(
+                'gateway' => 'MerchantSolutions',
+                'status' => 3,
+                'statusText' => 'Transaction Error',
+                'authCode' => '',
+                'description' => 'Unable to communicate with credit card processing service.'
+                       );
+               return $resp;
+
+        }
+
+        $resp = array(
+            'gateway' => 'MerchantSolutions',
+            'status' => 4,
+            'statusText' => 'Bad Response',
+            'authCode' => '',
+            'description' => 'Received unknown response from the credit card processing service.'
+        );
+        return $resp;
+
+    }
+
+}
index 1161fca..73a04ad 100755 (executable)
-<?php\r
-/**\r
- * Event Management System\r
- * PayPal Payment PaymentGateway class\r
- *\r
- * @category Front-End\r
- * @package  EventManagement\r
- * @author   Chuck Scott <cscott@gaslightmedia.com>\r
- * @license  http://www.gaslightmedia.com Gaslightmedia\r
- * @release  SVN: $Id: PayPal.php,v 1.0 2011/01/25 19:31:47 cscott Exp $\r
- * @link     <>\r
- */\r
-\r
-\r
-/**\r
- * Account Information\r
- *\r
- *  Developer account\r
- *             PayPal API:     https://developer.paypal.com/webapps/developer/\r
- *             E-Mail Address:         PayPal@n8dnx.org\r
- *             Password:                       pAy#glM2Pal\r
- *\r
- *     PayPal test account\r
- *             E-Mail address: paypalAcct2@n8dnx.org\r
- *             Password:               {std insecure}2\r
- *\r
- *     Test credentials\r
- *             Test account:   PayPal-facilitator@n8dnx.org\r
- *             Endpoint:               api.sandbox.paypal.com\r
- *             Client ID:              AY2IlhCAFCgTaYSgrGfBQ0h5WKKgpLwU-jd2QkKsEbDpGEWtCDZKtp2VLhu1\r
- *             Secret:                 EOWLsBDrkvdOKUlfhAKJ47aXHBr5xzw-2o7JdLCcLVciGqNGXlhMayP1WKhe\r
- *\r
- *     Gaslight Media Live credentials\r
- *             Endpoint:               api.paypal.com\r
- *             Client ID:              AZw7VxC8rVTxlKoZVBd60ugOy_9PZWLDazQHF0RlYYWBQbAvkX2MBLy2vfmQ\r
- *             Secret:                 EN3ZaxB4AhZ3J1814MtpfFjUXOqRTR8dto-fhFgk2wuLDTCoPfD0I0Dpbwuu\r
- *\r
- *     Standard PayPal buttons and images\r
- *             https://ppmts.custhelp.com/app/answers/detail/a_id/632\r
- *                             https://www.paypal.com/en_US/i/btn/x-click-but6.gif\r
- */\r
-\r
-/**\r
- * EventManagementPayPalPaymentProcessing class\r
- *\r
- * PHP version 5\r
- *\r
- * @category Event Management PayPal Payment Processing\r
- * @package  EventManagement\r
- * @author   Chuck Scott <cscott@gaslightmedia.com>\r
- * @license  http://www.gaslightmedia.com Gaslightmedia\r
- * @release  SVN: $Id: PayPal.php,v 1.0 2011/01/25 19:31:47 cscott Exp $\r
- * @link     <>\r
- */\r
-\r
-class PaymentGateway\r
-{\r
-       /**\r
-        * Curl Object\r
-        *\r
-        * @var         $curl\r
-        * @access      private\r
-        */\r
-       private $curl = false;\r
-       /**\r
-        * Result Status\r
-        *\r
-        * @var         $status\r
-        * @access      public\r
-        */\r
-       public $status = false;\r
-       /**\r
-        * Access Data\r
-        *\r
-        * @var         $access\r
-        * @access      private\r
-        */\r
-       public $access = false;\r
-       /**\r
-        * Curl Errors\r
-        *\r
-        * @var         $error\r
-        * @access      public\r
-        */\r
-       public $error = '';\r
-       /**\r
-        * PayPal Transaction\r
-        *\r
-        * @var         $trans\r
-        * @access      public\r
-        */\r
-       public $trans;\r
-       /**\r
-        * Test Mode - Use Sandbox\r
-        *\r
-        * @var         $sandbox\r
-        * @access      public\r
-        */\r
-       public $sandbox = false;\r
-       /**\r
-        * API URLs\r
-        *\r
-        * @var         $apiURLs\r
-        * @access      public\r
-        */\r
-       public $apiURLs = false;\r
-\r
-    /**\r
-     * Constructor\r
-     *\r
-     * To facilitate continuing after a return URL has been followed\r
-     * as required to execute or cancel the transaction, the constructor\r
-     * may optionally take an "access" object created in a previous\r
-     * instance (probably stored in a session or database) to re-establish\r
-     * a connection to the same transaction.\r
-     *\r
-     * @param array  $account Account information\r
-     * @param object $access  Access object from previous instance that should\r
-     *                                                   be used instead of creating a new one\r
-     * @param object $trans   Transaction object from a previous instance.\r
-     *\r
-     * @return boolean    Returns value of $success parameter\r
-     * @access public\r
-     *\r
-     * $account\r
-        *              clientID                PayPal Client ID\r
-        *              secret                  PayPal Secret\r
-        *              returnURL               URL for PayPal to return to after payment confirmation by customer\r
-        *              cancelURL               URL for PayPal to return to after payment cancelation by customer\r
-        *              test                    1=Local Test (not available for PayPal), 2=Fail test (not available for PayPal), 3=PayPal Sandbox test, 0=Live production\r
-        *\r
-     */\r
-    public function __construct($account, $access = false, $trans = false)\r
-    {\r
-\r
-               // URLs to use for requests if we're using the development sandbox\r
-       $sandboxURLs = (object) array(\r
-                       'access' => 'https://api.sandbox.paypal.com/v1/oauth2/token',\r
-                       'process' => 'https://api.sandbox.paypal.com/v1/payments/payment',\r
-                       'execute' => 'https://api.sandbox.paypal.com/v1/payments/payment/{transID}/execute/'\r
-       );\r
-\r
-       // URLs to use for requests if we're doing live transactions\r
-       $liveURLs = (object) array(\r
-                       'access' => 'https://api.paypal.com/v1/oauth2/token',\r
-                       'process' => 'https://api.paypal.com/v1/payments/payment',\r
-                       'execute' => 'https://api.paypal.com/v1/payments/payment/{transID}/execute/'\r
-       );\r
-\r
-\r
-       // Save account information\r
-       $this->account = $account;\r
-\r
-       // Check for various test modes\r
-       switch ($this->account['test']) {\r
-\r
-               // Local Test\r
-               case 1:\r
-                               break;\r
-\r
-                       // Fail Test\r
-               case 2:\r
-                               break;\r
-\r
-               // Online Test - Use sandbox\r
-               case 3:\r
-                       $this->sandbox = true;\r
-                       $this->apiURLs = $sandboxURLs;\r
-                       break;\r
-\r
-                       // Production Mode\r
-               case 0:\r
-                       $this->sandbox = false;\r
-                       $this->apiURLs = $liveURLs;\r
-                       break;\r
-       }\r
-\r
-       // Was an access object from a previous instance supplied?\r
-       if ($access) {\r
-\r
-               // Yes, so store that and be done\r
-               $this->access = $access;\r
-               $this->status = true;\r
-\r
-               // If we also have a transaction object\r
-               if ($trans) {\r
-\r
-                       // Store that\r
-                       $this->trans = $trans;\r
-               }\r
-\r
-               if (defined('PAYPAL_DEBUG') && PAYPAL_DEBUG) {\r
-                       echo\r
-                               '<b>__construct() - Existing Instance</b><p>'\r
-                               .'Account Data:<br>'\r
-                               .'<pre>'.print_r($account,1).'</pre>'\r
-                               .'Access:<br>'\r
-                               .'<pre>'.print_r($access,1)."</pre>"\r
-                               .'Transaction:<br>'\r
-                               .'<pre>'.print_r($trans,1)."</pre>";\r
-               }\r
-\r
-\r
-       // Otherwise, we need to create an access object\r
-       } else {\r
-\r
-               // Build request information\r
-               $url = $this->apiURLs->access;\r
-               $headers = array(\r
-                               "Accept: application/json",\r
-                               "Accept-Language: en_US",\r
-                               "Content-type: application/x-www-form-urlencoded"\r
-               );\r
-               $request = 'grant_type=client_credentials';\r
-\r
-               if (defined('PAYPAL_DEBUG') && PAYPAL_DEBUG) {\r
-                       echo\r
-                               '<b>__construct() - New Instance</b><p>'\r
-                               .'Account Data:<br>'\r
-                               .'<pre>'.print_r($account,1).'</pre>'\r
-                               .'Headers:<br>'\r
-                               .'<pre>'.print_r($headers,1)."</pre>"\r
-                               .'Request:<br>'\r
-                               .'<pre>'.print_r($request,1)."</pre>";\r
-               }\r
-\r
-                       // Send request\r
-               $response = $this->sendRequest($url, $headers, $request);\r
-\r
-               // If bad response\r
-               if (!$response) {\r
-                       $this->access = false;\r
-                       $this->status = false;\r
-                       return;\r
-               }\r
-\r
-               // Store our access data\r
-               $this->access = $response;\r
-               $this->status = true;\r
-\r
-       }\r
-\r
-       return $this->status;\r
-    }\r
-\r
-    /**\r
-     * Process a Payment\r
-     *\r
-     * NOTE: For PayPal, this method only requests the payment.\r
-     * The user must follow the approval_url supplied by this\r
-     * method and confirm the payment. When that is done, PayPal\r
-     * will send the user to the approval_url along with a\r
-     * PayerID. The executePayment() method must then be called\r
-     * to actually execute the payment.\r
-     *\r
-     * @param array $payment Array payment information\r
-     * @param array $contact Array contact information\r
-     *\r
-     * @access public\r
-     * @return array\r
-     *\r
-     * Information provided\r
-     *\r
-     * $payment array\r
-     *         name                            Name of vendor - required\r
-     *         charge                          Total to be charged - required\r
-     *         cctype                          Card type - not used\r
-     *         ccname                          Name on card - not used\r
-     *         ccnumb                          Card number - not used\r
-     *         ccexp                           Expiration date (m/y) - not used\r
-     *         cccode                          Security code on back of card - not used\r
-     *         invoice                         Invoice # is session ID (or some part thereof) - not used\r
-     *         description                     Description of transaction - not used\r
-     *         items                           Array of items being purchased - required\r
-     *                                                 Each item has following\r
-     *\r
-     *                 quantity                        A number - Required\r
-     *                 name                            Name of the item - Required\r
-     *                 price                           Price of the item (numeric float) - Required\r
-     *                 sku                                     SKU string - Optional\r
-     *\r
-     *\r
-     * $contact array\r
-     *         fname                           Customer first name\r
-     *         lname                           Customer last name\r
-     *         addr1                           Address Line 1\r
-     *         addr2                           Address Line 2\r
-     *         city                            City\r
-     *         state                           State\r
-     *         country                         Country\r
-     *         zip                                     ZIP/Postal code\r
-     *         phone                           Customer phone number\r
-     *         email                           Customer E-Mail address\r
-     *\r
-     * return array\r
-     *                 status                          Numeric return status code\r
-     *                                                                 1               Approved\r
-     *                                                                 2               Bad data supplied\r
-     *                                                                 3               Communications failure\r
-     *                                                                 4               Bad response\r
-     *                                                                 5               Transaction not valid\r
-     *                                                                 6               Merchant account problem\r
-     *                                                                 7               Card declined\r
-     *         statusText                      Short name of status\r
-     *         authCode                        Authorization code - blank if card not accepted\r
-     *         description                     Longer description of result\r
-     *\r
-     *\r
-     */\r
-    public function processPayment($payment = false, $contact = false)\r
-    {\r
-\r
-       // Check for local tests that don't require communication with PayPal\r
-       switch ($this->account['test']) {\r
-\r
-               // Local Test\r
-               case 1:\r
-                       // invalid type for PayPal class - default to sandbox\r
-               case 2:\r
-                       // invalid type for PayPal class - default to sandbox\r
-               case 3:\r
-                       $this->sandbox = true;\r
-                       break;\r
-\r
-                       // Production Mode\r
-               case 0:\r
-                       break;\r
-       }\r
-\r
-       // Build request information\r
-       $url = $this->apiURLs->process;\r
-       $headers = array(\r
-                       "Content-type:application/json",\r
-                       'Authorization:'.$this->access->token_type.' '.$this->access->access_token\r
-       );\r
-\r
-       // Build payment request\r
-       $charge =  number_format($payment['charge'], 2, '.', '');\r
-       $requestArray = array(\r
-               'intent' => 'sale',\r
-               'redirect_urls' => array(\r
-                       'return_url' => $this->account['returnURL'],\r
-                       'cancel_url' => $this->account['cancelURL']\r
-               ),\r
-               'payer' => array(\r
-                       'payment_method' => 'paypal'\r
-               ),\r
-               'transactions' => array(\r
-                       0 => array(\r
-                               'amount' => array(\r
-                               'total' => $charge,\r
-                               'currency' => 'USD'\r
-                               ),\r
-                               'item_list' => array(\r
-                                       'items' => array(\r
-                                       )\r
-                               )\r
-                       )\r
-               )\r
-       );\r
-\r
-       // Add item list\r
-       if (isset($payment['items']) && count($payment['items']) > 0) {\r
-\r
-               foreach ($payment['items'] as $item) {\r
-\r
-                       $item['name'] = trim($item['name']);\r
-                       $item['currency'] = 'USD';\r
-                       $item['price'] = number_format($item['price'], 2, '.', '');\r
-\r
-                       // Check required items\r
-                       if (\r
-                               ($item['quantity']-0) <= 0 ||\r
-                               $item['name'] == '' ||\r
-                               ($item['price']-0) <= 0\r
-                       ) {\r
-\r
-                               if (defined('PAYPAL_DEBUG') && PAYPAL_DEBUG) {\r
-                                       echo "<P>ERROR: payment item incomplete<br><pre>".print_r($item,1)."</pre>";\r
-                               }\r
-\r
-                               // Can't proceed, bad data supplied - May need to warn someone of this problem here\r
-                               $this->trans = false;\r
-                               $this->status = false;\r
-                               return;\r
-\r
-                       }\r
-\r
-                       // Add this item to the list\r
-                       $requestArray['transactions'][0]['item_list']['items'][] = $item;\r
-\r
-               }\r
-\r
-       // If not, then we can't proceed - While not required by PayPal, we are requiring it\r
-       } else {\r
-\r
-               echo "ERROR: PayPal integration requires an item list but none was provided along with "\r
-                               ."the payment information to the processPayment() method.";\r
-               exit;\r
-\r
-       }\r
-\r
-       // Convert request to a JSON\r
-       $request = json_encode($requestArray, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);\r
-\r
-       if (defined('PAYPAL_DEBUG') && PAYPAL_DEBUG) {\r
-               echo '<b>processPayment()</b><P>'\r
-                       .'Headers:<br>'\r
-                       .'<pre>'.print_r($headers,1)."</pre>"\r
-                       .'Request: <br>'\r
-                       .'<pre>'.$request.'</pre>';\r
-       }\r
-\r
-       // Send request\r
-       $response = $this->sendRequest($url, $headers, $request);\r
-\r
-       // If bad response\r
-       if (!$response) {\r
-               $this->trans = false;\r
-               $this->status = false;\r
-               return;\r
-       }\r
-\r
-       // Store URLs in a way they can be easily accessed\r
-       $response->urls = new stdClass();\r
-       foreach ($response->links as $link) {\r
-                       $response->urls->{$link->rel} = $link;\r
-       }\r
-\r
-               // Store our access data\r
-       $this->trans = $response;\r
-               $this->status = true;\r
-\r
-\r
-               return $this->status;\r
-\r
-\r
-    }\r
-\r
-    /**\r
-     * Execute the Payment\r
-     *\r
-     * This is the final step in PayPal payment approval.\r
-     * This method should be called with the PayerID provided\r
-     * when the user is sent back to us on a return URL.\r
-     *\r
-     * Note for this to work, the constructor must have been\r
-     * suppled the access and transaction data.\r
-     *\r
-     * Since the transaction ID is passed to PayPal in the URL\r
-     * we're assuming that the response we get back is for the\r
-     * correct transaction, so we don't check that.\r
-     *\r
-     * @param string $payerID  PayerID returned by PayPal on the return link\r
-     *\r
-     * @access public\r
-     * @return array\r
-     *\r
-     *\r
-     */\r
-    public function executePayment($payerID)\r
-    {\r
-\r
-       // Build request information\r
-       $url = str_replace('{transID}', $this->trans->id, $this->apiURLs->execute);\r
-\r
-       $headers = array(\r
-                       "Content-type:application/json",\r
-                       'Authorization:'.$this->access->token_type.' '.$this->access->access_token\r
-       );\r
-\r
-       // Build payment request\r
-       $charge =  number_format($payment['charge'], 2, '.', '');\r
-       $request = '{"payer_id" : "'.$payerID.'" }';\r
-\r
-       if (defined('PAYPAL_DEBUG') && PAYPAL_DEBUG) {\r
-               echo '<b>executePayment()</b><P>'\r
-                       .'Headers:<br>'\r
-                       .'<pre>'.print_r($headers,1)."</pre>"\r
-                       .'Request: <br>'\r
-                       .'<pre>'.$request.'</pre>';\r
-       }\r
-\r
-       // Send request\r
-       $response = $this->sendRequest($url, $headers, $request);\r
-\r
-       // If bad response\r
-       if (!$response) {\r
-               $this->confirmation = false;\r
-               $this->status = false;\r
-               return false;\r
-       }\r
-\r
-       // Save results\r
-       $this->confirmation = $response;\r
-\r
-               // Check if payment not approved\r
-               if ($response->state != 'approved') {\r
-                       $this->status = false;\r
-                       return false;\r
-               }\r
-\r
-               $r = array(\r
-                       'status' => 1,\r
-                       'statusText' => 'Approved',\r
-                       'authCode' => '',\r
-                       'description' => 'PayPal approval: '\r
-                               .$this->response->payer->payer_info->first_name.' '\r
-                               .$this->response->payer->payer_info->last_name.' '\r
-                               .$this->response->update_time,\r
-                       'payerName' => $this->response->payer->payer_info->first_name.' '\r
-                               .$this->response->payer->payer_info->last_name.' '\r
-\r
-               );\r
-\r
-       return $r;\r
-    }\r
-\r
-    /**\r
-     * Make Curl call to place request\r
-     *\r
-     * @param array $headers  Array of headers to include\r
-     * @param mixed $request  Fields to supply as POST data, either string, array, or json\r
-     *\r
-     * @access public\r
-     * @return array\r
-     *\r
-     */\r
-    private function sendRequest($url, $headers, $request)\r
-    {\r
-\r
-       if (defined('PAYPAL_DEBUG') && PAYPAL_DEBUG) {\r
-               echo '<p><b>sendRequest():</b><br>URL = '.$url.'<br>Headers:<br><pre>'\r
-                       .print_r($headers,1).'</pre>Request:<br><pre>'.print_r($request,1).'</pre>';\r
-       }\r
-\r
-       // Init Curl\r
-       $this->curl = curl_init();\r
-\r
-       // Curl Parameters\r
-       $id_pw = $this->account['clientID'].':'.$this->account['secret'];\r
-       $agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";\r
-\r
-       // Set curl options\r
-       curl_setopt($this->curl, CURLOPT_URL, $url);\r
-       curl_setopt($this->curl, CURLOPT_SSLVERSION,4);\r
-       curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, FALSE);\r
-       curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, 2);\r
-       curl_setopt($this->curl, CURLOPT_HEADER, false);\r
-       curl_setopt($this->curl, CURLOPT_HTTPHEADER, $headers);\r
-       curl_setopt($this->curl, CURLOPT_POST, true);\r
-       curl_setopt($this->curl, CURLOPT_POSTFIELDS, $request);\r
-       curl_setopt($this->curl, CURLOPT_USERPWD, $id_pw);\r
-       curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);\r
-       curl_setopt($this->curl, CURLOPT_USERAGENT, $agent);\r
-\r
-       // Place Curl call to get access token\r
-       $raw = curl_exec($this->curl);\r
-\r
-       // If we received a good response\r
-       if (!curl_errno($this->curl)) {\r
-\r
-               // Save access data\r
-               $response = json_decode($raw);\r
-\r
-               if (defined('PAYPAL_DEBUG') && PAYPAL_DEBUG) {\r
-                       echo 'Response:<br>'\r
-                               .'<pre>'.print_r($response,1).'</pre>';\r
-               }\r
-\r
-       // Otherwise\r
-       } else {\r
-\r
-               // Save our error message\r
-               $this->error = curl_error($this->curl);\r
-                       $response = false;\r
-\r
-                       if (defined('PAYPAL_DEBUG') && PAYPAL_DEBUG) {\r
-                               echo "Curl Error: ".$this->error."<P>";\r
-                       }\r
-\r
-       }\r
-\r
-       // Close our curl object\r
-       curl_close($this->curl);\r
-\r
-       return $response;\r
-\r
-    }\r
-\r
-}\r
+<?php
+/**
+ * Event Management System
+ * PayPal Payment PaymentGateway class
+ *
+ * @category Front-End
+ * @package  EventManagement
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: PayPal.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ * @link     <>
+ */
+
+
+/**
+ * Account Information
+ *
+ *  Developer account
+ *             PayPal API:     https://developer.paypal.com/webapps/developer/
+ *             E-Mail Address:         PayPal@n8dnx.org
+ *             Password:                       pAy#glM2Pal
+ *
+ *     PayPal test account
+ *             E-Mail address: paypalAcct2@n8dnx.org
+ *             Password:               {std insecure}2
+ *
+ *     Test credentials
+ *             Test account:   PayPal-facilitator@n8dnx.org
+ *             Endpoint:               api.sandbox.paypal.com
+ *             Client ID:              AY2IlhCAFCgTaYSgrGfBQ0h5WKKgpLwU-jd2QkKsEbDpGEWtCDZKtp2VLhu1
+ *             Secret:                 EOWLsBDrkvdOKUlfhAKJ47aXHBr5xzw-2o7JdLCcLVciGqNGXlhMayP1WKhe
+ *
+ *     Gaslight Media Live credentials
+ *             Endpoint:               api.paypal.com
+ *             Client ID:              AZw7VxC8rVTxlKoZVBd60ugOy_9PZWLDazQHF0RlYYWBQbAvkX2MBLy2vfmQ
+ *             Secret:                 EN3ZaxB4AhZ3J1814MtpfFjUXOqRTR8dto-fhFgk2wuLDTCoPfD0I0Dpbwuu
+ *
+ *     Standard PayPal buttons and images
+ *             https://ppmts.custhelp.com/app/answers/detail/a_id/632
+ *                             https://www.paypal.com/en_US/i/btn/x-click-but6.gif
+ */
+
+/**
+ * EventManagementPayPalPaymentProcessing class
+ *
+ * PHP version 5
+ *
+ * @category Event Management PayPal Payment Processing
+ * @package  EventManagement
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: PayPal.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ * @link     <>
+ */
+
+class PaymentGateway
+{
+       /**
+        * Curl Object
+        *
+        * @var         $curl
+        * @access      private
+        */
+       private $curl = false;
+       /**
+        * Result Status
+        *
+        * @var         $status
+        * @access      public
+        */
+       public $status = false;
+       /**
+        * Access Data
+        *
+        * @var         $access
+        * @access      private
+        */
+       public $access = false;
+       /**
+        * Curl Errors
+        *
+        * @var         $error
+        * @access      public
+        */
+       public $error = '';
+       /**
+        * PayPal Transaction
+        *
+        * @var         $trans
+        * @access      public
+        */
+       public $trans;
+       /**
+        * Test Mode - Use Sandbox
+        *
+        * @var         $sandbox
+        * @access      public
+        */
+       public $sandbox = false;
+       /**
+        * API URLs
+        *
+        * @var         $apiURLs
+        * @access      public
+        */
+       public $apiURLs = false;
+
+    /**
+     * Constructor
+     *
+     * To facilitate continuing after a return URL has been followed
+     * as required to execute or cancel the transaction, the constructor
+     * may optionally take an "access" object created in a previous
+     * instance (probably stored in a session or database) to re-establish
+     * a connection to the same transaction.
+     *
+     * @param array  $account Account information
+     * @param object $access  Access object from previous instance that should
+     *                                                   be used instead of creating a new one
+     * @param object $trans   Transaction object from a previous instance.
+     *
+     * @return boolean    Returns value of $success parameter
+     * @access public
+     *
+     * $account
+        *              clientID                PayPal Client ID
+        *              secret                  PayPal Secret
+        *              returnURL               URL for PayPal to return to after payment confirmation by customer
+        *              cancelURL               URL for PayPal to return to after payment cancelation by customer
+        *              test                    1=Local Test (not available for PayPal), 2=Fail test (not available for PayPal), 3=PayPal Sandbox test, 0=Live production
+        *
+     */
+    public function __construct($account, $access = false, $trans = false)
+    {
+
+               // URLs to use for requests if we're using the development sandbox
+       $sandboxURLs = (object) array(
+                       'access' => 'https://api.sandbox.paypal.com/v1/oauth2/token',
+                       'process' => 'https://api.sandbox.paypal.com/v1/payments/payment',
+                       'execute' => 'https://api.sandbox.paypal.com/v1/payments/payment/{transID}/execute/'
+       );
+
+       // URLs to use for requests if we're doing live transactions
+       $liveURLs = (object) array(
+                       'access' => 'https://api.paypal.com/v1/oauth2/token',
+                       'process' => 'https://api.paypal.com/v1/payments/payment',
+                       'execute' => 'https://api.paypal.com/v1/payments/payment/{transID}/execute/'
+       );
+
+
+       // Save account information
+       $this->account = $account;
+
+       // Check for various test modes
+       switch ($this->account['test']) {
+
+               // Local Test
+               case 1:
+                               break;
+
+                       // Fail Test
+               case 2:
+                               break;
+
+               // Online Test - Use sandbox
+               case 3:
+                       $this->sandbox = true;
+                       $this->apiURLs = $sandboxURLs;
+                       break;
+
+                       // Production Mode
+               case 0:
+                       $this->sandbox = false;
+                       $this->apiURLs = $liveURLs;
+                       break;
+       }
+
+       // Was an access object from a previous instance supplied?
+       if ($access) {
+
+               // Yes, so store that and be done
+               $this->access = $access;
+               $this->status = true;
+
+               // If we also have a transaction object
+               if ($trans) {
+
+                       // Store that
+                       $this->trans = $trans;
+               }
+
+               if (defined('PAYPAL_DEBUG') && PAYPAL_DEBUG) {
+                       echo
+                               '<b>__construct() - Existing Instance</b><p>'
+                               .'Account Data:<br>'
+                               .'<pre>'.print_r($account,1).'</pre>'
+                               .'Access:<br>'
+                               .'<pre>'.print_r($access,1)."</pre>"
+                               .'Transaction:<br>'
+                               .'<pre>'.print_r($trans,1)."</pre>";
+               }
+
+
+       // Otherwise, we need to create an access object
+       } else {
+
+               // Build request information
+               $url = $this->apiURLs->access;
+               $headers = array(
+                               "Accept: application/json",
+                               "Accept-Language: en_US",
+                               "Content-type: application/x-www-form-urlencoded"
+               );
+               $request = 'grant_type=client_credentials';
+
+               if (defined('PAYPAL_DEBUG') && PAYPAL_DEBUG) {
+                       echo
+                               '<b>__construct() - New Instance</b><p>'
+                               .'Account Data:<br>'
+                               .'<pre>'.print_r($account,1).'</pre>'
+                               .'Headers:<br>'
+                               .'<pre>'.print_r($headers,1)."</pre>"
+                               .'Request:<br>'
+                               .'<pre>'.print_r($request,1)."</pre>";
+               }
+
+                       // Send request
+               $response = $this->sendRequest($url, $headers, $request);
+
+               // If bad response
+               if (!$response) {
+                       $this->access = false;
+                       $this->status = false;
+                       return;
+               }
+
+               // Store our access data
+               $this->access = $response;
+               $this->status = true;
+
+       }
+
+       return $this->status;
+    }
+
+    /**
+     * Process a Payment
+     *
+     * NOTE: For PayPal, this method only requests the payment.
+     * The user must follow the approval_url supplied by this
+     * method and confirm the payment. When that is done, PayPal
+     * will send the user to the approval_url along with a
+     * PayerID. The executePayment() method must then be called
+     * to actually execute the payment.
+     *
+     * @param array $payment Array payment information
+     * @param array $contact Array contact information
+     *
+     * @access public
+     * @return array
+     *
+     * Information provided
+     *
+     * $payment array
+     *         name                            Name of vendor - required
+     *         charge                          Total to be charged - required
+     *         cctype                          Card type - not used
+     *         ccname                          Name on card - not used
+     *         ccnumb                          Card number - not used
+     *         ccexp                           Expiration date (m/y) - not used
+     *         cccode                          Security code on back of card - not used
+     *         invoice                         Invoice # is session ID (or some part thereof) - not used
+     *         description                     Description of transaction - not used
+     *         items                           Array of items being purchased - required
+     *                                                 Each item has following
+     *
+     *                 quantity                        A number - Required
+     *                 name                            Name of the item - Required
+     *                 price                           Price of the item (numeric float) - Required
+     *                 sku                                     SKU string - Optional
+     *
+     *
+     * $contact array
+     *         fname                           Customer first name
+     *         lname                           Customer last name
+     *         addr1                           Address Line 1
+     *         addr2                           Address Line 2
+     *         city                            City
+     *         state                           State
+     *         country                         Country
+     *         zip                                     ZIP/Postal code
+     *         phone                           Customer phone number
+     *         email                           Customer E-Mail address
+     *
+     * return array
+     *                 status                          Numeric return status code
+     *                                                                 1               Approved
+     *                                                                 2               Bad data supplied
+     *                                                                 3               Communications failure
+     *                                                                 4               Bad response
+     *                                                                 5               Transaction not valid
+     *                                                                 6               Merchant account problem
+     *                                                                 7               Card declined
+     *         statusText                      Short name of status
+     *         authCode                        Authorization code - blank if card not accepted
+     *         description                     Longer description of result
+     *
+     *
+     */
+    public function processPayment($payment = false, $contact = false)
+    {
+
+       // Check for local tests that don't require communication with PayPal
+       switch ($this->account['test']) {
+
+               // Local Test
+               case 1:
+                       // invalid type for PayPal class - default to sandbox
+               case 2:
+                       // invalid type for PayPal class - default to sandbox
+               case 3:
+                       $this->sandbox = true;
+                       break;
+
+                       // Production Mode
+               case 0:
+                       break;
+       }
+
+       // Build request information
+       $url = $this->apiURLs->process;
+       $headers = array(
+                       "Content-type:application/json",
+                       'Authorization:'.$this->access->token_type.' '.$this->access->access_token
+       );
+
+       // Build payment request
+       $charge =  number_format($payment['charge'], 2, '.', '');
+       $requestArray = array(
+               'intent' => 'sale',
+               'redirect_urls' => array(
+                       'return_url' => $this->account['returnURL'],
+                       'cancel_url' => $this->account['cancelURL']
+               ),
+               'payer' => array(
+                       'payment_method' => 'paypal'
+               ),
+               'transactions' => array(
+                       0 => array(
+                               'amount' => array(
+                               'total' => $charge,
+                               'currency' => 'USD'
+                               ),
+                               'item_list' => array(
+                                       'items' => array(
+                                       )
+                               )
+                       )
+               )
+       );
+
+       // Add item list
+       if (isset($payment['items']) && count($payment['items']) > 0) {
+
+               foreach ($payment['items'] as $item) {
+
+                       $item['name'] = trim($item['name']);
+                       $item['currency'] = 'USD';
+                       $item['price'] = number_format($item['price'], 2, '.', '');
+
+                       // Check required items
+                       if (
+                               ($item['quantity']-0) <= 0 ||
+                               $item['name'] == '' ||
+                               ($item['price']-0) <= 0
+                       ) {
+
+                               if (defined('PAYPAL_DEBUG') && PAYPAL_DEBUG) {
+                                       echo "<P>ERROR: payment item incomplete<br><pre>".print_r($item,1)."</pre>";
+                               }
+
+                               // Can't proceed, bad data supplied - May need to warn someone of this problem here
+                               $this->trans = false;
+                               $this->status = false;
+                               return;
+
+                       }
+
+                       // Add this item to the list
+                       $requestArray['transactions'][0]['item_list']['items'][] = $item;
+
+               }
+
+       // If not, then we can't proceed - While not required by PayPal, we are requiring it
+       } else {
+
+               echo "ERROR: PayPal integration requires an item list but none was provided along with "
+                               ."the payment information to the processPayment() method.";
+               exit;
+
+       }
+
+       // Convert request to a JSON
+       $request = json_encode($requestArray, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
+
+       if (defined('PAYPAL_DEBUG') && PAYPAL_DEBUG) {
+               echo '<b>processPayment()</b><P>'
+                       .'Headers:<br>'
+                       .'<pre>'.print_r($headers,1)."</pre>"
+                       .'Request: <br>'
+                       .'<pre>'.$request.'</pre>';
+       }
+
+       // Send request
+       $response = $this->sendRequest($url, $headers, $request);
+
+       // If bad response
+       if (!$response) {
+               $this->trans = false;
+               $this->status = false;
+               return;
+       }
+
+       // Store URLs in a way they can be easily accessed
+       $response->urls = new stdClass();
+       foreach ($response->links as $link) {
+                       $response->urls->{$link->rel} = $link;
+       }
+
+               // Store our access data
+       $this->trans = $response;
+               $this->status = true;
+
+
+               return $this->status;
+
+
+    }
+
+    /**
+     * Execute the Payment
+     *
+     * This is the final step in PayPal payment approval.
+     * This method should be called with the PayerID provided
+     * when the user is sent back to us on a return URL.
+     *
+     * Note for this to work, the constructor must have been
+     * suppled the access and transaction data.
+     *
+     * Since the transaction ID is passed to PayPal in the URL
+     * we're assuming that the response we get back is for the
+     * correct transaction, so we don't check that.
+     *
+     * @param string $payerID  PayerID returned by PayPal on the return link
+     *
+     * @access public
+     * @return array
+     *
+     *
+     */
+    public function executePayment($payerID)
+    {
+
+       // Build request information
+       $url = str_replace('{transID}', $this->trans->id, $this->apiURLs->execute);
+
+       $headers = array(
+                       "Content-type:application/json",
+                       'Authorization:'.$this->access->token_type.' '.$this->access->access_token
+       );
+
+       // Build payment request
+       $charge =  number_format($payment['charge'], 2, '.', '');
+       $request = '{"payer_id" : "'.$payerID.'" }';
+
+       if (defined('PAYPAL_DEBUG') && PAYPAL_DEBUG) {
+               echo '<b>executePayment()</b><P>'
+                       .'Headers:<br>'
+                       .'<pre>'.print_r($headers,1)."</pre>"
+                       .'Request: <br>'
+                       .'<pre>'.$request.'</pre>';
+       }
+
+       // Send request
+       $response = $this->sendRequest($url, $headers, $request);
+
+       // If bad response
+       if (!$response) {
+               $this->confirmation = false;
+               $this->status = false;
+               return false;
+       }
+
+       // Save results
+       $this->confirmation = $response;
+
+               // Check if payment not approved
+               if ($response->state != 'approved') {
+                       $this->status = false;
+                       return false;
+               }
+
+               $r = array(
+                       'status' => 1,
+                       'statusText' => 'Approved',
+                       'authCode' => '',
+                       'description' => 'PayPal approval: '
+                               .$this->response->payer->payer_info->first_name.' '
+                               .$this->response->payer->payer_info->last_name.' '
+                               .$this->response->update_time,
+                       'payerName' => $this->response->payer->payer_info->first_name.' '
+                               .$this->response->payer->payer_info->last_name.' '
+
+               );
+
+       return $r;
+    }
+
+    /**
+     * Make Curl call to place request
+     *
+     * @param array $headers  Array of headers to include
+     * @param mixed $request  Fields to supply as POST data, either string, array, or json
+     *
+     * @access public
+     * @return array
+     *
+     */
+    private function sendRequest($url, $headers, $request)
+    {
+
+       if (defined('PAYPAL_DEBUG') && PAYPAL_DEBUG) {
+               echo '<p><b>sendRequest():</b><br>URL = '.$url.'<br>Headers:<br><pre>'
+                       .print_r($headers,1).'</pre>Request:<br><pre>'.print_r($request,1).'</pre>';
+       }
+
+       // Init Curl
+       $this->curl = curl_init();
+
+       // Curl Parameters
+       $id_pw = $this->account['clientID'].':'.$this->account['secret'];
+       $agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
+
+       // Set curl options
+       curl_setopt($this->curl, CURLOPT_URL, $url);
+       curl_setopt($this->curl, CURLOPT_SSLVERSION,4);
+       curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, FALSE);
+       curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, 2);
+       curl_setopt($this->curl, CURLOPT_HEADER, false);
+       curl_setopt($this->curl, CURLOPT_HTTPHEADER, $headers);
+       curl_setopt($this->curl, CURLOPT_POST, true);
+       curl_setopt($this->curl, CURLOPT_POSTFIELDS, $request);
+       curl_setopt($this->curl, CURLOPT_USERPWD, $id_pw);
+       curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
+       curl_setopt($this->curl, CURLOPT_USERAGENT, $agent);
+
+       // Place Curl call to get access token
+       $raw = curl_exec($this->curl);
+
+       // If we received a good response
+       if (!curl_errno($this->curl)) {
+
+               // Save access data
+               $response = json_decode($raw);
+
+               if (defined('PAYPAL_DEBUG') && PAYPAL_DEBUG) {
+                       echo 'Response:<br>'
+                               .'<pre>'.print_r($response,1).'</pre>';
+               }
+
+       // Otherwise
+       } else {
+
+               // Save our error message
+               $this->error = curl_error($this->curl);
+                       $response = false;
+
+                       if (defined('PAYPAL_DEBUG') && PAYPAL_DEBUG) {
+                               echo "Curl Error: ".$this->error."<P>";
+                       }
+
+       }
+
+       // Close our curl object
+       curl_close($this->curl);
+
+       return $response;
+
+    }
+
+}
index 6ee2f98..dc78ca5 100755 (executable)
-<?php\r
-\r
-define('PAYPAL_DEBUG', true);\r
-\r
-// Setup some info that will be provided by the cart application\r
-$thisScript = 'http://'.$_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'];\r
-$account = array(\r
-               'clientID' => 'AY2IlhCAFCgTaYSgrGfBQ0h5WKKgpLwU-jd2QkKsEbDpGEWtCDZKtp2VLhu1',\r
-               'secret' => 'EOWLsBDrkvdOKUlfhAKJ47aXHBr5xzw-2o7JdLCcLVciGqNGXlhMayP1WKhe',\r
-               'returnURL' => $thisScript.'?PayPalAction=Approved',\r
-               'cancelURL' => $thisScript.'?PayPalAction=Canceled',\r
-               'test' => 3\r
-);\r
-$payment = array(\r
-               'name' => 'Gaslight Media',\r
-               'charge' =>  22.4,\r
-               'invoice' => '123abc',\r
-               'description' => 'Event Tickets Purchase',\r
-               'items' => array(\r
-                               array(\r
-                                               'quantity' => '2',\r
-                                               'name' => 'Fancy Dancy Dance',\r
-                                               'price' => 5.6,\r
-                                               'sku' => '123ABC1'\r
-                               ),\r
-                               array(\r
-                                               'quantity' => '1',\r
-                                               'name' => 'TuTu Tango',\r
-                                               'price' => 11.2,\r
-                                               'sku' => '123ABC2'\r
-                               )\r
-               )\r
-);\r
-$contact = array();\r
-\r
-// Load the PayPal class file\r
-require_once dirname(__FILE__).'/PayPal.php';\r
-\r
-// Start session\r
-session_start();\r
-\r
-\r
-// Check for certain actions related to sending user to PayPal site for approval\r
-switch ($_REQUEST['PayPalAction']) {\r
-\r
-       case 'GetApproval':\r
-\r
-               // Use browser redirect 302 to send user to PayPal.\r
-               // This is proper way to do so according to the API documentation.\r
-               $trans = $_SESSION['trans'];\r
-               header('Location: '.$trans->urls->approval_url->href);\r
-               exit;\r
-\r
-               break;\r
-\r
-       case 'Approved':\r
-\r
-               echo "Return link followed.<P>";\r
-\r
-               // Save Payer ID\r
-               $_SESSION['payerID'] = $_REQUEST['PayerID']; // NEED TO FILTER THIS FOR PRODUCTION\r
-\r
-               // Create PayPal object with existing access object from the session\r
-               $PayPal = new PaymentGateway($account, $_SESSION['access'], $_SESSION['trans']);\r
-\r
-               // Execute the PayPal payment\r
-               $r = $PayPal->executePayment($_SESSION['payerID']);\r
-\r
-               echo "Payment Executed Successfully<P>";\r
-\r
-               exit;\r
-\r
-               break;\r
-\r
-       case 'Canceled':\r
-\r
-               echo "Payment Cancelled<P>";\r
-               exit;\r
-\r
-               break;\r
-}\r
-\r
-// Create the PayPal object (note no previous access object)\r
-$PayPal = new PaymentGateway($account, false, false);\r
-\r
-// Was there an error?\r
-if (!$PayPal->status) {\r
-       echo "Received an error: ".$PayPal->error;\r
-       exit;\r
-}\r
-\r
-// Store access information\r
-$_SESSION['access'] = $PayPal->access;\r
-\r
-// Try to enter Payment\r
-$PayPal->processPayment($payment, $contact);\r
-\r
-// Was there an error?\r
-if (!$PayPal->status) {\r
-       echo "Received an error: ".$PayPal->error;\r
-       exit;\r
-}\r
-\r
-// Store Transaction data to session\r
-$_SESSION['trans'] = $PayPal->trans;\r
-\r
-// Show user link to PayPal for them to approve payment\r
-// Note that uses a target to create a new window/tab\r
-echo '<a href="'.$this_script.'?PayPalAction=GetApproval" target="PayPal">Proceed to PayPal</a>';\r
-\r
+<?php
+
+define('PAYPAL_DEBUG', true);
+
+// Setup some info that will be provided by the cart application
+$thisScript = 'http://'.$_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'];
+$account = array(
+               'clientID' => 'AY2IlhCAFCgTaYSgrGfBQ0h5WKKgpLwU-jd2QkKsEbDpGEWtCDZKtp2VLhu1',
+               'secret' => 'EOWLsBDrkvdOKUlfhAKJ47aXHBr5xzw-2o7JdLCcLVciGqNGXlhMayP1WKhe',
+               'returnURL' => $thisScript.'?PayPalAction=Approved',
+               'cancelURL' => $thisScript.'?PayPalAction=Canceled',
+               'test' => 3
+);
+$payment = array(
+               'name' => 'Gaslight Media',
+               'charge' =>  22.4,
+               'invoice' => '123abc',
+               'description' => 'Event Tickets Purchase',
+               'items' => array(
+                               array(
+                                               'quantity' => '2',
+                                               'name' => 'Fancy Dancy Dance',
+                                               'price' => 5.6,
+                                               'sku' => '123ABC1'
+                               ),
+                               array(
+                                               'quantity' => '1',
+                                               'name' => 'TuTu Tango',
+                                               'price' => 11.2,
+                                               'sku' => '123ABC2'
+                               )
+               )
+);
+$contact = array();
+
+// Load the PayPal class file
+require_once dirname(__FILE__).'/PayPal.php';
+
+// Start session
+session_start();
+
+
+// Check for certain actions related to sending user to PayPal site for approval
+switch ($_REQUEST['PayPalAction']) {
+
+       case 'GetApproval':
+
+               // Use browser redirect 302 to send user to PayPal.
+               // This is proper way to do so according to the API documentation.
+               $trans = $_SESSION['trans'];
+               header('Location: '.$trans->urls->approval_url->href);
+               exit;
+
+               break;
+
+       case 'Approved':
+
+               echo "Return link followed.<P>";
+
+               // Save Payer ID
+               $_SESSION['payerID'] = $_REQUEST['PayerID']; // NEED TO FILTER THIS FOR PRODUCTION
+
+               // Create PayPal object with existing access object from the session
+               $PayPal = new PaymentGateway($account, $_SESSION['access'], $_SESSION['trans']);
+
+               // Execute the PayPal payment
+               $r = $PayPal->executePayment($_SESSION['payerID']);
+
+               echo "Payment Executed Successfully<P>";
+
+               exit;
+
+               break;
+
+       case 'Canceled':
+
+               echo "Payment Cancelled<P>";
+               exit;
+
+               break;
+}
+
+// Create the PayPal object (note no previous access object)
+$PayPal = new PaymentGateway($account, false, false);
+
+// Was there an error?
+if (!$PayPal->status) {
+       echo "Received an error: ".$PayPal->error;
+       exit;
+}
+
+// Store access information
+$_SESSION['access'] = $PayPal->access;
+
+// Try to enter Payment
+$PayPal->processPayment($payment, $contact);
+
+// Was there an error?
+if (!$PayPal->status) {
+       echo "Received an error: ".$PayPal->error;
+       exit;
+}
+
+// Store Transaction data to session
+$_SESSION['trans'] = $PayPal->trans;
+
+// Show user link to PayPal for them to approve payment
+// Note that uses a target to create a new window/tab
+echo '<a href="'.$this_script.'?PayPalAction=GetApproval" target="PayPal">Proceed to PayPal</a>';
+
 ?>
\ No newline at end of file
index 9098c5f..af02d0c 100644 (file)
-<?php\r
-/**\r
- * Event Management System\r
- * Test Payment Processing class\r
- *\r
- * @category Front-End\r
- * @package  EventManagement\r
- * @author   Chuck Scott <cscott@gaslightmedia.com>\r
- * @license  http://www.gaslightmedia.com Gaslightmedia\r
- * @release  SVN: $Id: classes/paymentProcessors/test.php,v 1.0 2011/01/25 19:31:47 cscott Exp $\r
- * @link     <>\r
- */\r
-\r
-/**\r
- * EventManagementAuthorizeNetPaymentProcessing class\r
- *\r
- * PHP version 5\r
- *\r
- * @category Event Management Admin Tickets\r
- * @package  EventManagement\r
- * @author   Chuck Scott <cscott@gaslightmedia.com>\r
- * @license  http://www.gaslightmedia.com Gaslightmedia\r
- * @release  SVN: $Id: classes/paymentProcessors/test.php,v 1.0 2011/01/25 19:31:47 cscott Exp $\r
- * @link     <>\r
- */\r
-\r
-/**\r
- * Test Payment Gateway class\r
- *\r
- * PHP version 5\r
- */\r
-\r
-class PaymentGateway\r
-{\r
-\r
-    /**\r
-     * Constructor\r
-     *\r
-     * @param $account Array of account information - Not used for Test Processor\r
-     *\r
-     * @return boolean    Returns value of $success parameter\r
-     * @access public\r
-     */\r
-    function __construct($account = false)\r
-    {\r
-\r
-       // Nothing to do here for the test processor\r
-        return true;\r
-\r
-    }\r
-\r
-    /*\r
-     * Process Credit Card Payment\r
-     *\r
-     * @param array    $pmt Payment information\r
-     *\r
-     * array(\r
-     *                 'gateway' => {selected payment gateway},\r
-     *                 'name' => {name of venue}\r
-     *                 'charge' => {amount to charge card}\r
-     *                 'cctype' => {type of card - text}\r
-     *                 'ccnumb' => {card number - digits only}\r
-     *                 'ccexp' => {expiration date as m/Y}\r
-     *                 'ccode' => {security code on back of card}\r
-     * )\r
-     *\r
-     * @param array $contact Billing contact information (not used in this class)\r
-     *\r
-     * This Test Processor looks at the last digit of the card number\r
-     * and synthesizes a corresponding response.\r
-     *\r
-        *      1       Card Approved\r
-        *      2       Bad Data Supplied\r
-        *      3       Communications Failure\r
-        *  4   Bad response or no response from processor\r
-        *  5   Transaction validation not accepted\r
-        *  6   Merchant authentication failure or bad account\r
-        *  7   Card Declined\r
-     *\r
-     * @return array    Returns array of results\r
-     */\r
-    function processPayment($pmt, $contact = false)\r
-    {\r
-\r
-       // Get last digit of card number that indicates desired response\r
-       $respCode = substr($pmt['ccnumb'], 15, 1);\r
-\r
-       // Approved flag\r
-       $approved = false;\r
-\r
-       // Prepare synthesized response\r
-       switch ($respCode) {\r
-\r
-               case 1:\r
-\r
-                       $resp = array(\r
-                           'gateway' => 'Card # Tests',\r
-                               'status' => 1,\r
-                               'statusText' => 'Card Approved',\r
-                               'authCode' => '00110011',\r
-                               'description' => 'Card Approved'\r
-                       );\r
-                       break;\r
-\r
-               case 2:\r
-\r
-                       $resp = array(\r
-                           'gateway' => 'Card # Tests',\r
-                           'status' => 2,\r
-                    'statusText' => 'Bad data supplied',\r
-                               'authCode' => '',\r
-                               'description' => 'Card number was not recognizable'\r
-                       );\r
-                       break;\r
-\r
-               case 3:\r
-\r
-                       $resp = array(\r
-                    'gateway' => 'Card # Tests',\r
-                    'status' => 3,\r
-                    'statusText' => 'Communications failure',\r
-                    'authCode' => '',\r
-                    'description' => 'We were unable to communicate with the credit card processing service.'\r
-                       );\r
-                       break;\r
-\r
-               case 4:\r
-\r
-                       $resp = array(\r
-                    'gateway' => 'Card # Tests',\r
-                    'status' => 4,\r
-                    'statusText' => 'Bad Response',\r
-                    'authCode' => '',\r
-                    'description' => 'We received an unrecognizable response from the credit card processing service.'\r
-                       );\r
-                       break;\r
-\r
-               case 5:\r
-\r
-                       $resp = array(\r
-                    'gateway' => 'Card # Tests',\r
-                    'status' => 5,\r
-                    'statusText' => 'Transaction not valid',\r
-                    'authCode' => '',\r
-                    'description' => 'We were unable to validate the response from the credit card processor.'\r
-                       );\r
-                       break;\r
-\r
-               case 6:\r
-\r
-                       $resp = array(\r
-                    'gateway' => 'Card # Tests',\r
-                    'status' => 6,\r
-                    'statusText' => 'Merchant account problem',\r
-                    'authCode' => '00110011',\r
-                    'description' => 'The merchant account for this venue was not recognized by the credit card processor.'\r
-                       );\r
-                       break;\r
-\r
-               case 7:\r
-\r
-                       $resp = array(\r
-                    'gateway' => 'Card # Tests',\r
-                    'status' => 7,\r
-                    'statusText' => 'Card Declined',\r
-                    'authCode' => '',\r
-                    'description' => 'Your credit card purchase was declined.'\r
-                       );\r
-                       break;\r
-\r
-               default:        // Consider any other last digit as approved\r
-\r
-                       $resp = array(\r
-                    'gateway' => 'Card # Tests',\r
-                    'status' => 1,\r
-                    'statusText' => 'Card Approved',\r
-                    'authCode' => '00110011',\r
-                    'description' => 'Card Approved'\r
-                       );\r
-                       break;\r
-\r
-       }\r
-\r
-       return $resp;\r
-    }\r
-\r
-}\r
-\r
-\r
+<?php
+/**
+ * Event Management System
+ * Test Payment Processing class
+ *
+ * @category Front-End
+ * @package  EventManagement
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: classes/paymentProcessors/test.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ * @link     <>
+ */
+
+/**
+ * EventManagementAuthorizeNetPaymentProcessing class
+ *
+ * PHP version 5
+ *
+ * @category Event Management Admin Tickets
+ * @package  EventManagement
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: classes/paymentProcessors/test.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ * @link     <>
+ */
+
+/**
+ * Test Payment Gateway class
+ *
+ * PHP version 5
+ */
+
+class PaymentGateway
+{
+
+    /**
+     * Constructor
+     *
+     * @param $account Array of account information - Not used for Test Processor
+     *
+     * @return boolean    Returns value of $success parameter
+     * @access public
+     */
+    function __construct($account = false)
+    {
+
+       // Nothing to do here for the test processor
+        return true;
+
+    }
+
+    /*
+     * Process Credit Card Payment
+     *
+     * @param array    $pmt Payment information
+     *
+     * array(
+     *                 'gateway' => {selected payment gateway},
+     *                 'name' => {name of venue}
+     *                 'charge' => {amount to charge card}
+     *                 'cctype' => {type of card - text}
+     *                 'ccnumb' => {card number - digits only}
+     *                 'ccexp' => {expiration date as m/Y}
+     *                 'ccode' => {security code on back of card}
+     * )
+     *
+     * @param array $contact Billing contact information (not used in this class)
+     *
+     * This Test Processor looks at the last digit of the card number
+     * and synthesizes a corresponding response.
+     *
+        *      1       Card Approved
+        *      2       Bad Data Supplied
+        *      3       Communications Failure
+        *  4   Bad response or no response from processor
+        *  5   Transaction validation not accepted
+        *  6   Merchant authentication failure or bad account
+        *  7   Card Declined
+     *
+     * @return array    Returns array of results
+     */
+    function processPayment($pmt, $contact = false)
+    {
+
+       // Get last digit of card number that indicates desired response
+       $respCode = substr($pmt['ccnumb'], 15, 1);
+
+       // Approved flag
+       $approved = false;
+
+       // Prepare synthesized response
+       switch ($respCode) {
+
+               case 1:
+
+                       $resp = array(
+                           'gateway' => 'Card # Tests',
+                               'status' => 1,
+                               'statusText' => 'Card Approved',
+                               'authCode' => '00110011',
+                               'description' => 'Card Approved'
+                       );
+                       break;
+
+               case 2:
+
+                       $resp = array(
+                           'gateway' => 'Card # Tests',
+                           'status' => 2,
+                    'statusText' => 'Bad data supplied',
+                               'authCode' => '',
+                               'description' => 'Card number was not recognizable'
+                       );
+                       break;
+
+               case 3:
+
+                       $resp = array(
+                    'gateway' => 'Card # Tests',
+                    'status' => 3,
+                    'statusText' => 'Communications failure',
+                    'authCode' => '',
+                    'description' => 'We were unable to communicate with the credit card processing service.'
+                       );
+                       break;
+
+               case 4:
+
+                       $resp = array(
+                    'gateway' => 'Card # Tests',
+                    'status' => 4,
+                    'statusText' => 'Bad Response',
+                    'authCode' => '',
+                    'description' => 'We received an unrecognizable response from the credit card processing service.'
+                       );
+                       break;
+
+               case 5:
+
+                       $resp = array(
+                    'gateway' => 'Card # Tests',
+                    'status' => 5,
+                    'statusText' => 'Transaction not valid',
+                    'authCode' => '',
+                    'description' => 'We were unable to validate the response from the credit card processor.'
+                       );
+                       break;
+
+               case 6:
+
+                       $resp = array(
+                    'gateway' => 'Card # Tests',
+                    'status' => 6,
+                    'statusText' => 'Merchant account problem',
+                    'authCode' => '00110011',
+                    'description' => 'The merchant account for this venue was not recognized by the credit card processor.'
+                       );
+                       break;
+
+               case 7:
+
+                       $resp = array(
+                    'gateway' => 'Card # Tests',
+                    'status' => 7,
+                    'statusText' => 'Card Declined',
+                    'authCode' => '',
+                    'description' => 'Your credit card purchase was declined.'
+                       );
+                       break;
+
+               default:        // Consider any other last digit as approved
+
+                       $resp = array(
+                    'gateway' => 'Card # Tests',
+                    'status' => 1,
+                    'statusText' => 'Card Approved',
+                    'authCode' => '00110011',
+                    'description' => 'Card Approved'
+                       );
+                       break;
+
+       }
+
+       return $resp;
+    }
+
+}
+
+
 ?>
\ No newline at end of file
index 2dd38a8..d5e5dbe 100644 (file)
@@ -1,96 +1,96 @@
-<?php\r
-/**\r
- * Event Management System\r
- * No Payment PaymentGateway class\r
- *\r
- * @category Front-End\r
- * @package  EventManagement\r
- * @author   Chuck Scott <cscott@gaslightmedia.com>\r
- * @license  http://www.gaslightmedia.com Gaslightmedia\r
- * @release  SVN: $Id: classes/paymentProcessors/no_payment.php,v 1.0 2011/01/25 19:31:47 cscott Exp $\r
- * @link     <>\r
- */\r
-\r
-/**\r
- * No Payment PaymentGateway class\r
- *\r
- * PHP version 5\r
- *\r
- * @category Event Management Admin Tickets\r
- * @package  EventManagement\r
- * @author   Chuck Scott <cscott@gaslightmedia.com>\r
- * @license  http://www.gaslightmedia.com Gaslightmedia\r
- * @release  SVN: $Id: classes/paymentProcessors/no_payment.php,v 1.0 2011/01/25 19:31:47 cscott Exp $\r
- * @link     <>\r
- */\r
-\r
-/**\r
- * No Payment Gateway class\r
- *\r
- * PHP version 5\r
- */\r
-\r
-class PaymentGateway\r
-{\r
-\r
-    /**\r
-     * Constructor\r
-     *\r
-     * @param $account Array of account information - Not used for Test Processor\r
-     *\r
-     * @return boolean    Returns value of $success parameter\r
-     * @access public\r
-     */\r
-    function __construct($account = false)\r
-    {\r
-\r
-       // Nothing to do here\r
-        return true;\r
-\r
-    }\r
-\r
-    /*\r
-     * No Payment Required\r
-     *\r
-     * @param array    $pmt Payment information\r
-     *\r
-     * array(\r
-     *                 'gateway' => {selected payment gateway},\r
-     *                 'name' => {name of venue}\r
-     *                 'charge' => {amount to charge card}\r
-     *                 'cctype' => {type of card - text}\r
-     *                 'ccnumb' => {card number - digits only}\r
-     *                 'ccexp' => {expiration date as m/Y}\r
-     *                 'ccode' => {security code on back of card}\r
-     * )\r
-     *\r
-     * @param array $contact Billing contact information (not used in this class)\r
-     *\r
-     * This Processor always returns a "Card Approved" status\r
-     * and synthesizes a corresponding response.\r
-     *\r
-        *      1       Card Approved\r
-     *\r
-     * @return array    Returns array of results\r
-     */\r
-    function processPayment($pmt, $contact = false)\r
-    {\r
-\r
-       // Get last digit of card number that indicates desired response\r
-       $respCode = 'NO-PAYMENT';\r
-\r
-       // Approved flag\r
-       $approved = false;\r
-\r
-               $resp = array(\r
-                   'gateway' => 'Card Good',\r
-                   'status' => 1,\r
-                       'statusText' => 'No Payment',\r
-                       'authCode' => '000000',\r
-                       'description' => 'No Payment Required'\r
-               );\r
-\r
-       return $resp;\r
-    }\r
-\r
+<?php
+/**
+ * Event Management System
+ * No Payment PaymentGateway class
+ *
+ * @category Front-End
+ * @package  EventManagement
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: classes/paymentProcessors/no_payment.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ * @link     <>
+ */
+
+/**
+ * No Payment PaymentGateway class
+ *
+ * PHP version 5
+ *
+ * @category Event Management Admin Tickets
+ * @package  EventManagement
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: classes/paymentProcessors/no_payment.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ * @link     <>
+ */
+
+/**
+ * No Payment Gateway class
+ *
+ * PHP version 5
+ */
+
+class PaymentGateway
+{
+
+    /**
+     * Constructor
+     *
+     * @param $account Array of account information - Not used for Test Processor
+     *
+     * @return boolean    Returns value of $success parameter
+     * @access public
+     */
+    function __construct($account = false)
+    {
+
+       // Nothing to do here
+        return true;
+
+    }
+
+    /*
+     * No Payment Required
+     *
+     * @param array    $pmt Payment information
+     *
+     * array(
+     *                 'gateway' => {selected payment gateway},
+     *                 'name' => {name of venue}
+     *                 'charge' => {amount to charge card}
+     *                 'cctype' => {type of card - text}
+     *                 'ccnumb' => {card number - digits only}
+     *                 'ccexp' => {expiration date as m/Y}
+     *                 'ccode' => {security code on back of card}
+     * )
+     *
+     * @param array $contact Billing contact information (not used in this class)
+     *
+     * This Processor always returns a "Card Approved" status
+     * and synthesizes a corresponding response.
+     *
+        *      1       Card Approved
+     *
+     * @return array    Returns array of results
+     */
+    function processPayment($pmt, $contact = false)
+    {
+
+       // Get last digit of card number that indicates desired response
+       $respCode = 'NO-PAYMENT';
+
+       // Approved flag
+       $approved = false;
+
+               $resp = array(
+                   'gateway' => 'Card Good',
+                   'status' => 1,
+                       'statusText' => 'No Payment',
+                       'authCode' => '000000',
+                       'description' => 'No Payment Required'
+               );
+
+       return $resp;
+    }
+
 }
\ No newline at end of file