From: Laury GvR Date: Mon, 17 Nov 2014 19:43:49 +0000 (-0500) Subject: Initial commit X-Git-Tag: v1.0~1 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=8483a908d024bb656c3b708d174d36cfe235a266;p=WP-Plugins%2FGlmPayments.git Initial commit --- 8483a908d024bb656c3b708d174d36cfe235a266 diff --git a/anet_php_sdk/AuthorizeNet.php b/anet_php_sdk/AuthorizeNet.php new file mode 100755 index 0000000..31fdaa9 --- /dev/null +++ b/anet_php_sdk/AuthorizeNet.php @@ -0,0 +1,29 @@ + Includes all classes. Include this file in your project. + - lib/AuthorizeNetAIM.php -> AIM API. + - lib/AuthorizeNetARB.php -> ARB API. + - lib/AuthorizeNetCIM.php -> CIM API. + - lib/AuthorizeNetSIM.php -> SIM API. + - lib/AuthorizeNetTD.php -> Reporting API. + - lib/AuthorizeNetCP.php -> Card Present API. + - lib/AuthorizeNetDPM.php -> Direct Post Method Helpers. + - lib/AuthorizeNetSOAP.php -> Class to assist with using the SOAP API. + - lib/shared/AuthorizeNetRequest.php -> Class to connect to AuthorizeNet. + - lib/shared/AuthorizeNetTypes.php -> Classes for AuthorizeNet Datatypes. + - lib/shared/AuthorizeNetResponse.php -> Class to parse AuthorizeNet NVP Responses. + - lib/shared/AuthorizeNetXMLResponse.php -> Class to parse AuthorizeNet XML Responses. + - lib/ssl/cert.pem -> The AuthorizeNet Certificate bundle. + - tests/ -> Tests & examples for each of the API methods. + - README -> This file. + - README.html -> HTML version of this file. + +Requirements: + - cURL PHP Extension + - PHP 5.2+ + - An Authorize.Net Merchant Account or Test Account. You can get a + free test account at http://developer.authorize.net/testaccount/ + +Install: + - Include the 'AuthorizeNet.php' file in your application. + - Use your desired API. + +Usage Examples: + See below for basic usage examples. View the tests/ folder for more examples of each API. + +AuthorizeNetAIM.php Quick Usage Example: + amount = "5.99"; + $sale->card_num = '6011000000000012'; + $sale->exp_date = '04/15'; + $response = $sale->authorizeAndCapture(); + if ($response->approved) { + $transaction_id = $response->transaction_id; + } + ?> + +AuthorizeNetAIM.php Advanced Usage Example: + amount = "45.00"; + + // Use eCheck: + $auth->setECheck( + '121042882', + '123456789123', + 'CHECKING', + 'Bank of Earth', + 'Jane Doe', + 'WEB' + ); + + // Set multiple line items: + $auth->addLineItem('item1', 'Golf tees', 'Blue tees', '2', '5.00', 'N'); + $auth->addLineItem('item2', 'Golf shirt', 'XL', '1', '40.00', 'N'); + + // Set Invoice Number: + $auth->invoice_num = time(); + + // Set a Merchant Defined Field: + $auth->setCustomField("entrance_source", "Search Engine"); + + // Authorize Only: + $response = $auth->authorizeOnly(); + + if ($response->approved) { + $auth_code = $response->transaction_id; + + // Now capture: + $capture = new AuthorizeNetAIM; + $capture_response = $capture->priorAuthCapture($auth_code); + + // Now void: + $void = new AuthorizeNetAIM; + $void_response = $void->void($capture_response->transaction_id); + } + ?> + +AuthorizeNetARB.php Usage Example: + name = "PHP Monthly Magazine"; + $subscription->intervalLength = "1"; + $subscription->intervalUnit = "months"; + $subscription->startDate = "2011-03-12"; + $subscription->totalOccurrences = "12"; + $subscription->amount = "12.99"); + $subscription->creditCardCardNumber = "6011000000000012"; + $subscription->creditCardExpirationDate= "2018-10"; + $subscription->creditCardCardCode = "123"; + $subscription->billToFirstName = "Rasmus"; + $subscription->billToLastName = "Doe"; + + // Create the subscription. + $request = new AuthorizeNetARB; + $response = $request->createSubscription($subscription); + $subscription_id = $response->getSubscriptionId(); + ?> + +AuthorizeNetCIM.php Usage Example: + description = "Description of customer"; + $customerProfile->merchantCustomerId= time(); + $customerProfile->email = "test@domain.com"; + $response = $request->createCustomerProfile($customerProfile); + if ($response->isOk()) { + $customerProfileId = $response->getCustomerProfileId(); + } + ?> + +AuthorizeNetSIM.php Usage Example: + isAuthorizeNet()) { + $transactionId = $message->transaction_id; + } + ?> + +AuthorizeNetDPM.php Usage Example: + + +AuthorizeNetCP.php Usage Example: + amount = '59.99'; + $sale->device_type = '4'; + $sale->setTrack1Data('%B4111111111111111^CARDUSER/JOHN^1803101000000000020000831000000?'); + $response = $sale->authorizeAndCapture(); + $trans_id = $response->transaction_id; + ?> + +AuthorizeNetTD.php Usage Example: + getTransactionDetails("12345"); + echo $response->xml->transaction->transactionStatus; + ?> + +Test Credit Card Numbers: + - Set the expiration date to anytime in the future. + - American Express Test Card=> 370000000000002 + - Discover Test Card => 6011000000000012 + - Visa Test Card => 4007000000027 + - Second Visa Test Card => 4012888818888 + - JCB => 3088000000000017 + - Diners Club/ Carte Blanche=> 38000000000006 + +PHPDoc: + To autogenerate PHPDocs run: + phpdoc -t phpdocs/ -f AuthorizeNet.php -d lib + +Release Notes + Version 1.1.8 + - Fixed an issue with validationMode in CIM::updateCustomerPaymentProfile. + Note: The behavior where validationMode persisted across transactions using the same request object + has been removed. This was unsupported behavior. + - Removed an unused validationMode argument in CIM::updateCustomerProfile. The parameter used to be ignored, now its removed. + - Enhanced the tests with checks for single digit months in expiration date support and SSL certificate validity. + Version 1.1.7 + - Added getBatchStatisticsRequest and getUnsettledTransactionListRequest support to the SDK. + Version 1.1.6 + - Added the HTML version of the README to the distributed bundle. It was missing in version 1.1.5. + Version 1.1.5 + - Added HTML version of README. + Version 1.1.4 + - Updated the cert.pem bundle to include the new secure.authorize.net SSL certificate. + Version 1.1.3 + - Added more documentation + - Improved support for all Transaction Details API methods. + - Added support for the Card Present API. + - Added easier xpath support to XML Response class. + - Added ability to use DPM sample app with production account. + Version 1.1.2 + - Added getValidationResponses method to CIM Response for parsing the validation results when validating payment profiles. + - Added support for UpdateSplitTenderGroup method to CIM request. + - Bug fix. In CIM requests using validation mode the the validation mode element should have been added to the end of the request. + - Bug fix. In AIM Response class where $response->account_number was returning the wrong value. \ No newline at end of file diff --git a/anet_php_sdk/README.html b/anet_php_sdk/README.html new file mode 100755 index 0000000..795637a --- /dev/null +++ b/anet_php_sdk/README.html @@ -0,0 +1,358 @@ + + + + PHP SDK README + + + + +

Authorize.Net PHP SDK

+

version 3.1.2

+
http://developer.authorize.net
+
http://community.developer.authorize.net
+ +
+

License

+Authorize.Net
+ See License.pdf +
+ +
+

About

+A PHP library for working with all Authorize.Net APIs. + + +
+

Files

+ + + + + + + + + + + + + + + + + + + +
Authorize.Net.phpIncludes all classes. Include this file in your project.
AuthorizeNet.phpIncludes all classes. Include this file in your project.
lib/AuthorizeNetAIM.phpAIM API.
lib/AuthorizeNetARB.php-> ARB API.
lib/AuthorizeNetCIM.phpCIM API.
lib/AuthorizeNetSIM.phpSIM API.
lib/AuthorizeNetTD.phpReporting API.
lib/AuthorizeNetCP.phpCard Present API.
lib/AuthorizeNetDPM.phpDirect Post Method Helpers.
lib/AuthorizeNetSOAP.phpClass to assist with using the SOAP API.
lib/shared/AuthorizeNetRequest.phpClass to connect to AuthorizeNet.
lib/shared/AuthorizeNetTypes.phpClasses for AuthorizeNet Datatypes.
lib/shared/AuthorizeNetResponse.phpClass to parse AuthorizeNet NVP Responses.
lib/shared/AuthorizeNetXMLResponse.phpClass to parse AuthorizeNet XML Responses.
lib/ssl/cert.pemThe AuthorizeNet Certificate bundle.
tests/Tests & examples for each of the API methods.
READMEPlain text version of this file.
README.htmlThis file.
+ +
+

Requirements

+ + +

Install

+ + +

Usage Examples:

+ See below for basic usage examples. View the tests/ folder for more examples of each API. + +
AuthorizeNetAIM.php Quick Usage Example
+<?php + require_once 'anet_php_sdk/AuthorizeNet.php'; + define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN"); + define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY"); + define("AUTHORIZENET_SANDBOX", true); + $sale = new AuthorizeNetAIM; + $sale->amount = "5.99"; + $sale->card_num = '6011000000000012'; + $sale->exp_date = '04/15'; + $response = $sale->authorizeAndCapture(); + if ($response->approved) { + $transaction_id = $response->transaction_id; + } +?> + + +
AuthorizeNetAIM.php Advanced Usage Example
+<?php + require_once 'anet_php_sdk/AuthorizeNet.php'; + define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN"); + define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY"); + define("AUTHORIZENET_SANDBOX", true); + $auth = new AuthorizeNetAIM; + $auth->amount = "45.00"; + + // Use eCheck: + $auth->setECheck( + '121042882', + '123456789123', + 'CHECKING', + 'Bank of Earth', + 'Jane Doe', + 'WEB' + ); + + // Set multiple line items: + $auth->addLineItem('item1', 'Golf tees', 'Blue tees', '2', '5.00', 'N'); + $auth->addLineItem('item2', 'Golf shirt', 'XL', '1', '40.00', 'N'); + + // Set Invoice Number: + $auth->invoice_num = time(); + + // Set a Merchant Defined Field: + $auth->setCustomField("entrance_source", "Search Engine"); + + // Authorize Only: + $response = $auth->authorizeOnly(); + + if ($response->approved) { + $auth_code = $response->transaction_id; + + // Now capture: + $capture = new AuthorizeNetAIM; + $capture_response = $capture->priorAuthCapture($auth_code); + + // Now void: + $void = new AuthorizeNetAIM; + $void_response = $void->void($capture_response->transaction_id); + } +?> + + +
AuthorizeNetARB.php Usage Example
+<?php + require_once 'anet_php_sdk/AuthorizeNet.php'; + define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN"); + define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY"); + $subscription = new AuthorizeNet_Subscription; + $subscription->name = "PHP Monthly Magazine"; + $subscription->intervalLength = "1"; + $subscription->intervalUnit = "months"; + $subscription->startDate = "2011-03-12"; + $subscription->totalOccurrences = "12"; + $subscription->amount = "12.99"); + $subscription->creditCardCardNumber = "6011000000000012"; + $subscription->creditCardExpirationDate= "2018-10"; + $subscription->creditCardCardCode = "123"; + $subscription->billToFirstName = "Rasmus"; + $subscription->billToLastName = "Doe"; + + // Create the subscription. + $request = new AuthorizeNetARB; + $response = $request->createSubscription($subscription); + $subscription_id = $response->getSubscriptionId(); +?> + + +
AuthorizeNetCIM.php Usage Example
+<?php + require_once 'anet_php_sdk/AuthorizeNet.php'; + define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN"); + define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY"); + $request = new AuthorizeNetCIM; + // Create new customer profile + $customerProfile = new AuthorizeNetCustomer; + $customerProfile->description = "Description of customer"; + $customerProfile->merchantCustomerId= time(); + $customerProfile->email = "test@domain.com"; + $response = $request->createCustomerProfile($customerProfile); + if ($response->isOk()) { + $customerProfileId = $response->getCustomerProfileId(); + } +?> + + +
AuthorizeNetSIM.php Usage Example
+<?php + require_once 'anet_php_sdk/AuthorizeNet.php'; + define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN"); + define("AUTHORIZENET_MD5_SETTING", ""); + $message = new AuthorizeNetSIM; + if ($message->isAuthorizeNet()) { + $transactionId = $message->transaction_id; + } +?> + + +
AuthorizeNetDPM.php Usage Example
+<?php // Filename: direct_post.php + require_once 'anet_php_sdk/AuthorizeNet.php'; // The SDK + $url = "http://YOUR_DOMAIN.com/direct_post.php"; + $api_login_id = 'YOUR_API_LOGIN_ID'; + $transaction_key = 'YOUR_TRANSACTION_KEY'; + $md5_setting = 'YOUR_MD5_SETTING'; // Your MD5 Setting + $amount = "5.99"; + AuthorizeNetDPM::directPostDemo($url, $api_login_id, $transaction_key, $amount, $md5_setting); +?> + + +
AuthorizeNetCP.php Usage Example
+<?php + require_once 'anet_php_sdk/AuthorizeNet.php'; + define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN"); + define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY"); + define("AUTHORIZENET_MD5_SETTING", ""); + $sale = new AuthorizeNetCP; + $sale->amount = '59.99'; + $sale->device_type = '4'; + $sale->setTrack1Data('%B4111111111111111^CARDUSER/JOHN^1803101000000000020000831000000?'); + $response = $sale->authorizeAndCapture(); + $trans_id = $response->transaction_id; +?> + + +
AuthorizeNetTD.php Usage Example
+<?php + require_once 'anet_php_sdk/AuthorizeNet.php'; + define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN"); + define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY"); + $request = new AuthorizeNetTD; + $response = $request->getTransactionDetails("12345"); + echo $response->xml->transaction->transactionStatus; +?> + + +
+

Test Credit Card Numbers

+ + + + + + + +
American Express Test Card370000000000002
Discover Test Card6011000000000012
Visa Test Card4007000000027
Second Visa Test Card4012888818888
JCB3088000000000017
Diners Club/ Carte Blanche38000000000006
+Set the expiration date to anytime in the future. +
+ +

PHPDoc:

+ To autogenerate PHPDocs run + phpdoc -t phpdocs/ -f AuthorizeNet.php -d lib + +

Release Notes

+ + Version 1.1.8 + + Version 1.1.7 + + Version 1.1.6 + + Version 1.1.5 + + Version 1.1.4 + + Version 1.1.3 + + Version 1.1.2 + + + + \ No newline at end of file diff --git a/anet_php_sdk/doc/AIM.markdown b/anet_php_sdk/doc/AIM.markdown new file mode 100755 index 0000000..2ae1541 --- /dev/null +++ b/anet_php_sdk/doc/AIM.markdown @@ -0,0 +1,187 @@ +Advanced Integration Method +=========================== + +Basic Overview +-------------- + +The AuthorizeNetAIM class creates a request object for submitting transactions +to the AuthorizeNetAIM API. To use, create an instance of the class, set the fields +for your transaction, call the method you want to use (Authorize Only, Authorize & +Capture, etc.) and you'll receive an AuthorizeNetAIM response object providing easy access +to the results of the transaction. + +Including the SDK +----------------- + +require_once 'anet_php_sdk/AuthorizeNet.php'; + +Setting Merchant Credentials +---------------------------- +The easiest way to set credentials is to define constants which the SDK uses: +define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN"); +define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY"); + +You can also set credentials manually per request like so: + +$sale = new AuthorizeNetAIM("YOUR_API_LOGIN_ID","YOUR_TRANSACTION_KEY"); + + +Setting the Transaction Post Location +------------------------------------- + +To post transactions to the live Authorize.Net gateway: +define("AUTHORIZENET_SANDBOX", false); + +To post transactions to the Authorize.Net test server: +define("AUTHORIZENET_SANDBOX", true); + +You can also set the location manually per request: +$sale->setSandbox(false); + + +Setting Fields +-------------- + +An Authorize.Net AIM request is simply a set of name/value pairs. The PHP SDK +allows you to set these fields in a few different ways depending on your +preference. + +Note: to make things easier on the developer, the "x_" prefix attached to each +field in the AIM API has been removed. Thus, instead of setting $sale->x_card_num, +set $sale->card_num instead. + +1.) By Setting Fields Directly: +$sale = new AuthorizeNetAIM; +$sale->amount = "1999.99"; +$sale->card_num = '6011000000000012'; +$sale->exp_date = '04/15'; +$response = $sale->authorizeAndCapture(); + +2.) By Setting Multiple Fields at Once: +$sale = new AuthorizeNetAIM; +$sale->setFields( + array( + 'amount' => rand(1, 1000), + 'card_num' => '6011000000000012', + 'exp_date' => '0415' + ) +); + +3.) By Setting Special Items + +To add line items or set custom fields use the respective functions: + +Line Items: +$sale->addLineItem( + 'item1', // Item Id + 'Golf tees', // Item Name + 'Blue tees', // Item Description + '2', // Item Quantity + '5.00', // Item Unit Price + 'N' // Item taxable + ); + +Custom Fields: +$sale->setCustomField("coupon_code", "SAVE2011"); + +4.) By Passing in Objects + +Each property will be copied from the object to the AIM request. + +$sale = new AuthorizeNetAIM; +$customer = (object)array(); +$customer->first_name = "Jane"; +$customer->last_name = "Smith"; +$customer->company = "Jane Smith Enterprises Inc."; +$customer->address = "20 Main Street"; +$customer->city = "San Francisco"; +$customer->state = "CA"; +$customer->zip = "94110"; +$customer->country = "US"; +$customer->phone = "415-555-5557"; +$customer->fax = "415-555-5556"; +$customer->email = "foo@example.com"; +$customer->cust_id = "55"; +$customer->customer_ip = "98.5.5.5"; +$sale->setFields($customer); + +Submitting Transactions +----------------------- +To submit a transaction call one of the 7 methods: + +-authorizeAndCapture() +-authorizeOnly() +-priorAuthCapture() +-void() +-captureOnly() +-credit() + +Each method has optional parameters which highlight the fields required by the +Authorize.Net API for that transaction type. + + +eCheck +------ +To submit an electronic check transaction you can set the required fields individually +or simply use the setECheck method: + +$sale = new AuthorizeNetAIM; +$sale->amount = "45.00"; +$sale->setECheck( + '121042882', // bank_aba_code + '123456789123', // bank_acct_num + 'CHECKING', // bank_acct_type + 'Bank of Earth', // bank_name + 'Jane Doe', // bank_acct_name + 'WEB' // echeck_type +); +$response = $sale->authorizeAndCapture(); + + +Partial Authorization Transactions +---------------------------------- +To enable partial authorization transactions set the partial_auth flag +to true: + +$sale->allow_partial_auth = true; + +You should receive a split tender id in the response if a partial auth +is made: + +$split_tender_id = $response->split_tender_id; + + +Itemized Order Information +-------------------------- +To add itemized order information use the addLineItem method: + +$auth->addLineItem( + 'item1', // Item Id + 'Golf tees', // Item Name + 'Blue tees', // Item Description + '2', // Item Quantity + '5.00', // Item Unit Price + 'N' // Item taxable + ); + + +Merchant Defined Fields +----------------------- +You can use the setCustomField method to set any custom merchant defined field(s): + +$sale->setCustomField("entrance_source", "Search Engine"); +$sale->setCustomField("coupon_code", "SAVE2011"); + + +Transaction Response +-------------------- +When you submit an AIM transaction you receive an AuthorizeNetAIM_Response +object in return. You can access each name/value pair in the response as +you would normally expect: + +$response = $sale->authorizeAndCapture(); +$response->response_code; +$response->response_subcode; +$response->response_reason_code; +$response->transaction_id; + diff --git a/anet_php_sdk/doc/ARB.markdown b/anet_php_sdk/doc/ARB.markdown new file mode 100755 index 0000000..1d4bb92 --- /dev/null +++ b/anet_php_sdk/doc/ARB.markdown @@ -0,0 +1,52 @@ +ARB API +======= + +Basic Overview +-------------- + +The AuthorizeNetARB class creates a request object for submitting transactions +to the AuthorizeNetARB API. + + +Creating/Updating Subscriptions +------------------------------- + +To create or update a subscription first create a subscription object: + +$subscription = new AuthorizeNet_Subscription; +$subscription->name = "Short subscription"; +$subscription->intervalLength = "1"; +$subscription->intervalUnit = "months"; +$subscription->startDate = "2011-03-12"; +$subscription->totalOccurrences = "14"; +$subscription->amount = rand(1,100); +$subscription->creditCardCardNumber = "6011000000000012"; +$subscription->creditCardExpirationDate = "2018-10"; +$subscription->creditCardCardCode = "123"; +$subscription->billToFirstName = "john"; +$subscription->billToLastName = "doe"; + +Then create an AuthorizeNetARB object and call the appropriate method +passing in your subscription object: + +$request = new AuthorizeNetARB; +$response = $request->createSubscription($subscription); + + or for updating a subscription: + +$response = $request->updateSubscription($subscription_id, $subscription); + +Getting Subscription Status +--------------------------- + +Create a new AuthorizeNetARB object and call the getSubscriptionStatus +method with the subscription_id you want the status of as the parameter: + +$status_request = new AuthorizeNetARB; +$status_response = $status_request->getSubscriptionStatus($subscription_id); + +Canceling a Subscription +------------------------ + +$cancellation = new AuthorizeNetARB; +$cancel_response = $cancellation->cancelSubscription($subscription_id); diff --git a/anet_php_sdk/doc/CIM.markdown b/anet_php_sdk/doc/CIM.markdown new file mode 100755 index 0000000..bbe8a3b --- /dev/null +++ b/anet_php_sdk/doc/CIM.markdown @@ -0,0 +1,249 @@ +CIM API +======= + +Basic Overview +-------------- + +The AuthorizeNetCIM class creates a request object for submitting transactions +to the Authorize.Net CIM API. + + +Creating a Customer Profile +--------------------------- + +To create a new cusomter profile, first create a new AuthorizeNetCustomer +object. + +$customerProfile = new AuthorizeNetCustomer; +$customerProfile->description = "Description of customer"; +$customerProfile->merchantCustomerId = 123; +$customerProfile->email = "user@domain.com"; + +You can then create an add payment profiles and addresses to this +customer object. + +// Add payment profile. +$paymentProfile = new AuthorizeNetPaymentProfile; +$paymentProfile->customerType = "individual"; +$paymentProfile->payment->creditCard->cardNumber = "4111111111111111"; +$paymentProfile->payment->creditCard->expirationDate = "2015-10"; +$customerProfile->paymentProfiles[] = $paymentProfile; + +// Add another payment profile. +$paymentProfile2 = new AuthorizeNetPaymentProfile; +$paymentProfile2->customerType = "business"; +$paymentProfile2->payment->bankAccount->accountType = "businessChecking"; +$paymentProfile2->payment->bankAccount->routingNumber = "121042882"; +$paymentProfile2->payment->bankAccount->accountNumber = "123456789123"; +$paymentProfile2->payment->bankAccount->nameOnAccount = "Jane Doe"; +$paymentProfile2->payment->bankAccount->echeckType = "WEB"; +$paymentProfile2->payment->bankAccount->bankName = "Pandora Bank"; +$customerProfile->paymentProfiles[] = $paymentProfile2; + + +// Add shipping address. +$address = new AuthorizeNetAddress; +$address->firstName = "john"; +$address->lastName = "Doe"; +$address->company = "John Doe Company"; +$address->address = "1 Main Street"; +$address->city = "Boston"; +$address->state = "MA"; +$address->zip = "02412"; +$address->country = "USA"; +$address->phoneNumber = "555-555-5555"; +$address->faxNumber = "555-555-5556"; +$customerProfile->shipToList[] = $address; + +// Add another shipping address. +$address2 = new AuthorizeNetAddress; +$address2->firstName = "jane"; +$address2->lastName = "Doe"; +$address2->address = "11 Main Street"; +$address2->city = "Boston"; +$address2->state = "MA"; +$address2->zip = "02412"; +$address2->country = "USA"; +$address2->phoneNumber = "555-512-5555"; +$address2->faxNumber = "555-523-5556"; +$customerProfile->shipToList[] = $address2; + + +Next, create an AuthorizeNetCIM object: + +$request = new AuthorizeNetCIM; + +Finally, call the createCustomerProfile method and pass in your +customer object: + +$response = $request->createCustomerProfile($customerProfile); + +The response object provides some helper methods for easy access to the +results of the transaction: + +$new_customer_id = $response->getCustomerProfileId(); + +The response object also stores the XML response as a SimpleXml element +which you can access like so: + +$new_customer_id = $response->xml->customerProfileId + +You can also run xpath queries against the result: + +$array = $response->xpath('customerProfileId'); +$new_customer_id = $array[0]; + + +Deleting a Customer Profile +--------------------------- + +To delete a customer profile first create a new AuthorizeNetCIM object: + +$request = new AuthorizeNetCIM; + +Then call the deleteCustomerProfile method: + +request->deleteCustomerProfile($customer_id); + + +Retrieving a Customer Profile +----------------------------- + +To retrieve a customer profile call the getCustomerProfile method: + +$response = $request->getCustomerProfile($customerProfileId); + + +Validation Mode +--------------- + +Validation mode allows you to generate a test transaction at the time you create a customer profile. In Test Mode, only field validation is performed. In Live Mode, a transaction is generated and submitted to the processor with the amount of $0.00 or $0.01. If successful, the transaction is immediately voided. + +To create a customer profile with Validation mode, simply pass in the +a value for the validation mode parameter on the createCustomerProfile method: + +$response = $request->createCustomerProfile($customerProfile, "testMode"); + +You can access the validation response for each payment profile via xpath, +the SimpleXML element or the getValidationResponses method: + +$validationResponses = $response->getValidationResponses(); + foreach ($validationResponses as $vr) { + echo $vr->approved; +} + + +Updating a Customer Profile +--------------------------- + +Call the updateCustomerProfile method with the customerProfileId and customerProfile +parameters: + +$response = $request->updateCustomerProfile($customerProfileId, $customerProfile); + + +Adding a Payment Profile +------------------------ + + +$paymentProfile = new AuthorizeNetPaymentProfile; +$paymentProfile->customerType = "individual"; +$paymentProfile->payment->creditCard->cardNumber = "4111111111111111"; +$paymentProfile->payment->creditCard->expirationDate = "2015-10"; +$response = $request->createCustomerPaymentProfile($customerProfileId, $paymentProfile); + + +Updating a Payment Profile +-------------------------- + +$paymentProfile->payment->creditCard->cardNumber = "4111111111111111"; +$paymentProfile->payment->creditCard->expirationDate = "2017-11"; +$response = $request->updateCustomerPaymentProfile($customerProfileId,$paymentProfileId, $paymentProfile); + +Adding a Shipping Address +------------------------- + + + +$address = new AuthorizeNetAddress; +$address->firstName = "john"; +$address->lastName = "Doe"; +$address->company = "John Doe Company"; +$address->address = "1 Main Street"; +$address->city = "Boston"; +$address->state = "MA"; +$address->zip = "02412"; +$address->country = "USA"; +$address->phoneNumber = "555-555-5555"; +$address->faxNumber = "555-555-5556"; +$response = $request->createCustomerShippingAddress($customerProfileId, $address); +$customerAddressId = $response->getCustomerAddressId(); + +Updating a Shipping Address +--------------------------- + +// Update shipping address. +$address->address = "2 First Street"; +$response = $request->updateCustomerShippingAddress($customerProfileId, $customerAddressId, $address); + + +Creating Transactions +--------------------- + +// Create Auth & Capture Transaction +$transaction = new AuthorizeNetTransaction; +$transaction->amount = "9.79"; +$transaction->customerProfileId = $customerProfileId; +$transaction->customerPaymentProfileId = $paymentProfileId; +$transaction->customerShippingAddressId = $customerAddressId; + +$lineItem = new AuthorizeNetLineItem; +$lineItem->itemId = "4"; +$lineItem->name = "Cookies"; +$lineItem->description = "Chocolate Chip"; +$lineItem->quantity = "4"; +$lineItem->unitPrice = "1.00"; +$lineItem->taxable = "true"; + +$lineItem2 = new AuthorizeNetLineItem; +$lineItem2->itemId = "4"; +$lineItem2->name = "Cookies"; +$lineItem2->description= "Peanut Butter"; +$lineItem2->quantity = "4"; +$lineItem2->unitPrice = "1.00"; +$lineItem2->taxable = "true"; + +$transaction->lineItems[] = $lineItem; +$transaction->lineItems[] = $lineItem2; + + +$response = $request->createCustomerProfileTransaction("AuthCapture", $transaction); +$transactionResponse = $response->getTransactionResponse(); +$transactionId = $transactionResponse->transaction_id; + + +Voiding a Transaction +--------------------- + +$transaction = new AuthorizeNetTransaction; +$transaction->transId = $transactionId; +$response = $request->createCustomerProfileTransaction("Void", $transaction); + + +Deleting a Shipping Address +--------------------------- + +$response = $request->deleteCustomerShippingAddress($customerProfileId, $customerAddressId); + + +Deleting a Payment Profile +-------------------------- + +$response = $request->deleteCustomerPaymentProfile($customerProfileId, $paymentProfileId); + + + +Getting Customer Profile IDs +---------------------------- + +$response = $request->getCustomerProfileIds(); \ No newline at end of file diff --git a/anet_php_sdk/doc/CP.markdown b/anet_php_sdk/doc/CP.markdown new file mode 100755 index 0000000..96ea161 --- /dev/null +++ b/anet_php_sdk/doc/CP.markdown @@ -0,0 +1,43 @@ +Card Present API +================ + +Basic Overview +-------------- + +The AuthorizeNetCP class creates a request object for submitting transactions +to the AuthorizeNetCP API. The AuthorizeNetCP class extends the AuthorizeNetAIM +class. See the AIM.markdown for help with the basics. This document contains +information regarding the special features of the AuthorizeNetCP class. + + +Merchant Credentials +-------------------- + +Please note that if you are using both the CNP and CP APIs your merchant +credentials will be different. + +Setting Track Data +------------------ + +To set Track 1 and/or Track 2 data, use the respective methods like so: + +$sale = new AuthorizeNetCP(CP_API_LOGIN_ID, CP_TRANSACTION_KEY); +$sale->setFields( + array( + 'amount' => rand(1, 1000), + 'device_type' => '4', + ) +); +$sale->setTrack1Data('%B4111111111111111^CARDUSER/JOHN^1803101000000000020000831000000?'); +$response = $sale->authorizeAndCapture(); + +$sale = new AuthorizeNetCP(CP_API_LOGIN_ID, CP_TRANSACTION_KEY); +$sale->setFields( + array( + 'amount' => rand(1, 1000), + 'device_type' => '4', + ) +); +$sale->setTrack2Data('4111111111111111=1803101000020000831?'); +$response = $sale->authorizeAndCapture(); + diff --git a/anet_php_sdk/doc/DPM.markdown b/anet_php_sdk/doc/DPM.markdown new file mode 100755 index 0000000..115cc9d --- /dev/null +++ b/anet_php_sdk/doc/DPM.markdown @@ -0,0 +1,24 @@ +Direct Post Method +================== + +Basic Overview +-------------- + +The Authorize.Net PHP SDK includes a class that demonstrates one way +of implementing the Direct Post Method. + +While it is not necessary to use the AuthorizeNetDPM class to implement +DPM, it may serve as a handy reference. + +The AuthorizeNetDPM class extends the AuthorizeNetSIM_Form class. +See the SIM.markdown for additional documentation. + +Relay Response Snippet +---------------------- + +The AuthorizeNetDPM class contains a getRelayResponseSnippet($redirect_url) +which generates a snippet of HTML that will redirect a user back to your +site after submitting a checkout form using DPM/SIM. + +Use this method(or just grab the html) if you want to create a checkout +experience where the user only interacts with pages on your site. \ No newline at end of file diff --git a/anet_php_sdk/doc/SIM.markdown b/anet_php_sdk/doc/SIM.markdown new file mode 100755 index 0000000..ee38e59 --- /dev/null +++ b/anet_php_sdk/doc/SIM.markdown @@ -0,0 +1,74 @@ +Server Integration Method +========================= + +Basic Overview +-------------- + +The Authorize.Net PHP SDK includes classes that can speed up implementing +a Server Integration Method solution. + + +Hosted Order/Receipt Page +------------------------- + +The AuthorizeNetSIM_Form class aims to make it easier to setup the hidden +fields necessary for creating a SIM experience. While it is not necessary +to use the AuthorizeNetSIM_Form class to implement SIM, it may be handy for +reference. + +The code below will generate a buy now button that leads to a hosted order page: + +
+ $amount, + 'x_fp_sequence' => $fp_sequence, + 'x_fp_hash' => $fingerprint, + 'x_fp_timestamp' => $time, + 'x_relay_response'=> "FALSE", + 'x_login' => $api_login_id, + ) +); +echo $sim->getHiddenFieldString();?> + +
+ +Fingerprint Generation +---------------------- + +To generate the fingerprint needed for a SIM transaction call the getFingerprint method: + +$fingerprint = AuthorizeNetSIM_Form::getFingerprint($api_login_id, $transaction_key, $amount, $fp_sequence, $fp_timestamp); + + +Relay Response +-------------- + +The PHP SDK includes a AuthorizeNetSIM class for handling a relay response from +Authorize.Net. + +To receive a relay response from Authorize.Net you can either configure the +url in the Merchant Interface or specify the url when submitting a transaction +with SIM using the "x_relay_url" field. + +When a transaction occurs, Authorize.Net will post the transaction details to +this url. You can then craete a page on your server at a url such as +http://yourdomain.com/response_handler.php and execute any logic you want +when a transaction occurs. The AuthorizeNetSIM class makes it easy to verify +the transaction came from Authorize.Net and parse the response: + +$response = new AuthorizeNetSIM; +if ($response->isAuthorizeNet()) +{ + if ($response->approved) + { + // Activate magazine subscription + magazine_subscription_activate($response->cust_id); + } +} diff --git a/anet_php_sdk/doc/SOAP.markdown b/anet_php_sdk/doc/SOAP.markdown new file mode 100755 index 0000000..a535f00 --- /dev/null +++ b/anet_php_sdk/doc/SOAP.markdown @@ -0,0 +1,10 @@ +SOAP +==== + +Basic Overview +-------------- + +The AuthorizeNetSOAP class provides a very basic wrapper to PHP's bundled +SoapClient class. The AuthorizeNetSOAP class merely contains the WSDL, +Sandbox, and Live Production server urls to make it easier to connect +to the Authorize.Net SOAP API. \ No newline at end of file diff --git a/anet_php_sdk/doc/TD.markdown b/anet_php_sdk/doc/TD.markdown new file mode 100755 index 0000000..c9a1bfb --- /dev/null +++ b/anet_php_sdk/doc/TD.markdown @@ -0,0 +1,55 @@ +Transaction Details API +======================= + +Basic Overview +-------------- + +The AuthorizeNetTD class creates a request object for submitting requests +to the Authorize.Net Transaction Details API. + +The AuthorizeNetTD class returns a response that uses PHP's bundled SimpleXML +class for accessing it's members. + +The AuthorizeNetTD response provides two ways to access response elements: + +1.) A SimpleXml object: + +$response->xml->transaction->payment->creditCard->cardType + +2.) Xpath: + +$batches = $response->xpath("batchList/batch"); + +3.) AuthorizeNet Objects (todo) + + + +Get Transaction Details +----------------------- + +$request = new AuthorizeNetTD; +$response = $request->getTransactionDetails($transId); +echo "Amount: {$response->xml->transaction->authAmount}"; + +Get Settled Batch List +---------------------- +$request = new AuthorizeNetTD; +$response = $request->getSettledBatchList(); +$batches = $response->xpath("batchList/batch"); +echo "Batch 1: {$batches[0]->batchId}"; + +Get Transaction List +-------------------- +$request = new AuthorizeNetTD; +$response = $request->getTransactionList($batch_id); +$transactions = $response->xpath("transactions/transaction") + +There are two additional helper methods in the PHP SDK which +will make multiple calls to retrieve a day's worth of +transactions or a month's worth of batches: + +getTransactionsForDay($month, $day, $year = false) +getSettledBatchListForMonth($month , $year) + +If you don't pass parameters into these methods they will default +to the current day/month. diff --git a/anet_php_sdk/lib/AuthorizeNetAIM.php b/anet_php_sdk/lib/AuthorizeNetAIM.php new file mode 100755 index 0000000..e7aae63 --- /dev/null +++ b/anet_php_sdk/lib/AuthorizeNetAIM.php @@ -0,0 +1,500 @@ + + * setFields( + * array( + * 'amount' => '4.99', + * 'card_num' => '411111111111111', + * 'exp_date' => '0515' + * ) + * ); + * $response = $sale->authorizeAndCapture(); + * if ($response->approved) { + * echo "Sale successful!"; } else { + * echo $response->error_message; + * } + * ?> + * + * + * Note: To send requests to the live gateway, either define this: + * define("AUTHORIZENET_SANDBOX", false); + * -- OR -- + * $sale = new AuthorizeNetAIM; + * $sale->setSandbox(false); + * + * @package AuthorizeNet + * @subpackage AuthorizeNetAIM + * @link http://www.authorize.net/support/AIM_guide.pdf AIM Guide + */ + + +/** + * Builds and sends an AuthorizeNet AIM Request. + * + * @package AuthorizeNet + * @subpackage AuthorizeNetAIM + */ +class AuthorizeNetAIM extends AuthorizeNetRequest +{ + + const LIVE_URL = 'https://secure.authorize.net/gateway/transact.dll'; + const SANDBOX_URL = 'https://test.authorize.net/gateway/transact.dll'; + + /** + * Holds all the x_* name/values that will be posted in the request. + * Default values are provided for best practice fields. + */ + protected $_x_post_fields = array( + "version" => "3.1", + "delim_char" => ",", + "delim_data" => "TRUE", + "relay_response" => "FALSE", + "encap_char" => "|", + ); + + /** + * Only used if merchant wants to send multiple line items about the charge. + */ + private $_additional_line_items = array(); + + /** + * Only used if merchant wants to send custom fields. + */ + private $_custom_fields = array(); + + /** + * Checks to make sure a field is actually in the API before setting. + * Set to false to skip this check. + */ + public $verify_x_fields = true; + + /** + * A list of all fields in the AIM API. + * Used to warn user if they try to set a field not offered in the API. + */ + private $_all_aim_fields = array("address","allow_partial_auth","amount", + "auth_code","authentication_indicator", "bank_aba_code","bank_acct_name", + "bank_acct_num","bank_acct_type","bank_check_number","bank_name", + "card_code","card_num","cardholder_authentication_value","city","company", + "country","cust_id","customer_ip","delim_char","delim_data","description", + "duplicate_window","duty","echeck_type","email","email_customer", + "encap_char","exp_date","fax","first_name","footer_email_receipt", + "freight","header_email_receipt","invoice_num","last_name","line_item", + "login","method","phone","po_num","recurring_billing","relay_response", + "ship_to_address","ship_to_city","ship_to_company","ship_to_country", + "ship_to_first_name","ship_to_last_name","ship_to_state","ship_to_zip", + "split_tender_id","state","tax","tax_exempt","test_request","tran_key", + "trans_id","type","version","zip" + ); + + /** + * Do an AUTH_CAPTURE transaction. + * + * Required "x_" fields: card_num, exp_date, amount + * + * @param string $amount The dollar amount to charge + * @param string $card_num The credit card number + * @param string $exp_date CC expiration date + * + * @return AuthorizeNetAIM_Response + */ + public function authorizeAndCapture($amount = false, $card_num = false, $exp_date = false) + { + ($amount ? $this->amount = $amount : null); + ($card_num ? $this->card_num = $card_num : null); + ($exp_date ? $this->exp_date = $exp_date : null); + $this->type = "AUTH_CAPTURE"; + return $this->_sendRequest(); + } + + /** + * Do a PRIOR_AUTH_CAPTURE transaction. + * + * Required "x_" field: trans_id(The transaction id of the prior auth, unless split + * tender, then set x_split_tender_id manually.) + * amount (only if lesser than original auth) + * + * @param string $trans_id Transaction id to charge + * @param string $amount Dollar amount to charge if lesser than auth + * + * @return AuthorizeNetAIM_Response + */ + public function priorAuthCapture($trans_id = false, $amount = false) + { + ($trans_id ? $this->trans_id = $trans_id : null); + ($amount ? $this->amount = $amount : null); + $this->type = "PRIOR_AUTH_CAPTURE"; + return $this->_sendRequest(); + } + + /** + * Do an AUTH_ONLY transaction. + * + * Required "x_" fields: card_num, exp_date, amount + * + * @param string $amount The dollar amount to charge + * @param string $card_num The credit card number + * @param string $exp_date CC expiration date + * + * @return AuthorizeNetAIM_Response + */ + public function authorizeOnly($amount = false, $card_num = false, $exp_date = false) + { + ($amount ? $this->amount = $amount : null); + ($card_num ? $this->card_num = $card_num : null); + ($exp_date ? $this->exp_date = $exp_date : null); + $this->type = "AUTH_ONLY"; + return $this->_sendRequest(); + } + + /** + * Do a VOID transaction. + * + * Required "x_" field: trans_id(The transaction id of the prior auth, unless split + * tender, then set x_split_tender_id manually.) + * + * @param string $trans_id Transaction id to void + * + * @return AuthorizeNetAIM_Response + */ + public function void($trans_id = false) + { + ($trans_id ? $this->trans_id = $trans_id : null); + $this->type = "VOID"; + return $this->_sendRequest(); + } + + /** + * Do a CAPTURE_ONLY transaction. + * + * Required "x_" fields: auth_code, amount, card_num , exp_date + * + * @param string $auth_code The auth code + * @param string $amount The dollar amount to charge + * @param string $card_num The last 4 of credit card number + * @param string $exp_date CC expiration date + * + * @return AuthorizeNetAIM_Response + */ + public function captureOnly($auth_code = false, $amount = false, $card_num = false, $exp_date = false) + { + ($auth_code ? $this->auth_code = $auth_code : null); + ($amount ? $this->amount = $amount : null); + ($card_num ? $this->card_num = $card_num : null); + ($exp_date ? $this->exp_date = $exp_date : null); + $this->type = "CAPTURE_ONLY"; + return $this->_sendRequest(); + } + + /** + * Do a CREDIT transaction. + * + * Required "x_" fields: trans_id, amount, card_num (just the last 4) + * + * @param string $trans_id Transaction id to credit + * @param string $amount The dollar amount to credit + * @param string $card_num The last 4 of credit card number + * + * @return AuthorizeNetAIM_Response + */ + public function credit($trans_id = false, $amount = false, $card_num = false) + { + ($trans_id ? $this->trans_id = $trans_id : null); + ($amount ? $this->amount = $amount : null); + ($card_num ? $this->card_num = $card_num : null); + $this->type = "CREDIT"; + return $this->_sendRequest(); + } + + /** + * Alternative syntax for setting x_ fields. + * + * Usage: $sale->method = "echeck"; + * + * @param string $name + * @param string $value + */ + public function __set($name, $value) + { + $this->setField($name, $value); + } + + /** + * Quickly set multiple fields. + * + * Note: The prefix x_ will be added to all fields. If you want to set a + * custom field without the x_ prefix, use setCustomField or setCustomFields. + * + * @param array $fields Takes an array or object. + */ + public function setFields($fields) + { + $array = (array)$fields; + foreach ($array as $key => $value) { + $this->setField($key, $value); + } + } + + /** + * Quickly set multiple custom fields. + * + * @param array $fields + */ + public function setCustomFields($fields) + { + $array = (array)$fields; + foreach ($array as $key => $value) { + $this->setCustomField($key, $value); + } + } + + /** + * Add a line item. + * + * @param string $item_id + * @param string $item_name + * @param string $item_description + * @param string $item_quantity + * @param string $item_unit_price + * @param string $item_taxable + */ + public function addLineItem($item_id, $item_name, $item_description, $item_quantity, $item_unit_price, $item_taxable) + { + $line_item = ""; + $delimiter = ""; + foreach (func_get_args() as $key => $value) { + $line_item .= $delimiter . $value; + $delimiter = "<|>"; + } + $this->_additional_line_items[] = $line_item; + } + + /** + * Use ECHECK as payment type. + */ + public function setECheck($bank_aba_code, $bank_acct_num, $bank_acct_type, $bank_name, $bank_acct_name, $echeck_type = 'WEB') + { + $this->setFields( + array( + 'method' => 'echeck', + 'bank_aba_code' => $bank_aba_code, + 'bank_acct_num' => $bank_acct_num, + 'bank_acct_type' => $bank_acct_type, + 'bank_name' => $bank_name, + 'bank_acct_name' => $bank_acct_type, + 'echeck_type' => $echeck_type, + ) + ); + } + + /** + * Set an individual name/value pair. This will append x_ to the name + * before posting. + * + * @param string $name + * @param string $value + */ + public function setField($name, $value) + { + if ($this->verify_x_fields) { + if (in_array($name, $this->_all_aim_fields)) { + $this->_x_post_fields[$name] = $value; + } else { + throw new AuthorizeNetException("Error: no field $name exists in the AIM API. + To set a custom field use setCustomField('field','value') instead."); + } + } else { + $this->_x_post_fields[$name] = $value; + } + } + + /** + * Set a custom field. Note: the x_ prefix will not be added to + * your custom field if you use this method. + * + * @param string $name + * @param string $value + */ + public function setCustomField($name, $value) + { + $this->_custom_fields[$name] = $value; + } + + /** + * Unset an x_ field. + * + * @param string $name Field to unset. + */ + public function unsetField($name) + { + unset($this->_x_post_fields[$name]); + } + + /** + * + * + * @param string $response + * + * @return AuthorizeNetAIM_Response + */ + protected function _handleResponse($response) + { + return new AuthorizeNetAIM_Response($response, $this->_x_post_fields['delim_char'], $this->_x_post_fields['encap_char'], $this->_custom_fields); + } + + /** + * @return string + */ + protected function _getPostUrl() + { + return ($this->_sandbox ? self::SANDBOX_URL : self::LIVE_URL); + } + + /** + * Converts the x_post_fields array into a string suitable for posting. + */ + protected function _setPostString() + { + $this->_x_post_fields['login'] = $this->_api_login; + $this->_x_post_fields['tran_key'] = $this->_transaction_key; + $this->_post_string = ""; + foreach ($this->_x_post_fields as $key => $value) { + $this->_post_string .= "x_$key=" . urlencode($value) . "&"; + } + // Add line items + foreach ($this->_additional_line_items as $key => $value) { + $this->_post_string .= "x_line_item=" . urlencode($value) . "&"; + } + // Add custom fields + foreach ($this->_custom_fields as $key => $value) { + $this->_post_string .= "$key=" . urlencode($value) . "&"; + } + $this->_post_string = rtrim($this->_post_string, "& "); + } +} + +/** + * Parses an AuthorizeNet AIM Response. + * + * @package AuthorizeNet + * @subpackage AuthorizeNetAIM + */ +class AuthorizeNetAIM_Response extends AuthorizeNetResponse +{ + private $_response_array = array(); // An array with the split response. + + /** + * Constructor. Parses the AuthorizeNet response string. + * + * @param string $response The response from the AuthNet server. + * @param string $delimiter The delimiter used (default is ",") + * @param string $encap_char The encap_char used (default is "|") + * @param array $custom_fields Any custom fields set in the request. + */ + public function __construct($response, $delimiter, $encap_char, $custom_fields) + { + if ($response) { + + // Split Array + $this->response = $response; + if ($encap_char) { + $this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1)); + } else { + $this->_response_array = explode($delimiter, $response); + } + + /** + * If AuthorizeNet doesn't return a delimited response. + */ + if (count($this->_response_array) < 10) { + $this->approved = false; + $this->error = true; + $this->error_message = "Unrecognized response from AuthorizeNet: $response"; + return; + } + + + + // Set all fields + $this->response_code = $this->_response_array[0]; + $this->response_subcode = $this->_response_array[1]; + $this->response_reason_code = $this->_response_array[2]; + $this->response_reason_text = $this->_response_array[3]; + $this->authorization_code = $this->_response_array[4]; + $this->avs_response = $this->_response_array[5]; + $this->transaction_id = $this->_response_array[6]; + $this->invoice_num = $this->_response_array[7]; + $this->description = $this->_response_array[8]; + $this->amount = $this->_response_array[9]; + $this->method = $this->_response_array[10]; + $this->transaction_type = $this->_response_array[11]; + $this->customer_id = $this->_response_array[12]; + $this->first_name = $this->_response_array[13]; + $this->last_name = $this->_response_array[14]; + $this->company = $this->_response_array[15]; + $this->address = $this->_response_array[16]; + $this->city = $this->_response_array[17]; + $this->state = $this->_response_array[18]; + $this->zip_code = $this->_response_array[19]; + $this->country = $this->_response_array[20]; + $this->phone = $this->_response_array[21]; + $this->fax = $this->_response_array[22]; + $this->email_address = $this->_response_array[23]; + $this->ship_to_first_name = $this->_response_array[24]; + $this->ship_to_last_name = $this->_response_array[25]; + $this->ship_to_company = $this->_response_array[26]; + $this->ship_to_address = $this->_response_array[27]; + $this->ship_to_city = $this->_response_array[28]; + $this->ship_to_state = $this->_response_array[29]; + $this->ship_to_zip_code = $this->_response_array[30]; + $this->ship_to_country = $this->_response_array[31]; + $this->tax = $this->_response_array[32]; + $this->duty = $this->_response_array[33]; + $this->freight = $this->_response_array[34]; + $this->tax_exempt = $this->_response_array[35]; + $this->purchase_order_number= $this->_response_array[36]; + $this->md5_hash = $this->_response_array[37]; + $this->card_code_response = $this->_response_array[38]; + $this->cavv_response = $this->_response_array[39]; + $this->account_number = $this->_response_array[50]; + $this->card_type = $this->_response_array[51]; + $this->split_tender_id = $this->_response_array[52]; + $this->requested_amount = $this->_response_array[53]; + $this->balance_on_card = $this->_response_array[54]; + + $this->approved = ($this->response_code == self::APPROVED); + $this->declined = ($this->response_code == self::DECLINED); + $this->error = ($this->response_code == self::ERROR); + $this->held = ($this->response_code == self::HELD); + + // Set custom fields + if ($count = count($custom_fields)) { + $custom_fields_response = array_slice($this->_response_array, -$count, $count); + $i = 0; + foreach ($custom_fields as $key => $value) { + $this->$key = $custom_fields_response[$i]; + $i++; + } + } + + if ($this->error) { + $this->error_message = "AuthorizeNet Error: + Response Code: ".$this->response_code." + Response Subcode: ".$this->response_subcode." + Response Reason Code: ".$this->response_reason_code." + Response Reason Text: ".$this->response_reason_text." + "; + } + } else { + $this->approved = false; + $this->error = true; + $this->error_message = "Error connecting to AuthorizeNet"; + } + } + +} diff --git a/anet_php_sdk/lib/AuthorizeNetARB.php b/anet_php_sdk/lib/AuthorizeNetARB.php new file mode 100755 index 0000000..8df101a --- /dev/null +++ b/anet_php_sdk/lib/AuthorizeNetARB.php @@ -0,0 +1,159 @@ +_request_payload = ($refId ? "$refId" : ""); + } + + /** + * Create an ARB subscription + * + * @param AuthorizeNet_Subscription $subscription + * + * @return AuthorizeNetARB_Response + */ + public function createSubscription(AuthorizeNet_Subscription $subscription) + { + $this->_request_type = "CreateSubscriptionRequest"; + $this->_request_payload .= $subscription->getXml(); + return $this->_sendRequest(); + } + + /** + * Update an ARB subscription + * + * @param int $subscriptionId + * @param AuthorizeNet_Subscription $subscription + * + * @return AuthorizeNetARB_Response + */ + public function updateSubscription($subscriptionId, AuthorizeNet_Subscription $subscription) + { + $this->_request_type = "UpdateSubscriptionRequest"; + $this->_request_payload .= "$subscriptionId"; + $this->_request_payload .= $subscription->getXml(); + return $this->_sendRequest(); + } + + /** + * Get status of a subscription + * + * @param int $subscriptionId + * + * @return AuthorizeNetARB_Response + */ + public function getSubscriptionStatus($subscriptionId) + { + $this->_request_type = "GetSubscriptionStatusRequest"; + $this->_request_payload .= "$subscriptionId"; + return $this->_sendRequest(); + } + + /** + * Cancel a subscription + * + * @param int $subscriptionId + * + * @return AuthorizeNetARB_Response + */ + public function cancelSubscription($subscriptionId) + { + $this->_request_type = "CancelSubscriptionRequest"; + $this->_request_payload .= "$subscriptionId"; + return $this->_sendRequest(); + } + + /** + * + * + * @param string $response + * + * @return AuthorizeNetARB_Response + */ + protected function _handleResponse($response) + { + return new AuthorizeNetARB_Response($response); + } + + /** + * @return string + */ + protected function _getPostUrl() + { + return ($this->_sandbox ? self::SANDBOX_URL : self::LIVE_URL); + } + + /** + * Prepare the XML document for posting. + */ + protected function _setPostString() + { + $this->_post_string =<< +_request_type} xmlns= "AnetApi/xml/v1/schema/AnetApiSchema.xsd"> + + {$this->_api_login} + {$this->_transaction_key} + + {$this->_request_payload} +_request_type}> +XML; + } + +} + + +/** + * A class to parse a response from the ARB XML API. + * + * @package AuthorizeNet + * @subpackage AuthorizeNetARB + */ +class AuthorizeNetARB_Response extends AuthorizeNetXMLResponse +{ + + /** + * @return int + */ + public function getSubscriptionId() + { + return $this->_getElementContents("subscriptionId"); + } + + /** + * @return string + */ + public function getSubscriptionStatus() + { + return $this->_getElementContents("Status"); + } + +} \ No newline at end of file diff --git a/anet_php_sdk/lib/AuthorizeNetCIM.php b/anet_php_sdk/lib/AuthorizeNetCIM.php new file mode 100755 index 0000000..eb44342 --- /dev/null +++ b/anet_php_sdk/lib/AuthorizeNetCIM.php @@ -0,0 +1,511 @@ +_refId = $refId; + } + + /** + * Create a customer profile. + * + * @param AuthorizeNetCustomer $customerProfile + * @param string $validationMode + * + * @return AuthorizeNetCIM_Response + */ + public function createCustomerProfile($customerProfile, $validationMode = "none") + { + $this->_validationMode = $validationMode; + $this->_constructXml("createCustomerProfileRequest"); + $profile = $this->_xml->addChild("profile"); + $this->_addObject($profile, $customerProfile); + return $this->_sendRequest(); + } + + /** + * Create a customer payment profile. + * + * @param int $customerProfileId + * @param AuthorizeNetPaymentProfile $paymentProfile + * @param string $validationMode + * + * @return AuthorizeNetCIM_Response + */ + public function createCustomerPaymentProfile($customerProfileId, $paymentProfile, $validationMode = "none") + { + $this->_validationMode = $validationMode; + $this->_constructXml("createCustomerPaymentProfileRequest"); + $this->_xml->addChild("customerProfileId", $customerProfileId); + $profile = $this->_xml->addChild("paymentProfile"); + $this->_addObject($profile, $paymentProfile); + return $this->_sendRequest(); + } + + /** + * Create a shipping address. + * + * @param int $customerProfileId + * @param AuthorizeNetAddress $shippingAddress + * + * @return AuthorizeNetCIM_Response + */ + public function createCustomerShippingAddress($customerProfileId, $shippingAddress) + { + $this->_constructXml("createCustomerShippingAddressRequest"); + $this->_xml->addChild("customerProfileId", $customerProfileId); + $address = $this->_xml->addChild("address"); + $this->_addObject($address, $shippingAddress); + return $this->_sendRequest(); + } + + /** + * Create a transaction. + * + * @param string $transactionType + * @param AuthorizeNetTransaction $transaction + * @param string $extraOptionsString + * + * @return AuthorizeNetCIM_Response + */ + public function createCustomerProfileTransaction($transactionType, $transaction, $extraOptionsString = "") + { + $this->_constructXml("createCustomerProfileTransactionRequest"); + $transactionParent = $this->_xml->addChild("transaction"); + $transactionChild = $transactionParent->addChild("profileTrans" . $transactionType); + $this->_addObject($transactionChild, $transaction); + $this->_extraOptions = $extraOptionsString; + return $this->_sendRequest(); + } + + /** + * Delete a customer profile. + * + * @param int $customerProfileId + * + * @return AuthorizeNetCIM_Response + */ + public function deleteCustomerProfile($customerProfileId) + { + $this->_constructXml("deleteCustomerProfileRequest"); + $this->_xml->addChild("customerProfileId", $customerProfileId); + return $this->_sendRequest(); + } + + /** + * Delete a payment profile. + * + * @param int $customerProfileId + * @param int $customerPaymentProfileId + * + * @return AuthorizeNetCIM_Response + */ + public function deleteCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId) + { + $this->_constructXml("deleteCustomerPaymentProfileRequest"); + $this->_xml->addChild("customerProfileId", $customerProfileId); + $this->_xml->addChild("customerPaymentProfileId", $customerPaymentProfileId); + return $this->_sendRequest(); + } + + /** + * Delete a shipping address. + * + * @param int $customerProfileId + * @param int $customerAddressId + * + * @return AuthorizeNetCIM_Response + */ + public function deleteCustomerShippingAddress($customerProfileId, $customerAddressId) + { + $this->_constructXml("deleteCustomerShippingAddressRequest"); + $this->_xml->addChild("customerProfileId", $customerProfileId); + $this->_xml->addChild("customerAddressId", $customerAddressId); + return $this->_sendRequest(); + } + + /** + * Get all customer profile ids. + * + * @return AuthorizeNetCIM_Response + */ + public function getCustomerProfileIds() + { + $this->_constructXml("getCustomerProfileIdsRequest"); + return $this->_sendRequest(); + } + + /** + * Get a customer profile. + * + * @param int $customerProfileId + * + * @return AuthorizeNetCIM_Response + */ + public function getCustomerProfile($customerProfileId) + { + $this->_constructXml("getCustomerProfileRequest"); + $this->_xml->addChild("customerProfileId", $customerProfileId); + return $this->_sendRequest(); + } + + /** + * Get a payment profile. + * + * @param int $customerProfileId + * @param int $customerPaymentProfileId + * + * @return AuthorizeNetCIM_Response + */ + public function getCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId) + { + $this->_constructXml("getCustomerPaymentProfileRequest"); + $this->_xml->addChild("customerProfileId", $customerProfileId); + $this->_xml->addChild("customerPaymentProfileId", $customerPaymentProfileId); + return $this->_sendRequest(); + } + + /** + * Get a shipping address. + * + * @param int $customerProfileId + * @param int $customerAddressId + * + * @return AuthorizeNetCIM_Response + */ + public function getCustomerShippingAddress($customerProfileId, $customerAddressId) + { + $this->_constructXml("getCustomerShippingAddressRequest"); + $this->_xml->addChild("customerProfileId", $customerProfileId); + $this->_xml->addChild("customerAddressId", $customerAddressId); + return $this->_sendRequest(); + } + + /** + * Update a profile. + * + * @param int $customerProfileId + * @param AuthorizeNetCustomer $customerProfile + * + * @return AuthorizeNetCIM_Response + */ + public function updateCustomerProfile($customerProfileId, $customerProfile) + { + $this->_constructXml("updateCustomerProfileRequest"); + $customerProfile->customerProfileId = $customerProfileId; + $profile = $this->_xml->addChild("profile"); + $this->_addObject($profile, $customerProfile); + return $this->_sendRequest(); + } + + /** + * Update a payment profile. + * + * @param int $customerProfileId + * @param int $customerPaymentProfileId + * @param AuthorizeNetPaymentProfile $paymentProfile + * @param string $validationMode + * + * @return AuthorizeNetCIM_Response + */ + public function updateCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId, $paymentProfile, $validationMode = "none") + { + $this->_validationMode = $validationMode; + $this->_constructXml("updateCustomerPaymentProfileRequest"); + $this->_xml->addChild("customerProfileId", $customerProfileId); + $paymentProfile->customerPaymentProfileId = $customerPaymentProfileId; + $profile = $this->_xml->addChild("paymentProfile"); + $this->_addObject($profile, $paymentProfile); + return $this->_sendRequest(); + } + + /** + * Update a shipping address. + * + * @param int $customerProfileId + * @param int $customerShippingAddressId + * @param AuthorizeNetAddress $shippingAddress + * + * @return AuthorizeNetCIM_Response + */ + public function updateCustomerShippingAddress($customerProfileId, $customerShippingAddressId, $shippingAddress) + { + + $this->_constructXml("updateCustomerShippingAddressRequest"); + $this->_xml->addChild("customerProfileId", $customerProfileId); + $shippingAddress->customerAddressId = $customerShippingAddressId; + $sa = $this->_xml->addChild("address"); + $this->_addObject($sa, $shippingAddress); + return $this->_sendRequest(); + } + + /** + * Update the status of an existing order that contains multiple transactions with the same splitTenderId. + * + * @param int $splitTenderId + * @param string $splitTenderStatus + * + * @return AuthorizeNetCIM_Response + */ + public function updateSplitTenderGroup($splitTenderId, $splitTenderStatus) + { + $this->_constructXml("updateSplitTenderGroupRequest"); + $this->_xml->addChild("splitTenderId", $splitTenderId); + $this->_xml->addChild("splitTenderStatus", $splitTenderStatus); + return $this->_sendRequest(); + } + + /** + * Validate a customer payment profile. + * + * @param int $customerProfileId + * @param int $customerPaymentProfileId + * @param int $customerShippingAddressId + * @param int $cardCode + * @param string $validationMode + * + * @return AuthorizeNetCIM_Response + */ + public function validateCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId, $customerShippingAddressId, $cardCode, $validationMode = "testMode") + { + $this->_validationMode = $validationMode; + $this->_constructXml("validateCustomerPaymentProfileRequest"); + $this->_xml->addChild("customerProfileId",$customerProfileId); + $this->_xml->addChild("customerPaymentProfileId",$customerPaymentProfileId); + $this->_xml->addChild("customerShippingAddressId",$customerShippingAddressId); + $this->_xml->addChild("cardCode",$cardCode); + return $this->_sendRequest(); + } + + /** + * @return string + */ + protected function _getPostUrl() + { + return ($this->_sandbox ? self::SANDBOX_URL : self::LIVE_URL); + } + + /** + * + * + * @param string $response + * + * @return AuthorizeNetCIM_Response + */ + protected function _handleResponse($response) + { + return new AuthorizeNetCIM_Response($response); + } + + /** + * Prepare the XML post string. + */ + protected function _setPostString() + { + ($this->_validationMode != "none" ? $this->_xml->addChild('validationMode',$this->_validationMode) : ""); + $this->_post_string = $this->_xml->asXML(); + + // Add extraOptions CDATA + if ($this->_extraOptions) { + $this->_xml->addChild("extraOptions"); + $this->_post_string = str_replace("",'_extraOptions . ']]>', $this->_xml->asXML()); + $this->_extraOptions = false; + } + // Blank out our validation mode, so that we don't include it in calls that + // don't use it. + $this->_validationMode = "none"; + } + + /** + * Start the SimpleXMLElement that will be posted. + * + * @param string $request_type The action to be performed. + */ + private function _constructXml($request_type) + { + $string = '<'.$request_type.' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">'; + $this->_xml = @new SimpleXMLElement($string); + $merchant = $this->_xml->addChild('merchantAuthentication'); + $merchant->addChild('name',$this->_api_login); + $merchant->addChild('transactionKey',$this->_transaction_key); + ($this->_refId ? $this->_xml->addChild('refId',$this->_refId) : ""); + } + + /** + * Add an object to an SimpleXMLElement parent element. + * + * @param SimpleXMLElement $destination The parent element. + * @param Object $object An object, array or value. + */ + private function _addObject($destination, $object) + { + $array = (array)$object; + foreach ($array as $key => $value) { + if ($value && !is_object($value)) { + if (is_array($value) && count($value)) { + foreach ($value as $index => $item) { + $items = $destination->addChild($key); + $this->_addObject($items, $item); + } + } else { + $destination->addChild($key,$value); + } + } elseif (is_object($value) && self::_notEmpty($value)) { + $dest = $destination->addChild($key); + $this->_addObject($dest, $value); + } + } + } + + /** + * Checks whether an array or object contains any values. + * + * @param Object $object + * + * @return bool + */ + private static function _notEmpty($object) + { + $array = (array)$object; + foreach ($array as $key => $value) { + if ($value && !is_object($value)) { + return true; + } elseif (is_object($value)) { + if (self::_notEmpty($value)) { + return true; + } + } + } + return false; + } + +} + +/** + * A class to parse a response from the CIM XML API. + * + * @package AuthorizeNet + * @subpackage AuthorizeNetCIM + */ +class AuthorizeNetCIM_Response extends AuthorizeNetXMLResponse +{ + /** + * @return AuthorizeNetAIM_Response + */ + public function getTransactionResponse() + { + return new AuthorizeNetAIM_Response($this->_getElementContents("directResponse"), ",", "", array()); + } + + /** + * @return array Array of AuthorizeNetAIM_Response objects for each payment profile. + */ + public function getValidationResponses() + { + $responses = (array)$this->xml->validationDirectResponseList; + $return = array(); + foreach ((array)$responses["string"] as $response) { + $return[] = new AuthorizeNetAIM_Response($response, ",", "", array()); + } + return $return; + } + + /** + * @return AuthorizeNetAIM_Response + */ + public function getValidationResponse() + { + return new AuthorizeNetAIM_Response($this->_getElementContents("validationDirectResponse"), ",", "", array()); + } + + /** + * @return array + */ + public function getCustomerProfileIds() + { + $ids = (array)$this->xml->ids; + return $ids["numericString"]; + } + + /** + * @return array + */ + public function getCustomerPaymentProfileIds() + { + $ids = (array)$this->xml->customerPaymentProfileIdList; + return $ids["numericString"]; + } + + /** + * @return array + */ + public function getCustomerShippingAddressIds() + { + $ids = (array)$this->xml->customerShippingAddressIdList; + return $ids["numericString"]; + } + + /** + * @return string + */ + public function getCustomerAddressId() + { + return $this->_getElementContents("customerAddressId"); + } + + /** + * @return string + */ + public function getCustomerProfileId() + { + return $this->_getElementContents("customerProfileId"); + } + + /** + * @return string + */ + public function getPaymentProfileId() + { + return $this->_getElementContents("customerPaymentProfileId"); + } + +} diff --git a/anet_php_sdk/lib/AuthorizeNetCP.php b/anet_php_sdk/lib/AuthorizeNetCP.php new file mode 100755 index 0000000..1ff0a3d --- /dev/null +++ b/anet_php_sdk/lib/AuthorizeNetCP.php @@ -0,0 +1,222 @@ + "1.0", + "delim_char" => ",", + "encap_char" => "|", + "market_type" => "2", + "response_format" => "1", // 0 - XML, 1 - NVP + ); + + /** + * Device Types (x_device_type) + * 1 = Unknown + * 2 = Unattended Terminal + * 3 = Self Service Terminal + * 4 = Electronic Cash Register + * 5 = Personal Computer- Based Terminal + * 6 = AirPay + * 7 = Wireless POS + * 8 = Website + * 9 = Dial Terminal + * 10 = Virtual Terminal + */ + + /** + * Strip sentinels and set track1 field. + * + * @param string $track1data + */ + public function setTrack1Data($track1data) { + if (preg_match('/^%.*\?$/', $track1data)) { + $this->track1 = substr($track1data, 1, -1); + } else { + $this->track1 = $track1data; + } + } + + /** + * Strip sentinels and set track2 field. + * + * @param string $track2data + */ + public function setTrack2Data($track2data) { + if (preg_match('/^;.*\?$/', $track2data)) { + $this->track2 = substr($track2data, 1, -1); + } else { + $this->track2 = $track2data; + } + } + + /** + * + * + * @param string $response + * + * @return AuthorizeNetAIM_Response + */ + protected function _handleResponse($response) + { + return new AuthorizeNetCP_Response($response, $this->_x_post_fields['delim_char'], $this->_x_post_fields['encap_char'], $this->_custom_fields); + } + +} + + +/** + * Parses an AuthorizeNet Card Present Response. + * + * @package AuthorizeNet + * @subpackage AuthorizeNetCP + */ +class AuthorizeNetCP_Response extends AuthorizeNetResponse +{ + private $_response_array = array(); // An array with the split response. + + /** + * Constructor. Parses the AuthorizeNet response string. + * + * @param string $response The response from the AuthNet server. + * @param string $delimiter The delimiter used (default is ",") + * @param string $encap_char The encap_char used (default is "|") + * @param array $custom_fields Any custom fields set in the request. + */ + public function __construct($response, $delimiter, $encap_char, $custom_fields) + { + if ($response) { + + // If it's an XML response + if (substr($response, 0, 5) == "xml = @simplexml_load_string($response); + // Set all fields + $this->version = array_pop(array_slice(explode('"', $response), 1,1)); + $this->response_code = (string)$this->xml->ResponseCode; + + if ($this->response_code == 1) { + $this->response_reason_code = (string)$this->xml->Messages->Message->Code; + $this->response_reason_text = (string)$this->xml->Messages->Message->Description; + } else { + $this->response_reason_code = (string)$this->xml->Errors->Error->ErrorCode; + $this->response_reason_text = (string)$this->xml->Errors->Error->ErrorText; + } + + $this->authorization_code = (string)$this->xml->AuthCode; + $this->avs_code = (string)$this->xml->AVSResultCode; + $this->card_code_response = (string)$this->xml->CVVResultCode; + $this->transaction_id = (string)$this->xml->TransID; + $this->md5_hash = (string)$this->xml->TransHash; + $this->user_ref = (string)$this->xml->UserRef; + $this->card_num = (string)$this->xml->AccountNumber; + $this->card_type = (string)$this->xml->AccountType; + $this->test_mode = (string)$this->xml->TestMode; + $this->ref_trans_id = (string)$this->xml->RefTransID; + + + } else { // If it's an NVP response + + // Split Array + $this->response = $response; + if ($encap_char) { + $this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1)); + } else { + $this->_response_array = explode($delimiter, $response); + } + + /** + * If AuthorizeNet doesn't return a delimited response. + */ + if (count($this->_response_array) < 10) { + $this->approved = false; + $this->error = true; + $this->error_message = "Unrecognized response from AuthorizeNet: $response"; + return; + } + + + + // Set all fields + $this->version = $this->_response_array[0]; + $this->response_code = $this->_response_array[1]; + $this->response_reason_code = $this->_response_array[2]; + $this->response_reason_text = $this->_response_array[3]; + $this->authorization_code = $this->_response_array[4]; + $this->avs_code = $this->_response_array[5]; + $this->card_code_response = $this->_response_array[6]; + $this->transaction_id = $this->_response_array[7]; + $this->md5_hash = $this->_response_array[8]; + $this->user_ref = $this->_response_array[9]; + $this->card_num = $this->_response_array[20]; + $this->card_type = $this->_response_array[21]; + $this->split_tender_id = $this->_response_array[22]; + $this->requested_amount = $this->_response_array[23]; + $this->approved_amount = $this->_response_array[24]; + $this->card_balance = $this->_response_array[25]; + + + + } + $this->approved = ($this->response_code == self::APPROVED); + $this->declined = ($this->response_code == self::DECLINED); + $this->error = ($this->response_code == self::ERROR); + $this->held = ($this->response_code == self::HELD); + + + if ($this->error) { + $this->error_message = "AuthorizeNet Error: + Response Code: ".$this->response_code." + Response Reason Code: ".$this->response_reason_code." + Response Reason Text: ".$this->response_reason_text." + "; + } + + } else { + $this->approved = false; + $this->error = true; + $this->error_message = "Error connecting to AuthorizeNet"; + } + } + + /** + * Is the MD5 provided correct? + * + * @param string $api_login_id + * @param string $md5_setting + * @return bool + */ + public function isAuthorizeNet($api_login_id = false, $md5_setting = false) + { + $amount = ($this->amount ? $this->amount : '0.00'); + $api_login_id = ($api_login_id ? $api_login_id : AUTHORIZENET_API_LOGIN_ID); + $md5_setting = ($md5_setting ? $md5_setting : AUTHORIZENET_MD5_SETTING); + return ($this->md5_hash == strtoupper(md5($md5_setting . $api_login_id . $this->transaction_id . $amount))); + } + +} + diff --git a/anet_php_sdk/lib/AuthorizeNetDPM.php b/anet_php_sdk/lib/AuthorizeNetDPM.php new file mode 100755 index 0000000..5e693cc --- /dev/null +++ b/anet_php_sdk/lib/AuthorizeNetDPM.php @@ -0,0 +1,237 @@ +isAuthorizeNet()) + { + if ($response->approved) + { + // Do your processing here. + $redirect_url = $url . '?response_code=1&transaction_id=' . $response->transaction_id; + } + else + { + // Redirect to error page. + $redirect_url = $url . '?response_code='.$response->response_code . '&response_reason_text=' . $response->response_reason_text; + } + // Send the Javascript back to AuthorizeNet, which will redirect user back to your site. + echo AuthorizeNetDPM::getRelayResponseSnippet($redirect_url); + } + else + { + echo "Error -- not AuthorizeNet. Check your MD5 Setting."; + } + } + // Step 3: Show receipt page to customer. + elseif (!count($_POST) && count($_GET)) + { + if ($_GET['response_code'] == 1) + { + echo "Thank you for your purchase! Transaction id: " . htmlentities($_GET['transaction_id']); + } + else + { + echo "Sorry, an error occurred: " . htmlentities($_GET['response_reason_text']); + } + } + } + + /** + * A snippet to send to AuthorizeNet to redirect the user back to the + * merchant's server. Use this on your relay response page. + * + * @param string $redirect_url Where to redirect the user. + * + * @return string + */ + public static function getRelayResponseSnippet($redirect_url) + { + return " + "; + } + + /** + * Generate a sample form for use in a demo Direct Post implementation. + * + * @param string $amount Amount of the transaction. + * @param string $fp_sequence Sequential number(ie. Invoice #) + * @param string $relay_response_url The Relay Response URL + * @param string $api_login_id Your API Login ID + * @param string $transaction_key Your API Tran Key. + * @param bool $test_mode Use the sandbox? + * @param bool $prefill Prefill sample values(for test purposes). + * + * @return string + */ + public static function getCreditCardForm($amount, $fp_sequence, $relay_response_url, $api_login_id, $transaction_key, $test_mode = true, $prefill = true) + { + $time = time(); + $fp = self::getFingerprint($api_login_id, $transaction_key, $amount, $fp_sequence, $time); + $sim = new AuthorizeNetSIM_Form( + array( + 'x_amount' => $amount, + 'x_fp_sequence' => $fp_sequence, + 'x_fp_hash' => $fp, + 'x_fp_timestamp' => $time, + 'x_relay_response'=> "TRUE", + 'x_relay_url' => $relay_response_url, + 'x_login' => $api_login_id, + ) + ); + $hidden_fields = $sim->getHiddenFieldString(); + $post_url = ($test_mode ? self::SANDBOX_URL : self::LIVE_URL); + + $form = ' + +
+ '.$hidden_fields.' +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
'; + return $form; + } + +} \ No newline at end of file diff --git a/anet_php_sdk/lib/AuthorizeNetSIM.php b/anet_php_sdk/lib/AuthorizeNetSIM.php new file mode 100755 index 0000000..60297e5 --- /dev/null +++ b/anet_php_sdk/lib/AuthorizeNetSIM.php @@ -0,0 +1,212 @@ +api_login_id = ($api_login_id ? $api_login_id : (defined('AUTHORIZENET_API_LOGIN_ID') ? AUTHORIZENET_API_LOGIN_ID : "")); + $this->md5_setting = ($md5_setting ? $md5_setting : (defined('AUTHORIZENET_MD5_SETTING') ? AUTHORIZENET_MD5_SETTING : "")); + $this->response = $_POST; + + // Set fields without x_ prefix + foreach ($_POST as $key => $value) { + $name = substr($key, 2); + $this->$name = $value; + } + + // Set some human readable fields + $map = array( + 'avs_response' => 'x_avs_code', + 'authorization_code' => 'x_auth_code', + 'transaction_id' => 'x_trans_id', + 'customer_id' => 'x_cust_id', + 'md5_hash' => 'x_MD5_Hash', + 'card_code_response' => 'x_cvv2_resp_code', + 'cavv_response' => 'x_cavv_response', + ); + foreach ($map as $key => $value) { + $this->$key = (isset($_POST[$value]) ? $_POST[$value] : ""); + } + + $this->approved = ($this->response_code == self::APPROVED); + $this->declined = ($this->response_code == self::DECLINED); + $this->error = ($this->response_code == self::ERROR); + $this->held = ($this->response_code == self::HELD); + } + + /** + * Verify the request is AuthorizeNet. + * + * @return bool + */ + public function isAuthorizeNet() + { + return count($_POST) && $this->md5_hash && ($this->generateHash() == $this->md5_hash); + } + + /** + * Generates an Md5 hash to compare against Authorize.Net's. + * + * @return string Hash + */ + public function generateHash() + { + $amount = ($this->amount ? $this->amount : "0.00"); + return strtoupper(md5($this->md5_setting . $this->api_login_id . $this->transaction_id . $amount)); + } + +} + +/** + * A helper class for using hosted order page. + * + * @package AuthorizeNet + * @subpackage AuthorizeNetSIM + */ +class AuthorizeNetSIM_Form +{ + public $x_address; + public $x_amount; + public $x_background_url; + public $x_card_num; + public $x_city; + public $x_color_background; + public $x_color_link; + public $x_color_text; + public $x_company; + public $x_country; + public $x_cust_id; + public $x_customer_ip; + public $x_description; + public $x_delim_data; + public $x_duplicate_window; + public $x_duty; + public $x_email; + public $x_email_customer; + public $x_fax; + public $x_first_name; + public $x_footer_email_receipt; + public $x_footer_html_payment_form; + public $x_footer_html_receipt; + public $x_fp_hash; + public $x_fp_sequence; + public $x_fp_timestamp; + public $x_freight; + public $x_header_email_receipt; + public $x_header_html_payment_form; + public $x_header_html_receipt; + public $x_invoice_num; + public $x_last_name; + public $x_line_item; + public $x_login; + public $x_logo_url; + public $x_method; + public $x_phone; + public $x_po_num; + public $x_receipt_link_method; + public $x_receipt_link_text; + public $x_receipt_link_url; + public $x_recurring_billing; + public $x_relay_response; + public $x_relay_url; + public $x_rename; + public $x_ship_to_address; + public $x_ship_to_company; + public $x_ship_to_country; + public $x_ship_to_city; + public $x_ship_to_first_name; + public $x_ship_to_last_name; + public $x_ship_to_state; + public $x_ship_to_zip; + public $x_show_form; + public $x_state; + public $x_tax; + public $x_tax_exempt; + public $x_test_request; + public $x_trans_id; + public $x_type; + public $x_version; + public $x_zip; + + /** + * Constructor + * + * @param array $fields Fields to set. + */ + public function __construct($fields = false) + { + // Set some best practice fields + $this->x_relay_response = "FALSE"; + $this->x_version = "3.1"; + $this->x_delim_char = ","; + $this->x_delim_data = "TRUE"; + + if ($fields) { + foreach ($fields as $key => $value) { + $this->$key = $value; + } + } + } + + /** + * Get a string of HTML hidden fields for use in a form. + * + * @return string + */ + public function getHiddenFieldString() + { + $array = (array)$this; + $string = ""; + foreach ($array as $key => $value) { + if ($value) { + $string .= ''; + } + } + return $string; + } + + /** + * Generates a fingerprint needed for a hosted order form or DPM. + * + * @param string $api_login_id Login ID. + * @param string $transaction_key API key. + * @param string $amount Amount of transaction. + * @param string $fp_sequence An invoice number or random number. + * @param string $fp_timestamp Timestamp. + * + * @return string The fingerprint. + */ + public static function getFingerprint($api_login_id, $transaction_key, $amount, $fp_sequence, $fp_timestamp) + { + $api_login_id = ($api_login_id ? $api_login_id : (defined('AUTHORIZENET_API_LOGIN_ID') ? AUTHORIZENET_API_LOGIN_ID : "")); + $transaction_key = ($transaction_key ? $transaction_key : (defined('AUTHORIZENET_TRANSACTION_KEY') ? AUTHORIZENET_TRANSACTION_KEY : "")); + if (function_exists('hash_hmac')) { + return hash_hmac("md5", $api_login_id . "^" . $fp_sequence . "^" . $fp_timestamp . "^" . $amount . "^", $transaction_key); + } + return bin2hex(mhash(MHASH_MD5, $api_login_id . "^" . $fp_sequence . "^" . $fp_timestamp . "^" . $amount . "^", $transaction_key)); + } + +} \ No newline at end of file diff --git a/anet_php_sdk/lib/AuthorizeNetSOAP.php b/anet_php_sdk/lib/AuthorizeNetSOAP.php new file mode 100755 index 0000000..36c30a4 --- /dev/null +++ b/anet_php_sdk/lib/AuthorizeNetSOAP.php @@ -0,0 +1,99 @@ +__setLocation(self::SANDBOX_URL); + } + + /** + * Switch between the sandbox or production gateway. + * + * @param bool + */ + public function setSandbox($bool) + { + $this->__setLocation(($bool ? self::SANDBOX_URL : self::LIVE_URL)); + } + + /** + * Get all types as PHP Code. + * @return string + */ + public function getSoapTypes() + { + $string = ""; + $types = $this->__getTypes(); + foreach ($types as $type) { + if (preg_match("/struct /",$type)) { + $type = preg_replace("/struct /","class ",$type); + $type = preg_replace("/ (\w+) (\w+);/"," // $1\n public \$$2;",$type); + $string .= $type ."\n"; + } + } + return $string; + } + + /** + * Get all methods as PHP Code. + * @return string + */ + public function getSoapMethods() + { + $string = ""; + $functions = array(); + $methods = $this->__getFunctions(); + foreach ($methods as $index => $method) { + $sig = explode(" ", $method, 2); + if (!isset($functions[$sig[1]])) { + $string .= " /**\n * @return {$sig[0]}\n */\n public function {$sig[1]} {}\n\n"; + $functions[$sig[1]] = true; + } + } + return $string; + } + + /** + * Create a file from the WSDL for reference. + */ + public function saveSoapDocumentation($path) + { + $string = "getSoapMethods() . "\n}\n\n" . $this->getSoapTypes() ."\n\n ?>"; + return file_put_contents($path, $string); + } + + + +} \ No newline at end of file diff --git a/anet_php_sdk/lib/AuthorizeNetTD.php b/anet_php_sdk/lib/AuthorizeNetTD.php new file mode 100755 index 0000000..e98a6cd --- /dev/null +++ b/anet_php_sdk/lib/AuthorizeNetTD.php @@ -0,0 +1,209 @@ +_constructXml("getSettledBatchListRequest"); + ($includeStatistics ? + $this->_xml->addChild("includeStatistics", $includeStatistics) : null); + ($firstSettlementDate ? + $this->_xml->addChild("firstSettlementDate", $firstSettlementDate . $utc) : null); + ($lastSettlementDate ? + $this->_xml->addChild("lastSettlementDate", $lastSettlementDate . $utc) : null); + return $this->_sendRequest(); + } + + /** + * Return all settled batches for a certain month. + * + * @param int $month + * @param int $year + * + * @return AuthorizeNetTD_Response + */ + public function getSettledBatchListForMonth($month = false, $year = false) + { + $month = ($month ? $month : date('m')); + $year = ($year ? $year : date('Y')); + $firstSettlementDate = substr(date('c',mktime(0, 0, 0, $month, 1, $year)),0,-6); + $lastSettlementDate = substr(date('c',mktime(0, 0, 0, $month+1, 0, $year)),0,-6); + return $this->getSettledBatchList(true, $firstSettlementDate, $lastSettlementDate); + } + + /** + * This function returns limited transaction details for a specified batch ID + * + * @param int $batchId + * + * @return AuthorizeNetTD_Response + */ + public function getTransactionList($batchId) + { + $this->_constructXml("getTransactionListRequest"); + $this->_xml->addChild("batchId", $batchId); + return $this->_sendRequest(); + } + + /** + * Return all transactions for a certain day. + * + * @param int $month + * @param int $day + * @param int $year + * + * @return array Array of SimpleXMLElments + */ + public function getTransactionsForDay($month = false, $day = false, $year = false) + { + $transactions = array(); + $month = ($month ? $month : date('m')); + $day = ($day ? $day : date('d')); + $year = ($year ? $year : date('Y')); + $firstSettlementDate = substr(date('c',mktime(0, 0, 0, (int)$month, (int)$day, (int)$year)),0,-6); + $lastSettlementDate = substr(date('c',mktime(0, 0, 0, (int)$month, (int)$day, (int)$year)),0,-6); + $response = $this->getSettledBatchList(true, $firstSettlementDate, $lastSettlementDate); + $batches = $response->xpath("batchList/batch"); + foreach ($batches as $batch) { + $batch_id = (string)$batch->batchId; + $request = new AuthorizeNetTD; + $tran_list = $request->getTransactionList($batch_id); + $transactions = array_merge($transactions, $tran_list->xpath("transactions/transaction")); + } + return $transactions; + } + + /** + * This function returns full transaction details for a specified transaction ID. + * + * @param int $transId + * + * @return AuthorizeNetTD_Response + */ + public function getTransactionDetails($transId) + { + $this->_constructXml("getTransactionDetailsRequest"); + $this->_xml->addChild("transId", $transId); + return $this->_sendRequest(); + } + + /** + * This function returns statistics about the settled batch specified by $batchId. + * + * @param int $batchId + * + * @return AuthorizeNetTD_Response + */ + public function getBatchStatistics($batchId) + { + $this->_constructXml("getBatchStatisticsRequest"); + $this->_xml->addChild("batchId", $batchId); + return $this->_sendRequest(); + } + + /** + * This function returns the last 1000 unsettled transactions. + * + * + * @return AuthorizeNetTD_Response + */ + public function getUnsettledTransactionList() + { + $this->_constructXml("getUnsettledTransactionListRequest"); + return $this->_sendRequest(); + } + + /** + * @return string + */ + protected function _getPostUrl() + { + return ($this->_sandbox ? self::SANDBOX_URL : self::LIVE_URL); + } + + /** + * + * + * @param string $response + * + * @return AuthorizeNetTransactionDetails_Response + */ + protected function _handleResponse($response) + { + return new AuthorizeNetTD_Response($response); + } + + /** + * Prepare the XML post string. + */ + protected function _setPostString() + { + $this->_post_string = $this->_xml->asXML(); + + } + + /** + * Start the SimpleXMLElement that will be posted. + * + * @param string $request_type The action to be performed. + */ + private function _constructXml($request_type) + { + $string = '<'.$request_type.' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">'; + $this->_xml = @new SimpleXMLElement($string); + $merchant = $this->_xml->addChild('merchantAuthentication'); + $merchant->addChild('name',$this->_api_login); + $merchant->addChild('transactionKey',$this->_transaction_key); + } + +} + +/** + * A class to parse a response from the Transaction Details XML API. + * + * @package AuthorizeNet + * @subpackage AuthorizeNetTD + */ +class AuthorizeNetTD_Response extends AuthorizeNetXMLResponse +{ + + +} diff --git a/anet_php_sdk/lib/shared/AuthorizeNetRequest.php b/anet_php_sdk/lib/shared/AuthorizeNetRequest.php new file mode 100755 index 0000000..76d9dbf --- /dev/null +++ b/anet_php_sdk/lib/shared/AuthorizeNetRequest.php @@ -0,0 +1,120 @@ +_api_login = ($api_login_id ? $api_login_id : (defined('AUTHORIZENET_API_LOGIN_ID') ? AUTHORIZENET_API_LOGIN_ID : "9q52ab6YPsL")); + $this->_transaction_key = ($transaction_key ? $transaction_key : (defined('AUTHORIZENET_TRANSACTION_KEY') ? AUTHORIZENET_TRANSACTION_KEY : "728872Hz3aZ7Jqy9")); + $this->_sandbox = (defined('AUTHORIZENET_SANDBOX') ? AUTHORIZENET_SANDBOX : false); + $this->_log_file = (defined('AUTHORIZENET_LOG_FILE') ? AUTHORIZENET_LOG_FILE : true); + } + + /** + * Alter the gateway url. + * + * @param bool $bool Use the Sandbox. + */ + public function setSandbox($bool) + { + $this->_sandbox = $bool; + } + + /** + * Set a log file. + * + * @param string $filepath Path to log file. + */ + public function setLogFile($filepath) + { + $this->_log_file = $filepath; + } + + /** + * Return the post string. + * + * @return string + */ + public function getPostString() + { + return $this->_post_string; + } + + /** + * Posts the request to AuthorizeNet & returns response. + * + * @return AuthorizeNetARB_Response The response. + */ + protected function _sendRequest() + { + $this->_setPostString(); + $post_url = $this->_getPostUrl(); + $curl_request = curl_init($post_url); + curl_setopt($curl_request, CURLOPT_POSTFIELDS, $this->_post_string); + curl_setopt($curl_request, CURLOPT_HEADER, 0); + curl_setopt($curl_request, CURLOPT_TIMEOUT, 45); + curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2); + if ($this->VERIFY_PEER) { + curl_setopt($curl_request, CURLOPT_CAINFO, dirname(dirname(__FILE__)) . '/ssl/cert.pem'); + } else { + curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false); + } + + if (preg_match('/xml/',$post_url)) { + curl_setopt($curl_request, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml")); + } + + $response = curl_exec($curl_request); + + if ($this->_log_file) { + + if ($curl_error = curl_error($curl_request)) { + file_put_contents($this->_log_file, "----CURL ERROR----\n$curl_error\n\n", FILE_APPEND); + } + // Do not log requests that could contain CC info. + // file_put_contents($this->_log_file, "----Request----\n{$this->_post_string}\n", FILE_APPEND); + + file_put_contents($this->_log_file, "----Response----\n$response\n\n", FILE_APPEND); + } + curl_close($curl_request); + + return $this->_handleResponse($response); + } + +} diff --git a/anet_php_sdk/lib/shared/AuthorizeNetResponse.php b/anet_php_sdk/lib/shared/AuthorizeNetResponse.php new file mode 100755 index 0000000..969b60a --- /dev/null +++ b/anet_php_sdk/lib/shared/AuthorizeNetResponse.php @@ -0,0 +1,75 @@ +billTo = new AuthorizeNetAddress; + $this->payment = new AuthorizeNetPayment; + } + +} + +/** + * A class that contains all fields for a CIM Payment Type. + * + * @package AuthorizeNet + * @subpackage AuthorizeNetCIM + */ +class AuthorizeNetPayment +{ + public $creditCard; + public $bankAccount; + + public function __construct() + { + $this->creditCard = new AuthorizeNetCreditCard; + $this->bankAccount = new AuthorizeNetBankAccount; + } +} + +/** + * A class that contains all fields for a CIM Transaction. + * + * @package AuthorizeNet + * @subpackage AuthorizeNetCIM + */ +class AuthorizeNetTransaction +{ + public $amount; + public $tax; + public $shipping; + public $duty; + public $lineItems = array(); + public $customerProfileId; + public $customerPaymentProfileId; + public $customerShippingAddressId; + public $creditCardNumberMasked; + public $bankRoutingNumberMasked; + public $bankAccountNumberMasked; + public $order; + public $taxExempt; + public $recurringBilling; + public $cardCode; + public $splitTenderId; + public $approvalCode; + public $transId; + + public function __construct() + { + $this->tax = (object)array(); + $this->tax->amount = ""; + $this->tax->name = ""; + $this->tax->description = ""; + + $this->shipping = (object)array(); + $this->shipping->amount = ""; + $this->shipping->name = ""; + $this->shipping->description = ""; + + $this->duty = (object)array(); + $this->duty->amount = ""; + $this->duty->name = ""; + $this->duty->description = ""; + + // line items + + $this->order = (object)array(); + $this->order->invoiceNumber = ""; + $this->order->description = ""; + $this->order->purchaseOrderNumber = ""; + } + +} + +/** + * A class that contains all fields for a CIM Transaction Line Item. + * + * @package AuthorizeNet + * @subpackage AuthorizeNetCIM + */ +class AuthorizeNetLineItem +{ + public $itemId; + public $name; + public $description; + public $quantity; + public $unitPrice; + public $taxable; + +} + +/** + * A class that contains all fields for a CIM Credit Card. + * + * @package AuthorizeNet + * @subpackage AuthorizeNetCIM + */ +class AuthorizeNetCreditCard +{ + public $cardNumber; + public $expirationDate; + public $cardCode; +} + +/** + * A class that contains all fields for a CIM Bank Account. + * + * @package AuthorizeNet + * @subpackage AuthorizeNetCIM + */ +class AuthorizeNetBankAccount +{ + public $accountType; + public $routingNumber; + public $accountNumber; + public $nameOnAccount; + public $echeckType; + public $bankName; +} + +/** + * A class that contains all fields for an AuthorizeNet ARB Subscription. + * + * @package AuthorizeNet + * @subpackage AuthorizeNetARB + */ +class AuthorizeNet_Subscription +{ + + public $name; + public $intervalLength; + public $intervalUnit; + public $startDate; + public $totalOccurrences; + public $trialOccurrences; + public $amount; + public $trialAmount; + public $creditCardCardNumber; + public $creditCardExpirationDate; + public $creditCardCardCode; + public $bankAccountAccountType; + public $bankAccountRoutingNumber; + public $bankAccountAccountNumber; + public $bankAccountNameOnAccount; + public $bankAccountEcheckType; + public $bankAccountBankName; + public $orderInvoiceNumber; + public $orderDescription; + public $customerId; + public $customerEmail; + public $customerPhoneNumber; + public $customerFaxNumber; + public $billToFirstName; + public $billToLastName; + public $billToCompany; + public $billToAddress; + public $billToCity; + public $billToState; + public $billToZip; + public $billToCountry; + public $shipToFirstName; + public $shipToLastName; + public $shipToCompany; + public $shipToAddress; + public $shipToCity; + public $shipToState; + public $shipToZip; + public $shipToCountry; + + public function getXml() + { + $xml = " + {$this->name} + + + {$this->intervalLength} + {$this->intervalUnit} + + {$this->startDate} + {$this->totalOccurrences} + {$this->trialOccurrences} + + {$this->amount} + {$this->trialAmount} + + + {$this->creditCardCardNumber} + {$this->creditCardExpirationDate} + {$this->creditCardCardCode} + + + {$this->bankAccountAccountType} + {$this->bankAccountRoutingNumber} + {$this->bankAccountAccountNumber} + {$this->bankAccountNameOnAccount} + {$this->bankAccountEcheckType} + {$this->bankAccountBankName} + + + + {$this->orderInvoiceNumber} + {$this->orderDescription} + + + {$this->customerId} + {$this->customerEmail} + {$this->customerPhoneNumber} + {$this->customerFaxNumber} + + + {$this->billToFirstName} + {$this->billToLastName} + {$this->billToCompany} +
{$this->billToAddress}
+ {$this->billToCity} + {$this->billToState} + {$this->billToZip} + {$this->billToCountry} +
+ + {$this->shipToFirstName} + {$this->shipToLastName} + {$this->shipToCompany} +
{$this->shipToAddress}
+ {$this->shipToCity} + {$this->shipToState} + {$this->shipToZip} + {$this->shipToCountry} +
+
"; + + $xml_clean = ""; + // Remove any blank child elements + foreach (preg_split("/(\r?\n)/", $xml) as $key => $line) { + if (!preg_match('/><\//', $line)) { + $xml_clean .= $line . "\n"; + } + } + + // Remove any blank parent elements + $element_removed = 1; + // Recursively repeat if a change is made + while ($element_removed) { + $element_removed = 0; + if (preg_match('/<[a-z]+>[\r?\n]+\s*<\/[a-z]+>/i', $xml_clean)) { + $xml_clean = preg_replace('/<[a-z]+>[\r?\n]+\s*<\/[a-z]+>/i', '', $xml_clean); + $element_removed = 1; + } + } + + // Remove any blank lines + // $xml_clean = preg_replace('/\r\n[\s]+\r\n/','',$xml_clean); + return $xml_clean; + } +} + diff --git a/anet_php_sdk/lib/shared/AuthorizeNetXMLResponse.php b/anet_php_sdk/lib/shared/AuthorizeNetXMLResponse.php new file mode 100755 index 0000000..ede7854 --- /dev/null +++ b/anet_php_sdk/lib/shared/AuthorizeNetXMLResponse.php @@ -0,0 +1,128 @@ +response = $response; + if ($response) { + $this->xml = @simplexml_load_string($response); + + // Remove namespaces for use with XPath. + $this->xpath_xml = @simplexml_load_string(preg_replace('/ xmlns:xsi[^>]+/','',$response)); + } + } + + /** + * Was the transaction successful? + * + * @return bool + */ + public function isOk() + { + return ($this->getResultCode() == "Ok"); + } + + /** + * Run an xpath query on the cleaned XML response + * + * @param string $path + * @return array Returns an array of SimpleXMLElement objects or FALSE in case of an error. + */ + public function xpath($path) + { + return $this->xpath_xml->xpath($path); + } + + /** + * Was there an error? + * + * @return bool + */ + public function isError() + { + return ($this->getResultCode() == "Error"); + } + + /** + * @return string + */ + public function getErrorMessage() + { + return "Error: {$this->getResultCode()} + Message: {$this->getMessageText()} + {$this->getMessageCode()}"; + } + + /** + * @return string + */ + public function getRefID() + { + return $this->_getElementContents("refId"); + } + + /** + * @return string + */ + public function getResultCode() + { + return $this->_getElementContents("resultCode"); + } + + /** + * @return string + */ + public function getMessageCode() + { + return $this->_getElementContents("code"); + } + + /** + * @return string + */ + public function getMessageText() + { + return $this->_getElementContents("text"); + } + + /** + * Grabs the contents of a unique element. + * + * @param string + * @return string + */ + protected function _getElementContents($elementName) + { + $start = "<$elementName>"; + $end = ""; + if (strpos($this->response,$start) === false || strpos($this->response,$end) === false) { + return false; + } else { + $start_position = strpos($this->response, $start)+strlen($start); + $end_position = strpos($this->response, $end); + return substr($this->response, $start_position, $end_position-$start_position); + } + } + +} \ No newline at end of file diff --git a/anet_php_sdk/lib/ssl/cert.pem b/anet_php_sdk/lib/ssl/cert.pem new file mode 100755 index 0000000..b59fbb0 --- /dev/null +++ b/anet_php_sdk/lib/ssl/cert.pem @@ -0,0 +1,253 @@ +-----BEGIN CERTIFICATE----- +MIIEYTCCA0mgAwIBAgIESyDOMjANBgkqhkiG9w0BAQUFADCBsTELMAkGA1UEBhMC +VVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydX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CLFPPH5jfdAx +sOtocx7eyUovzO387ve8UMTdw6Anr9Ai7iVaYf4MpMqcuaHVet3QeE97Koy1 +mT3q9FmUGbXM+nCqSs/TQ4jSqOo4zqDnkK/cOgbzjsuJJZ/rCPSxaKvz3b/n +wMWH7kM= +-----END CERTIFICATE----- \ No newline at end of file diff --git a/anet_php_sdk/tests/AuthorizeNetAIM_Test.php b/anet_php_sdk/tests/AuthorizeNetAIM_Test.php new file mode 100755 index 0000000..573327d --- /dev/null +++ b/anet_php_sdk/tests/AuthorizeNetAIM_Test.php @@ -0,0 +1,888 @@ +setFields( + array( + 'amount' => rand(1, 1000), + 'card_num' => '4111111111111111', + 'exp_date' => '0415' + ) + ); + $response = $sale->authorizeAndCapture(); + $this->assertTrue($response->approved); + } + + public function testAuthCaptureSingleDigitMonth() + { + $sale = new AuthorizeNetAIM; + $sale->setFields( + array( + 'amount' => rand(1, 1000), + 'card_num' => '4111111111111111', + 'exp_date' => '415' + ) + ); + $response = $sale->authorizeAndCapture(); + $this->assertTrue($response->approved); + } + + public function testAuthCaptureSingleDigitMonthWithSlash() + { + $sale = new AuthorizeNetAIM; + $sale->setFields( + array( + 'amount' => rand(1, 1000), + 'card_num' => '4111111111111111', + 'exp_date' => '4/15' + ) + ); + $response = $sale->authorizeAndCapture(); + $this->assertTrue($response->approved); + } + + public function testAuthCaptureTwoDigitMonthWithSlash() + { + $sale = new AuthorizeNetAIM; + $sale->setFields( + array( + 'amount' => rand(1, 1000), + 'card_num' => '4111111111111111', + 'exp_date' => '04/15' + ) + ); + $response = $sale->authorizeAndCapture(); + $this->assertTrue($response->approved); + } + + public function testAuthCaptureAlternate() + { + $sale = new AuthorizeNetAIM; + $sale->amount = rand(1, 10000); + $sale->card_num = '6011000000000012'; + $sale->exp_date = '04/15'; + $response = $sale->authorizeAndCapture(); + $this->assertTrue($response->approved); + } + + public function testAuthCaptureShort() + { + $sale = new AuthorizeNetAIM; + $response = $sale->authorizeAndCapture(rand(1, 100), '6011000000000012', '04/16'); + $this->assertTrue($response->approved); + } + + public function testAuthCapturePartial() + { + $amount = 3.69; + + $sale = new AuthorizeNetAIM; + $sale->amount = $amount; + $sale->card_num = '4222222222222'; + $sale->zip = "46225"; + $sale->exp_date = '04/15'; + $sale->allow_partial_auth = true; + $response = $sale->authorizeAndCapture(); + $this->assertTrue($response->held); + $this->assertEquals("1.23", $response->amount); + $this->assertEquals($amount, $response->requested_amount); + $split_tender_id = $response->split_tender_id; + + // Pay the balance with a different card + $sale = new AuthorizeNetAIM; + $sale->amount = $amount - $response->amount; + $sale->card_num = '6011000000000012'; + $sale->exp_date = '04/20'; + $sale->split_tender_id = $split_tender_id; + $sale->allow_partial_auth = true; + $response = $sale->authorizeAndCapture(); + $this->assertTrue($response->approved); + + + } + + public function testAuthCaptureShortNoVerify() + { + $sale = new AuthorizeNetAIM; + $sale->VERIFY_PEER = false; + $response = $sale->authorizeAndCapture(rand(1, 100), '6011000000000012', '04/19'); + $this->assertTrue($response->approved); + } + + // public function testVisaVerify() + // { + // return; // Remove to enable test + // $verify = new AuthorizeNetAIM; + // $verify->amount = "0.00"; + // $verify->card_num = '4012888818888'; + // $verify->exp_date = "0517"; + // $verify->address = "123 Main Street"; + // $verify->zip = "94110"; + // $verify->authentication_indicator = "5"; + // $verify->cardholder_authentication_value = "512"; + // $response = $verify->authorizeOnly(); + // $this->assertTrue($response->approved); + // } + // + // public function testVisaVerifyFail() + // { + // return; // Remove to enable test + // $verify = new AuthorizeNetAIM; + // $verify->amount = "0.00"; + // $verify->card_num = '4012888818888'; + // $verify->exp_date = "0517"; + // $verify->address = "123 Main Street"; + // $verify->zip = "94110"; + // $verify->authentication_indicator = "5"; + // $verify->cardholder_authentication_value = ""; + // $response = $verify->authorizeOnly(); + // $this->assertTrue($response->declined); + // } + // + // public function testMastercardVerify() + // { + // return; // Remove to enable test + // $verify = new AuthorizeNetAIM; + // $verify->amount = "0.00"; + // $verify->card_num = '5424000000000015'; + // $verify->exp_date = "0517"; + // $verify->address = "123 Main Street"; + // $verify->zip = "94110"; + // $verify->authentication_indicator = "2"; + // $verify->cardholder_authentication_value = "512"; + // $response = $verify->authorizeOnly(); + // $this->assertTrue($response->approved); + // } + // + // public function testMastercardVerifyFail() + // { + // return; // Remove to enable test + // $verify = new AuthorizeNetAIM; + // $verify->amount = "0.00"; + // $verify->card_num = '5424000000000015'; + // $verify->exp_date = "0517"; + // $verify->address = "123 Main Street"; + // $verify->zip = "94110"; + // $verify->authentication_indicator = "2"; + // $verify->cardholder_authentication_value = ""; + // $response = $verify->authorizeOnly(); + // $this->assertTrue($response->declined); + // } + + public function testAimResponseFields() + { + + $sale = new AuthorizeNetAIM; + $sale->card_num = '4111111111111111'; + $sale->exp_date = '04/16'; + $sale->amount = $amount = rand(1,99); + $sale->description = $description = "Sale description"; + $sale->first_name = $first_name = "Jane"; + $sale->last_name = $last_name = "Smith"; + $sale->company = $company = "Jane Smith Enterprises Inc."; + $sale->address = $address = "20 Main Street"; + $sale->city = $city = "San Francisco"; + $sale->state = $state = "CA"; + $sale->zip = $zip = "94110"; + $sale->country = $country = "US"; + $sale->phone = $phone = "415-555-5557"; + $sale->fax = $fax = "415-555-5556"; + $sale->email = $email = "foo@example.com"; + $sale->cust_id = $customer_id = "55"; + $sale->customer_ip = "98.5.5.5"; + $sale->invoice_num = $invoice_num = "123"; + $sale->ship_to_first_name = $ship_to_first_name = "John"; + $sale->ship_to_last_name = $ship_to_last_name = "Smith"; + $sale->ship_to_company = $ship_to_company = "Smith Enterprises Inc."; + $sale->ship_to_address = $ship_to_address = "10 Main Street"; + $sale->ship_to_city = $ship_to_city = "San Francisco"; + $sale->ship_to_state = $ship_to_state = "CA"; + $sale->ship_to_zip = $ship_to_zip_code = "94110"; + $sale->ship_to_country = $ship_to_country = "US"; + $sale->tax = $tax = "0.00"; + $sale->freight = $freight = "Freight<|>ground overnight<|>12.95"; + $sale->duty = $duty = "Duty1<|>export<|>15.00"; + $sale->tax_exempt = $tax_exempt = "FALSE"; + $sale->po_num = $po_num = "12"; + + + + $response = $sale->authorizeAndCapture(); + $this->assertTrue($response->approved); + $this->assertEquals("1", $response->response_code); + $this->assertEquals("1", $response->response_subcode); + $this->assertEquals("1", $response->response_reason_code); + $this->assertEquals("This transaction has been approved.", $response->response_reason_text); + $this->assertGreaterThan(1, strlen($response->authorization_code)); + $this->assertEquals("Y", $response->avs_response); + $this->assertGreaterThan(1, strlen($response->transaction_id)); + $this->assertEquals($invoice_num, $response->invoice_num); + $this->assertEquals($description, $response->description); + $this->assertEquals($amount, $response->amount); + $this->assertEquals("CC", $response->method); + $this->assertEquals("auth_capture", $response->transaction_type); + $this->assertEquals($customer_id, $response->customer_id); + $this->assertEquals($first_name, $response->first_name); + $this->assertEquals($last_name, $response->last_name); + $this->assertEquals($company, $response->company); + $this->assertEquals($address, $response->address); + $this->assertEquals($city, $response->city); + $this->assertEquals($state, $response->state); + $this->assertEquals($zip, $response->zip_code); + $this->assertEquals($country, $response->country); + $this->assertEquals($phone, $response->phone); + $this->assertEquals($fax, $response->fax); + $this->assertEquals($email, $response->email_address); + $this->assertEquals($ship_to_first_name, $response->ship_to_first_name); + $this->assertEquals($ship_to_last_name, $response->ship_to_last_name); + $this->assertEquals($ship_to_company, $response->ship_to_company); + $this->assertEquals($ship_to_address, $response->ship_to_address); + $this->assertEquals($ship_to_city, $response->ship_to_city); + $this->assertEquals($ship_to_state, $response->ship_to_state); + $this->assertEquals($ship_to_zip_code, $response->ship_to_zip_code); + $this->assertEquals($ship_to_country, $response->ship_to_country); + $this->assertEquals($tax, $response->tax); + $this->assertEquals("15.00", $response->duty); + $this->assertEquals("12.95", $response->freight); + $this->assertEquals($tax_exempt, $response->tax_exempt); + $this->assertEquals($po_num, $response->purchase_order_number); + $this->assertGreaterThan(1, strlen($response->md5_hash)); + $this->assertEquals("", $response->card_code_response); + $this->assertEquals("2", $response->cavv_response); + $this->assertEquals("XXXX1111", $response->account_number); + $this->assertEquals("Visa", $response->card_type); + $this->assertEquals("", $response->split_tender_id); + $this->assertEquals("", $response->requested_amount); + $this->assertEquals("", $response->balance_on_card); + + + } + + + public function testVoid() + { + // First create transaction to void. + $amount = rand(1, 1000); + $sale = new AuthorizeNetAIM; + $sale->setFields( + array( + 'amount' => $amount, + 'card_num' => '6011000000000012', + 'exp_date' => '0415' + ) + ); + $response = $sale->authorizeAndCapture(); + $this->assertTrue($response->approved); + + $void = new AuthorizeNetAIM; + $void->setFields( + array( + 'amount' => $amount, + 'card_num' => '6011000000000012', + 'trans_id' => $response->transaction_id, + ) + ); + $void_response = $void->Void(); + $this->assertTrue($void_response->approved); + } + + public function testVoidShort() + { + // First create transaction to void. + $amount = rand(1, 1000); + $card_num = '6011000000000012'; + $exp_date = '0415'; + $sale = new AuthorizeNetAIM; + $response = $sale->authorizeAndCapture($amount, $card_num, $exp_date); + $this->assertTrue($response->approved); + + $void = new AuthorizeNetAIM; + $void_response = $void->void($response->transaction_id); + $this->assertTrue($void_response->approved); + } + + public function testAuthCaptureECheckSandbox() + { + $sale = new AuthorizeNetAIM; + $sale->setFields( + array( + 'amount' => rand(1, 1000), + 'method' => 'echeck', + 'bank_aba_code' => '121042882', + 'bank_acct_num' => '123456789123', + 'bank_acct_type' => 'CHECKING', + 'bank_name' => 'Bank of Earth', + 'bank_acct_name' => 'Jane Doe', + 'echeck_type' => 'WEB', + ) + ); + $response = $sale->authorizeAndCapture(); + $this->assertEquals("ECHECK", $response->method); + $this->assertTrue($response->approved); + + } + + public function testAmex() + { + $sale = new AuthorizeNetAIM; + $response = $sale->authorizeAndCapture(rand(1, 100), '370000000000002', '04/16'); + $this->assertTrue($response->approved); + } + + public function testDiscover() + { + $sale = new AuthorizeNetAIM; + $response = $sale->authorizeAndCapture(rand(1, 100), '6011000000000012', '04/16'); + $this->assertTrue($response->approved); + } + + public function testVisa() + { + $sale = new AuthorizeNetAIM; + $response = $sale->authorizeAndCapture(rand(1, 100), '4012888818888', '04/16'); + $this->assertTrue($response->approved); + } + + // public function testJCB() + // { + // return; // Remove to enable test + // $sale = new AuthorizeNetAIM; + // $response = $sale->authorizeAndCapture(rand(1, 100), '3088000000000017', '0905'); + // $this->assertTrue($response->approved); + // } + // + // public function testDinersClub() + // { + // return; // Remove to enable test + // $sale = new AuthorizeNetAIM; + // $response = $sale->authorizeAndCapture(rand(1, 100), '38000000000006', '0905'); + // $this->assertTrue($response->approved); + // } + + public function testAuthOnly() + { + $auth = new AuthorizeNetAIM; + $auth->setFields( + array( + 'amount' => rand(1, 1000), + 'card_num' => '6011000000000012', + 'exp_date' => '0415' + ) + ); + $response = $auth->authorizeOnly(); + $this->assertTrue($response->approved); + } + + public function testAuthCaptureVoid() + { + $amount = rand(1, 1000); + $auth = new AuthorizeNetAIM; + $auth->setFields( + array( + 'amount' => $amount, + 'card_num' => '6011000000000012', + 'exp_date' => '0415' + ) + ); + $auth_response = $auth->authorizeOnly(); + $this->assertTrue($auth_response->approved); + + // Now capture. + $capture = new AuthorizeNetAIM; + $capture->setFields( + array( + 'amount' => $amount, + 'card_num' => '6011000000000012', + 'exp_date' => '0415', + 'trans_id' => $auth_response->transaction_id, + ) + ); + $capture_response = $capture->priorAuthCapture(); + $this->assertTrue($capture_response->approved); + + // Now void + $void = new AuthorizeNetAIM; + $void->setFields( + array( + 'amount' => $amount, + 'card_num' => '0012', + 'trans_id' => $auth_response->transaction_id, + ) + ); + $void_response = $void->void(); + $this->assertTrue($void_response->approved); + } + + // public function testCredit() + // { + // + // } + // + // public function testPriorAuthCapture() + // { + // + // } + // + // public function testCaptureOnly() + // { + // + // } + + public function testAdvancedAIM() + { + $auth = new AuthorizeNetAIM; + $auth->amount = "45.00"; + + // Use eCheck: + $auth->setECheck( + '121042882', + '123456789123', + 'CHECKING', + 'Bank of Earth', + 'Jane Doe', + 'WEB' + ); + + // Set multiple line items: + $auth->addLineItem('item1', 'Golf tees', 'Blue tees', '2', '5.00', 'N'); + $auth->addLineItem('item2', 'Golf shirt', 'XL', '1', '40.00', 'N'); + + // Set Invoice Number: + $auth->invoice_num = time(); + + // Set a Merchant Defined Field: + $auth->setCustomField("entrance_source", "Search Engine"); + + // Authorize Only: + $response = $auth->authorizeOnly(); + $this->assertTrue($response->approved); + if ($response->approved) { + $auth_code = $response->transaction_id; + + // Now capture: + $capture = new AuthorizeNetAIM; + $capture_response = $capture->priorAuthCapture($auth_code); + $this->assertTrue($capture_response->approved); + + // Now void: + $void = new AuthorizeNetAIM; + $void_response = $void->void($capture_response->transaction_id); + $this->assertTrue($void_response->approved); + } + } + + public function testAuthCaptureCustomFields() + { + $sale = new AuthorizeNetAIM; + $sale->setFields( + array( + 'amount' => rand(1, 1000), + 'card_num' => '6011000000000012', + 'exp_date' => '0415' + ) + ); + $sale->setCustomField("foo", "bar"); + $sale->setCustomField("foo2", "bar2"); + $sale->setCustomField("foo3", "bar3"); + $sale->setCustomField("foo4", "bar4"); + $sale->setCustomField("foo5", "bar5"); + $sale->setCustomField("My_MerchantField6", "My Merchant Value6"); + $sale->setCustomField("foo7", "bar7"); + $response = $sale->authorizeAndCapture(); + $this->assertTrue($response->approved); + $this->assertEquals("bar", $response->foo); + $this->assertEquals("bar2", $response->foo2); + } + + public function testEncapCharacter() + { + $description = "john doe's present, with comma"; + $amount = rand(1, 1000); + $sale = new AuthorizeNetAIM; + $sale->setFields( + array( + 'amount' => $amount, + 'card_num' => '6011000000000012', + 'exp_date' => '0415', + 'encap_char' => '$', + 'description' => $description, + ) + ); + $response = $sale->authorizeAndCapture(); + $this->assertTrue($response->approved); + $this->assertEquals($amount, $response->amount); + $this->assertEquals($description, $response->description); + } + + public function testAuthCaptureSetMultipleCustomFields() + { + $sale = new AuthorizeNetAIM; + $sale->setFields( + array( + 'amount' => rand(1, 1000), + 'card_num' => '6011000000000012', + 'exp_date' => '0415' + ) + ); + $sale->setCustomFields(array("foo" => "bar", "foo2" => "bar2")); + $response = $sale->authorizeAndCapture(); + $this->assertTrue($response->approved); + $this->assertEquals("bar", $response->foo); + $this->assertEquals("bar2", $response->foo2); + } + + public function testInvalidMerchantCredentials() + { + $auth = new AuthorizeNetAIM('d', 'd'); + $response = $auth->AuthorizeOnly(); + $this->assertTrue($response->error); + $this->assertEquals($response->response_subcode, 2); + $this->assertEquals($response->response_reason_code, 13); + } + + public function testInvalidCreditCard() + { + $sale = new AuthorizeNetAIM; + $sale->setFields( + array( + 'amount' => rand(1, 1000), + 'card_num' => '123', + 'exp_date' => '0415' + ) + ); + $response = $sale->authorizeAndCapture(); + $this->assertFalse($response->approved); + $this->assertTrue($response->error); + } + + public function testError() + { + $sale = new AuthorizeNetAIM; + $sale->unsetField("login"); + $sale->unsetField("tran_key"); + $sale->unsetField("delim_data"); + + $sale->unsetField("version"); + $sale->unsetField("relay_response"); + + $response = $sale->authorizeAndCapture(); + // An exception should have been thrown. + $this->assertFalse($response->approved); + $this->assertTrue($response->error); + + } + + public function testMultipleLineItems() + { + $merchant = (object)array(); + $merchant->login = AUTHORIZENET_API_LOGIN_ID; + $merchant->tran_key = AUTHORIZENET_TRANSACTION_KEY; + $merchant->allow_partial_auth = "false"; + + $creditCard = array( + 'exp_date' => '02/2012', + 'card_num' => '6011000000000012', + 'card_code' => '452', + ); + + $transaction = array( + 'amount' => rand(100, 1000), + 'duplicate_window' => '10', + // 'email_customer' => 'true', + 'footer_email_receipt' => 'thank you for your business!', + 'header_email_receipt' => 'a copy of your receipt is below', + ); + + $order = array( + 'description' => 'Johns Bday Gift', + 'invoice_num' => '3123', + 'line_item' => 'item1<|>golf balls<|><|>2<|>18.95<|>Y', + ); + + $customer = (object)array(); + $customer->first_name = "Jane"; + $customer->last_name = "Smith"; + $customer->company = "Jane Smith Enterprises Inc."; + $customer->address = "20 Main Street"; + $customer->city = "San Francisco"; + $customer->state = "CA"; + $customer->zip = "94110"; + $customer->country = "US"; + $customer->phone = "415-555-5557"; + $customer->fax = "415-555-5556"; + $customer->email = "foo@example.com"; + $customer->cust_id = "55"; + $customer->customer_ip = "98.5.5.5"; + + $shipping_info = (object)array(); + $shipping_info->ship_to_first_name = "John"; + $shipping_info->ship_to_last_name = "Smith"; + $shipping_info->ship_to_company = "Smith Enterprises Inc."; + $shipping_info->ship_to_address = "10 Main Street"; + $shipping_info->ship_to_city = "San Francisco"; + $shipping_info->ship_to_state = "CA"; + $shipping_info->ship_to_zip = "94110"; + $shipping_info->ship_to_country = "US"; + $shipping_info->tax = "CA"; + $shipping_info->freight = "Freight<|>ground overnight<|>12.95"; + $shipping_info->duty = "Duty1<|>export<|>15.00"; + $shipping_info->tax_exempt = "false"; + $shipping_info->po_num = "12"; + + $sale = new AuthorizeNetAIM; + $sale->setFields($creditCard); + $sale->setFields($shipping_info); + $sale->setFields($customer); + $sale->setFields($order); + $sale->setFields($merchant); + $sale->setFields($transaction); + + $sale->addLineItem('item2', 'golf tees', 'titanium tees', '2', '2.95', 'Y'); + $sale->addLineItem('item3', 'golf shirt', 'red, large', '2', '3.95', 'Y'); + + $response = $sale->authorizeAndCapture(); + + $this->assertTrue($response->approved); + } + + public function testAllFieldsLongMethod() + { + $merchant = (object)array(); + $merchant->login = AUTHORIZENET_API_LOGIN_ID; + $merchant->tran_key = AUTHORIZENET_TRANSACTION_KEY; + $merchant->allow_partial_auth = "false"; + + $creditCard = array( + 'exp_date' => '02/2012', + 'card_num' => '6011000000000012', + 'card_code' => '452', + ); + + $transaction = array( + 'amount' => rand(100, 1000), + 'duplicate_window' => '10', + // 'email_customer' => 'true', + 'footer_email_receipt' => 'thank you for your business!', + 'header_email_receipt' => 'a copy of your receipt is below', + ); + + $order = array( + 'description' => 'Johns Bday Gift', + 'invoice_num' => '3123', + 'line_item' => 'item1<|>golf balls<|><|>2<|>18.95<|>Y', + ); + + $customer = (object)array(); + $customer->first_name = "Jane"; + $customer->last_name = "Smith"; + $customer->company = "Jane Smith Enterprises Inc."; + $customer->address = "20 Main Street"; + $customer->city = "San Francisco"; + $customer->state = "CA"; + $customer->zip = "94110"; + $customer->country = "US"; + $customer->phone = "415-555-5557"; + $customer->fax = "415-555-5556"; + $customer->email = "foo@example.com"; + $customer->cust_id = "55"; + $customer->customer_ip = "98.5.5.5"; + + $shipping_info = (object)array(); + $shipping_info->ship_to_first_name = "John"; + $shipping_info->ship_to_last_name = "Smith"; + $shipping_info->ship_to_company = "Smith Enterprises Inc."; + $shipping_info->ship_to_address = "10 Main Street"; + $shipping_info->ship_to_city = "San Francisco"; + $shipping_info->ship_to_state = "CA"; + $shipping_info->ship_to_zip = "94110"; + $shipping_info->ship_to_country = "US"; + $shipping_info->tax = "CA"; + $shipping_info->freight = "Freight<|>ground overnight<|>12.95"; + $shipping_info->duty = "Duty1<|>export<|>15.00"; + $shipping_info->tax_exempt = "false"; + $shipping_info->po_num = "12"; + + $sale = new AuthorizeNetAIM; + $sale->setFields($creditCard); + $sale->setFields($shipping_info); + $sale->setFields($customer); + $sale->setFields($order); + $sale->setFields($merchant); + $sale->setFields($transaction); + $response = $sale->authorizeAndCapture(); + + $this->assertTrue($response->approved); + } + + public function testResponseMethods() + { + $amount = rand(1, 1000); + $zipcode = "02301"; + + $sale = new AuthorizeNetAIM; + $sale->setFields( + array( + 'amount' => $amount, + 'card_num' => '6011000000000012', + 'exp_date' => '0415', + 'zip' => $zipcode, + ) + ); + + $sale->setCustomField("custom1", "custom1value"); + $sale->setCustomField("custom2", "custom2value"); + $result = $sale->authorizeAndCapture(); + $this->assertTrue($result->approved); + + $this->assertEquals("custom2value", $result->custom2); + $this->assertEquals($amount, $result->amount); + $this->assertEquals("CC", $result->method); + $this->assertEquals("auth_capture", $result->transaction_type); + $this->assertEquals("Discover", $result->card_type); + $this->assertEquals($zipcode, $result->zip_code); + } + + public function testSetBadField() + { + try { + $amount = rand(1, 1000); + $zipcode = "02301"; + + $sale = new AuthorizeNetAIM; + $sale->setFields( + array( + 'amount' => $amount, + 'card_num' => '6011000000000012', + 'exp_date' => '0415', + 'zipcode' => $zipcode, // Should actually be just "zip" + ) + ); + + $result = $sale->authorizeAndCapture(); + $this->assertTrue($result->approved); + // should have thrown an exception by now + $this->assertFalse(true); + } + catch (AuthorizeNetException $e){ + $this->assertTrue(true); + + } + } + +} + + +class AuthorizeNetAIM_Live_Test extends PHPUnit_Framework_TestCase +{ + + public function testAuthCaptureSetECheckMethod() + { + if (MERCHANT_LIVE_API_LOGIN_ID) { + // $this->markTestIncomplete('Depends on whether eChecks is enabled'); + $sale = new AuthorizeNetAIM(MERCHANT_LIVE_API_LOGIN_ID,MERCHANT_LIVE_TRANSACTION_KEY); + $sale->setSandbox(false); + $sale->test_request = 'TRUE'; + $sale->amount = "4.99"; + $sale->setECheck( + '121042882', + '123456789123', + 'CHECKING', + 'Bank of Earth', + 'Jane Doe', + 'WEB' + ); + $response = $sale->authorizeAndCapture(); + $this->assertEquals("ECHECK", $response->method); + $this->assertEquals("18", $response->response_reason_code); + // $this->assertTrue($response->approved); + } + } + + public function testAuthCaptureECheck() + { + if (MERCHANT_LIVE_API_LOGIN_ID) { + // $this->markTestIncomplete('Depends on whether eChecks is enabled'); + $sale = new AuthorizeNetAIM(MERCHANT_LIVE_API_LOGIN_ID,MERCHANT_LIVE_TRANSACTION_KEY); + $sale->setSandbox(false); + $sale->test_request = 'TRUE'; + $sale->setFields( + array( + 'amount' => rand(1, 1000), + 'method' => 'echeck', + 'bank_aba_code' => '121042882', + 'bank_acct_num' => '123456789123', + 'bank_acct_type' => 'CHECKING', + 'bank_name' => 'Bank of Earth', + 'bank_acct_name' => 'Jane Doe', + 'echeck_type' => 'WEB', + ) + ); + $response = $sale->authorizeAndCapture(); + $this->assertEquals("ECHECK", $response->method); + $this->assertEquals("18", $response->response_reason_code); + // $this->assertTrue($response->approved); + } + } + + public function testAuthCaptureLiveServerTestRequest() + { + if (MERCHANT_LIVE_API_LOGIN_ID) { + $sale = new AuthorizeNetAIM(MERCHANT_LIVE_API_LOGIN_ID,MERCHANT_LIVE_TRANSACTION_KEY); + $sale->setSandbox(false); + $sale->setFields( + array( + 'amount' => rand(1, 1000), + 'card_num' => '6011000000000012', + 'exp_date' => '0415' + ) + ); + $sale->setField('test_request', 'TRUE'); + $response = $sale->authorizeAndCapture(); + $this->assertTrue($response->approved); + } + } + + public function testAuthCaptureLiveServer() + { + if (MERCHANT_LIVE_API_LOGIN_ID) { + $sale = new AuthorizeNetAIM(MERCHANT_LIVE_API_LOGIN_ID,MERCHANT_LIVE_TRANSACTION_KEY); + $sale->setSandbox(false); + $sale->test_request = 'TRUE'; + $sale->setFields( + array( + 'amount' => rand(1, 1000), + 'card_num' => '6011000000000012', + 'exp_date' => '0415' + ) + ); + $response = $sale->authorizeAndCapture(); + $this->assertTrue($response->approved); + } + } + + public function testInvalidCredentials() + { + if (MERCHANT_LIVE_API_LOGIN_ID) { + // Post a response to live server using invalid credentials. + $sale = new AuthorizeNetAIM('a','a'); + $sale->setSandbox(false); + $sale->setFields( + array( + 'amount' => rand(1, 1000), + 'card_num' => '6011000000000012', + 'exp_date' => '0415' + ) + ); + $response = $sale->authorizeAndCapture(); + $this->assertTrue($response->error); + $this->assertEquals("13", $response->response_reason_code); + } + } + +} \ No newline at end of file diff --git a/anet_php_sdk/tests/AuthorizeNetARB_Test.php b/anet_php_sdk/tests/AuthorizeNetARB_Test.php new file mode 100755 index 0000000..ef120af --- /dev/null +++ b/anet_php_sdk/tests/AuthorizeNetARB_Test.php @@ -0,0 +1,201 @@ +name = "Short subscription"; + $subscription->intervalLength = "1"; + $subscription->intervalUnit = "months"; + $subscription->startDate = "2011-03-12"; + $subscription->totalOccurrences = "14"; + $subscription->amount = rand(1,100); + $subscription->creditCardCardNumber = "6011000000000012"; + $subscription->creditCardExpirationDate = "2018-10"; + $subscription->creditCardCardCode = "123"; + $subscription->billToFirstName = "john"; + $subscription->billToLastName = "doe"; + + // Create the subscription. + $request = new AuthorizeNetARB; + $response = $request->createSubscription($subscription); + $this->assertTrue($response->isOk()); + $subscription_id = $response->getSubscriptionId(); + + // Get the subscription status + $status_request = new AuthorizeNetARB; + $status_response = $status_request->getSubscriptionStatus($subscription_id); + $this->assertEquals("active",$status_response->getSubscriptionStatus()); + + // Update the subscription + $update_request = new AuthorizeNetARB; + $updated_subscription_info = new AuthorizeNet_Subscription; + $updated_subscription_info->billToFirstName = "jane"; + $updated_subscription_info->billToLastName = "smith"; + $updated_subscription_info->creditCardCardNumber = "6011000000000012"; + $updated_subscription_info->creditCardExpirationDate = "2019-10"; + $updated_subscription_info->creditCardCardCode = "423"; + $update_response = $update_request->updateSubscription($subscription_id, $updated_subscription_info); + $this->assertTrue($update_response->isOk()); + + // Cancel the subscription + $cancellation = new AuthorizeNetARB; + $cancel_response = $cancellation->cancelSubscription($subscription_id); + $this->assertTrue($cancel_response->isOk()); + + // Get the subscription status + $status_request = new AuthorizeNetARB; + $status_response = $status_request->getSubscriptionStatus($subscription_id); + $this->assertEquals("canceled", $status_response->getSubscriptionStatus()); + + } + + + public function testCreateSubscriptionLong() + { + + $subscription = new AuthorizeNet_Subscription; + $subscription->name = "test subscription"; + $subscription->intervalLength = "1"; + $subscription->intervalUnit = "months"; + $subscription->startDate = "2015-03-12"; + $subscription->totalOccurrences = "14"; + $subscription->trialOccurrences = ""; + $subscription->amount = "6.99"; + $subscription->trialAmount = ""; + $subscription->creditCardCardNumber = "6011000000000012"; + $subscription->creditCardExpirationDate = "2018-10"; + $subscription->creditCardCardCode = "123"; + $subscription->bankAccountAccountType = ""; + $subscription->bankAccountRoutingNumber = ""; + $subscription->bankAccountAccountNumber = ""; + $subscription->bankAccountNameOnAccount = ""; + $subscription->bankAccountEcheckType = ""; + $subscription->bankAccountBankName = ""; + $subscription->orderInvoiceNumber = ""; + $subscription->orderDescription = ""; + $subscription->customerId = "12"; + $subscription->customerEmail = "foo@domain.com"; + $subscription->customerPhoneNumber = ""; + $subscription->customerFaxNumber = ""; + $subscription->billToFirstName = "john"; + $subscription->billToLastName = "doe"; + $subscription->billToCompany = ""; + $subscription->billToAddress = ""; + $subscription->billToCity = ""; + $subscription->billToState = ""; + $subscription->billToZip = ""; + $subscription->billToCountry = ""; + $subscription->shipToFirstName = ""; + $subscription->shipToLastName = ""; + $subscription->shipToCompany = ""; + $subscription->shipToAddress = ""; + $subscription->shipToCity = ""; + $subscription->shipToState = ""; + $subscription->shipToZip = ""; + $subscription->shipToCountry = ""; + + $refId = "ref" . time(); + + // Create the request and send it. + $request = new AuthorizeNetARB; + $request->setRefId($refId); + $response = $request->createSubscription($subscription); + + + // Handle the response. + + $this->assertTrue($response->isOk()); + $this->assertEquals($response->getMessageCode(), "I00001"); + $this->assertEquals($response->getMessageText(), "Successful."); + $this->assertEquals($response->getRefId(), $refId); + $this->assertEquals($response->getResultCode(), "Ok"); + + // Cancel the subscription to avoid duplicate errors in future + + $cancellation = new AuthorizeNetARB; + $cancellation->setRefId($refId); + $cancel_response = $cancellation->cancelSubscription($response->getSubscriptionId()); + + + + $this->assertTrue($cancel_response->isOk()); + + } + + public function testCreateSubscriptionECheck() + { + + $subscription = new AuthorizeNet_Subscription; + $subscription->name = "my test echeck subscription"; + $subscription->intervalLength = "1"; + $subscription->intervalUnit = "months"; + $subscription->startDate = "2015-04-12"; + $subscription->totalOccurrences = "2"; + $subscription->trialOccurrences = ""; + $subscription->amount = "11.99"; + $subscription->trialAmount = ""; + $subscription->bankAccountAccountType = "checking"; + $subscription->bankAccountRoutingNumber = "121000248"; + $subscription->bankAccountAccountNumber = "12345678"; + $subscription->bankAccountNameOnAccount = "John Doe"; + $subscription->bankAccountEcheckType = "WEB"; + $subscription->bankAccountBankName = "Bank of Earth"; + $subscription->orderInvoiceNumber = ""; + $subscription->orderDescription = ""; + $subscription->customerId = "12"; + $subscription->customerEmail = "foo@domain.com"; + $subscription->customerPhoneNumber = ""; + $subscription->customerFaxNumber = ""; + $subscription->billToFirstName = "john"; + $subscription->billToLastName = "doe"; + $subscription->billToCompany = ""; + $subscription->billToAddress = ""; + $subscription->billToCity = ""; + $subscription->billToState = ""; + $subscription->billToZip = ""; + $subscription->billToCountry = ""; + $subscription->shipToFirstName = ""; + $subscription->shipToLastName = ""; + $subscription->shipToCompany = ""; + $subscription->shipToAddress = ""; + $subscription->shipToCity = ""; + $subscription->shipToState = ""; + $subscription->shipToZip = ""; + $subscription->shipToCountry = ""; + + $refId = "ref" . time(); + + // Create the request and send it. + $request = new AuthorizeNetARB; + $request->setRefId($refId); + + $response = $request->createSubscription($subscription); + + + // Handle the response. + + $this->assertTrue($response->isOk()); + $this->assertEquals($response->getMessageCode(), "I00001"); + $this->assertEquals($response->getMessageText(), "Successful."); + $this->assertEquals($response->getRefId(), $refId); + $this->assertEquals($response->getResultCode(), "Ok"); + + + // Cancel the subscription to avoid duplicate errors in future + + + $cancellation = new AuthorizeNetARB; + $cancellation->setRefId($refId); + $cancel_response = $cancellation->cancelSubscription($response->getSubscriptionId()); + + $this->assertTrue($cancel_response->isOk()); + + } + +} \ No newline at end of file diff --git a/anet_php_sdk/tests/AuthorizeNetCIM_Test.php b/anet_php_sdk/tests/AuthorizeNetCIM_Test.php new file mode 100755 index 0000000..75c58d9 --- /dev/null +++ b/anet_php_sdk/tests/AuthorizeNetCIM_Test.php @@ -0,0 +1,355 @@ +getCustomerProfileIds(); + $customers = $response->getCustomerProfileIds(); + + foreach ($customers as $customer) { + $response = $request->deleteCustomerProfile($customer); + $this->assertTrue($response->isOk()); + } + + + } + + public function testXPath() + { + + // Create new customer profile + $request = new AuthorizeNetCIM; + $customerProfile = new AuthorizeNetCustomer; + $customerProfile->description = $description = "Some Description of customer 2"; + $customerProfile->merchantCustomerId = $merchantCustomerId = time().rand(1,150); + $customerProfile->email = $email = "test2@domain.com"; + + // Add payment profile. + $paymentProfile = new AuthorizeNetPaymentProfile; + $paymentProfile->customerType = "individual"; + $paymentProfile->payment->creditCard->cardNumber = "4111111111111111"; + $paymentProfile->payment->creditCard->expirationDate = "2021-04"; + $customerProfile->paymentProfiles[] = $paymentProfile; + + $response = $request->createCustomerProfile($customerProfile); + $this->assertTrue($response->isOk()); + $array = $response->xpath('customerProfileId'); + $this->assertEquals($response->getCustomerProfileId(), "{$array[0]}"); + + $profile = $request->getCustomerProfile($response->getCustomerProfileId()); + + $this->assertEquals($email, (string)array_pop($profile->xpath('profile/email'))); + $this->assertEquals($email, (string)array_pop($profile->xpath('profile/email'))); + $this->assertEquals($description, (string)array_pop($profile->xpath('profile/description'))); + $this->assertEquals($merchantCustomerId, (string)array_pop($profile->xpath('profile/merchantCustomerId'))); + + } + + + + public function testCreateCustomerProfile() + { + // Create new customer profile + $request = new AuthorizeNetCIM; + $customerProfile = new AuthorizeNetCustomer; + $customerProfile->description = "Description of customer"; + $customerProfile->merchantCustomerId = time().rand(1,100); + $customerProfile->email = "blahbla@domain.com"; + + // Add payment profile. + $paymentProfile = new AuthorizeNetPaymentProfile; + $paymentProfile->customerType = "individual"; + $paymentProfile->payment->creditCard->cardNumber = "4111111111111111"; + $paymentProfile->payment->creditCard->expirationDate = "2015-10"; + $customerProfile->paymentProfiles[] = $paymentProfile; + + // Add another payment profile. + $paymentProfile2 = new AuthorizeNetPaymentProfile; + $paymentProfile2->customerType = "business"; + $paymentProfile2->payment->bankAccount->accountType = "businessChecking"; + $paymentProfile2->payment->bankAccount->routingNumber = "121042882"; + $paymentProfile2->payment->bankAccount->accountNumber = "123456789123"; + $paymentProfile2->payment->bankAccount->nameOnAccount = "Jane Doe"; + $paymentProfile2->payment->bankAccount->echeckType = "WEB"; + $paymentProfile2->payment->bankAccount->bankName = "Pandora Bank"; + $customerProfile->paymentProfiles[] = $paymentProfile2; + + + // Add shipping address. + $address = new AuthorizeNetAddress; + $address->firstName = "john"; + $address->lastName = "Doe"; + $address->company = "John Doe Company"; + $address->address = "1 Main Street"; + $address->city = "Boston"; + $address->state = "MA"; + $address->zip = "02412"; + $address->country = "USA"; + $address->phoneNumber = "555-555-5555"; + $address->faxNumber = "555-555-5556"; + $customerProfile->shipToList[] = $address; + + // Add another shipping address. + $address2 = new AuthorizeNetAddress; + $address2->firstName = "jane"; + $address2->lastName = "Doe"; + $address2->address = "11 Main Street"; + $address2->city = "Boston"; + $address2->state = "MA"; + $address2->zip = "02412"; + $address2->country = "USA"; + $address2->phoneNumber = "555-512-5555"; + $address2->faxNumber = "555-523-5556"; + $customerProfile->shipToList[] = $address2; + + $response = $request->createCustomerProfile($customerProfile); + $this->assertTrue($response->isOk()); + $this->assertEquals(2, count($response->getCustomerShippingAddressIds())); + $this->assertEquals(2, count($response->getCustomerPaymentProfileIds())); + $customerProfileId = $response->getCustomerProfileId(); + + $this->assertEquals($response->getCustomerProfileId(), "{$response->xml->customerProfileId}"); + + + + $response = $request->getCustomerProfile($customerProfileId); + $this->assertEquals($customerProfile->description, (string)$response->xml->profile->description); + $this->assertEquals($customerProfile->merchantCustomerId, (string)$response->xml->profile->merchantCustomerId); + $this->assertEquals($customerProfile->email, (string)$response->xml->profile->email); + $this->assertEquals(substr($customerProfile->paymentProfiles[0]->payment->creditCard->cardNumber, -4, 4), substr((string)$response->xml->profile->paymentProfiles->payment->creditCard->cardNumber, -4, 4)); + + + + $this->assertTrue($response->isOk()); + + + } + + public function testGetCustomerProfile() + { + // Create new customer profile + $request = new AuthorizeNetCIM; + $customerProfile = new AuthorizeNetCustomer; + $customerProfile->description = "Description of customer"; + $customerProfile->merchantCustomerId = time().rand(1,10); + $customerProfile->email = "blahlah@domain.com"; + $response = $request->createCustomerProfile($customerProfile); + $this->assertTrue($response->isOk()); + $customerProfileId = $response->getCustomerProfileId(); + + $response = $request->getCustomerProfile($customerProfileId); + + $this->assertTrue($response->isOk()); + + } + + public function testCreateCustomerProfileWithValidationMode() + { + // Create new customer profile + $request = new AuthorizeNetCIM; + $customerProfile = new AuthorizeNetCustomer; + $customerProfile->description = "Some Description of customer 2"; + $customerProfile->merchantCustomerId = time().rand(1,10); + $customerProfile->email = "test2@domain.com"; + + // Add payment profile. + $paymentProfile = new AuthorizeNetPaymentProfile; + $paymentProfile->customerType = "individual"; + $paymentProfile->payment->creditCard->cardNumber = "4111111111111111"; + $paymentProfile->payment->creditCard->expirationDate = "2015-04"; + $customerProfile->paymentProfiles[] = $paymentProfile; + + // Add another payment profile. + $paymentProfile2 = new AuthorizeNetPaymentProfile; + $paymentProfile2->customerType = "individual"; + $paymentProfile2->payment->creditCard->cardNumber = "4222222222222"; + $paymentProfile2->payment->creditCard->expirationDate = "2019-10"; + $customerProfile->paymentProfiles[] = $paymentProfile2; + + $response = $request->createCustomerProfile($customerProfile, "testMode"); + + $this->assertTrue($response->isOk()); + + $validationResponses = $response->getValidationResponses(); + foreach ($validationResponses as $vr) { + $this->assertTrue($vr->approved); + } + + } + + public function testUpdateSplitTenderGroup() + { + // Create a partial auth test transaction + $amount = 4.92; + + $sale = new AuthorizeNetAIM; + $sale->amount = $amount; + $sale->card_num = '4222222222222'; + $sale->zip = "46225"; + $sale->exp_date = '04/24'; + $sale->allow_partial_auth = true; + $response = $sale->authorizeAndCapture(); + $this->assertTrue($response->held); + $this->assertEquals("1.23", $response->amount); + $this->assertEquals($amount, $response->requested_amount); + $split_tender_id = $response->split_tender_id; + + // Charge a bit more + $sale = new AuthorizeNetAIM; + $sale->amount = 1.23; + $sale->card_num = '6011000000000012'; + $sale->exp_date = '04/26'; + $sale->split_tender_id = $split_tender_id; + $sale->allow_partial_auth = true; + $response = $sale->authorizeAndCapture(); + $this->assertTrue($response->approved); + + // Void the group of partial auths. + + $request = new AuthorizeNetCIM; + $response = $request->updateSplitTenderGroup($split_tender_id, "voided"); + $this->assertTrue($response->isOk()); + } + + public function testAll() + { + // Create new customer profile + $request = new AuthorizeNetCIM; + $customerProfile = new AuthorizeNetCustomer; + $customerProfile->description = "Description of customer"; + $customerProfile->merchantCustomerId = time().rand(1,10); + $customerProfile->email = "blahblahblah@domain.com"; + $response = $request->createCustomerProfile($customerProfile); + $this->assertTrue($response->isOk()); + $customerProfileId = $response->getCustomerProfileId(); + + // Update customer profile + $customerProfile->description = "New description"; + $customerProfile->email = "newemail@domain.com"; + $response = $request->updateCustomerProfile($customerProfileId, $customerProfile); + $this->assertTrue($response->isOk()); + + // Add payment profile. + $paymentProfile = new AuthorizeNetPaymentProfile; + $paymentProfile->customerType = "individual"; + $paymentProfile->payment->creditCard->cardNumber = "4111111111111111"; + $paymentProfile->payment->creditCard->expirationDate = "2015-10"; + $response = $request->createCustomerPaymentProfile($customerProfileId, $paymentProfile); + $this->assertTrue($response->isOk()); + $paymentProfileId = $response->getPaymentProfileId(); + + // Update payment profile. + $paymentProfile->payment->creditCard->cardNumber = "4111111111111111"; + $paymentProfile->payment->creditCard->expirationDate = "2017-11"; + $response = $request->updateCustomerPaymentProfile($customerProfileId,$paymentProfileId, $paymentProfile); + $this->assertTrue($response->isOk()); + + // Add shipping address. + $address = new AuthorizeNetAddress; + $address->firstName = "john"; + $address->lastName = "Doe"; + $address->company = "John Doe Company"; + $address->address = "1 Main Street"; + $address->city = "Boston"; + $address->state = "MA"; + $address->zip = "02412"; + $address->country = "USA"; + $address->phoneNumber = "555-555-5555"; + $address->faxNumber = "555-555-5556"; + $response = $request->createCustomerShippingAddress($customerProfileId, $address); + $this->assertTrue($response->isOk()); + $customerAddressId = $response->getCustomerAddressId(); + + // Update shipping address. + $address->address = "2 First Street"; + $response = $request->updateCustomerShippingAddress($customerProfileId, $customerAddressId, $address); + $this->assertTrue($response->isOk()); + + // Create Auth & Capture Transaction + $transaction = new AuthorizeNetTransaction; + $transaction->amount = "9.79"; + $transaction->customerProfileId = $customerProfileId; + $transaction->customerPaymentProfileId = $paymentProfileId; + $transaction->customerShippingAddressId = $customerAddressId; + + $lineItem = new AuthorizeNetLineItem; + $lineItem->itemId = "4"; + $lineItem->name = "Cookies"; + $lineItem->description = "Chocolate Chip"; + $lineItem->quantity = "4"; + $lineItem->unitPrice = "1.00"; + $lineItem->taxable = "true"; + + $lineItem2 = new AuthorizeNetLineItem; + $lineItem2->itemId = "4"; + $lineItem2->name = "Cookies"; + $lineItem2->description= "Peanut Butter"; + $lineItem2->quantity = "4"; + $lineItem2->unitPrice = "1.00"; + $lineItem2->taxable = "true"; + + $transaction->lineItems[] = $lineItem; + $transaction->lineItems[] = $lineItem2; + + + $response = $request->createCustomerProfileTransaction("AuthCapture", $transaction); + $this->assertTrue($response->isOk()); + $transactionResponse = $response->getTransactionResponse(); + $this->assertTrue($transactionResponse->approved); + $transactionId = $transactionResponse->transaction_id; + + // Void the transaction + $transaction = new AuthorizeNetTransaction; + $transaction->transId = $transactionId; + $response = $request->createCustomerProfileTransaction("Void", $transaction); + $this->assertTrue($response->isOk()); + $transactionResponse = $response->getTransactionResponse(); + $this->assertTrue($transactionResponse->approved); + + + // Delete Shipping Address + $response = $request->deleteCustomerShippingAddress($customerProfileId, $customerAddressId); + $this->assertTrue($response->isOk()); + + // Delete payment profile. + $response = $request->deleteCustomerPaymentProfile($customerProfileId, $paymentProfileId); + $this->assertTrue($response->isOk()); + + + // Delete the profile id for future testing. + $response = $request->deleteCustomerProfile($customerProfileId); + $this->assertTrue($response->isOk()); + } + + + + + public function testGetCustomerProfileIds() + { + // Create new customer profile + $request = new AuthorizeNetCIM; + $customerProfile = new AuthorizeNetCustomer; + $customerProfile->description = "Description of customer"; + $customerProfile->merchantCustomerId = time().rand(1,10); + $customerProfile->email = "blahblahblah@domain.com"; + $response = $request->createCustomerProfile($customerProfile); + $this->assertTrue($response->isOk()); + $customerProfileId = $response->getCustomerProfileId(); + + $response = $request->getCustomerProfileIds(); + $this->assertTrue($response->isOk()); + $this->assertTrue(in_array($customerProfileId, $response->getCustomerProfileIds())); + + + } + + + + +} \ No newline at end of file diff --git a/anet_php_sdk/tests/AuthorizeNetCP_Test.php b/anet_php_sdk/tests/AuthorizeNetCP_Test.php new file mode 100755 index 0000000..aa8c580 --- /dev/null +++ b/anet_php_sdk/tests/AuthorizeNetCP_Test.php @@ -0,0 +1,179 @@ +setFields( + array( + 'amount' => rand(1, 1000), + 'card_num' => '4111111111111111', + 'exp_date' => '0415', + 'device_type' => '4', + ) + ); + $response = $sale->authorizeAndCapture(); + $this->assertTrue($response->approved); + } + + // public function testMd5() + // { + // return; + // $sale = new AuthorizeNetCP(CP_API_LOGIN_ID, CP_TRANSACTION_KEY); + // $sale->setFields( + // array( + // 'amount' => rand(1, 1000), + // 'card_num' => '4111111111111111', + // 'exp_date' => '0415', + // 'device_type' => '4', + // ) + // ); + // $response = $sale->authorizeAndCapture(); + // $this->assertTrue($response->approved); + // $this->assertTrue($response->isAuthorizeNet(CP_API_LOGIN_ID)); + // } + + public function testAuthCaptureTrack1() + { + $sale = new AuthorizeNetCP(CP_API_LOGIN_ID, CP_TRANSACTION_KEY); + $sale->setFields( + array( + 'amount' => rand(1, 1000), + 'device_type' => '4', + ) + ); + $sale->setTrack1Data('%B4111111111111111^CARDUSER/JOHN^1803101000000000020000831000000?'); + $response = $sale->authorizeAndCapture(); + $this->assertTrue($response->approved); + } + + public function testAuthCaptureTrack2() + { + $sale = new AuthorizeNetCP(CP_API_LOGIN_ID, CP_TRANSACTION_KEY); + $sale->setFields( + array( + 'amount' => rand(1, 1000), + 'device_type' => '4', + ) + ); + $sale->setTrack2Data('4111111111111111=1803101000020000831?'); + $response = $sale->authorizeAndCapture(); + $this->assertTrue($response->approved); + } + + public function testAuthCaptureTrack2Error() + { + $sale = new AuthorizeNetCP(CP_API_LOGIN_ID, CP_TRANSACTION_KEY); + $sale->setFields( + array( + 'amount' => rand(1, 1000), + 'device_type' => '4', + ) + ); + $sale->setTrack2Data('4411111111111111=1803101000020000831?'); + $response = $sale->authorizeAndCapture(); + $this->assertFalse($response->approved); + $this->assertTrue($response->error); + $this->assertEquals(6, $response->response_reason_code); + } + + public function testResponseFields() + { + $sale = new AuthorizeNetCP(CP_API_LOGIN_ID, CP_TRANSACTION_KEY); + $sale->setFields( + array( + 'amount' => rand(1, 1000), + 'device_type' => '4', + ) + ); + $sale->user_ref = $user_ref = "someCustomVariable123"; + $sale->setTrack1Data('%B4111111111111111^CARDUSER/JOHN^1803101000000000020000831000000?'); + $response = $sale->authorizeAndCapture(); + + + $this->assertTrue($response->approved); + $this->assertEquals('1.0',$response->version); + $this->assertEquals('1',$response->response_code); + $this->assertEquals('1',$response->response_reason_code); + $this->assertEquals('(TESTMODE) This transaction has been approved.',$response->response_reason_text); + $this->assertEquals('000000',$response->authorization_code); + $this->assertEquals('P',$response->avs_code); + $this->assertEquals('',$response->card_code_response); + $this->assertEquals('0',$response->transaction_id); + $this->assertStringMatchesFormat('%x',$response->md5_hash); + $this->assertEquals($user_ref, $response->user_ref); + $this->assertEquals('XXXX1111',$response->card_num); + $this->assertEquals('Visa',$response->card_type); + + + } + + public function testXmlResponse() + { + $sale = new AuthorizeNetCP(CP_API_LOGIN_ID, CP_TRANSACTION_KEY); + $sale->setFields( + array( + 'amount' => rand(1, 1000), + 'device_type' => '4', + 'response_format' => '0', + ) + ); + $sale->user_ref = $user_ref = "dummyvalue323"; + $sale->setTrack1Data('%B4111111111111111^CARDUSER/JOHN^1803101000000000020000831000000?'); + $response = $sale->authorizeAndCapture(); + + + $this->assertTrue($response->approved); + $this->assertEquals('1.0',$response->version); + $this->assertEquals('1',$response->response_code); + $this->assertEquals('1',$response->response_reason_code); + $this->assertEquals('This transaction has been approved.',$response->response_reason_text); + $this->assertEquals('000000',$response->authorization_code); + $this->assertEquals('P',$response->avs_code); + $this->assertEquals('',$response->card_code_response); + $this->assertEquals('0',$response->transaction_id); + $this->assertStringMatchesFormat('%x',$response->md5_hash); + $this->assertEquals($user_ref, $response->user_ref); + $this->assertEquals('XXXX1111',$response->card_num); + $this->assertEquals('Visa',$response->card_type); + + + } + + public function testXmlResponseFailure() + { + $sale = new AuthorizeNetCP(CP_API_LOGIN_ID, CP_TRANSACTION_KEY); + $sale->setFields( + array( + 'amount' => rand(1, 1000), + 'device_type' => '4', + 'response_format' => '0', + ) + ); + $sale->user_ref = $user_ref = "dummyvalue323"; + $sale->setTrack1Data('%B4111111111111^CARDUSER/JOHN^1803101000000000020000831000000?'); + $response = $sale->authorizeAndCapture(); + + + $this->assertTrue($response->error); + $this->assertEquals('1.0',$response->version); + $this->assertEquals('3',$response->response_code); + $this->assertEquals('6',$response->response_reason_code); + $this->assertEquals('The credit card number is invalid.',$response->response_reason_text); + $this->assertEquals('000000',$response->authorization_code); + $this->assertEquals('P',$response->avs_code); + $this->assertEquals('',$response->card_code_response); + $this->assertEquals('0',$response->transaction_id); + $this->assertStringMatchesFormat('%x',$response->md5_hash); + $this->assertEquals($user_ref, $response->user_ref); + $this->assertEquals('XXXX1111',$response->card_num); + + + } + + +} \ No newline at end of file diff --git a/anet_php_sdk/tests/AuthorizeNetDPM_Test.php b/anet_php_sdk/tests/AuthorizeNetDPM_Test.php new file mode 100755 index 0000000..78b7e5a --- /dev/null +++ b/anet_php_sdk/tests/AuthorizeNetDPM_Test.php @@ -0,0 +1,25 @@ +assertEquals("db88bbebb8f699acdbe70daad897a68a",AuthorizeNetDPM::getFingerprint("123","123","123","123","123")); + } + + public function testGetCreditCardForm() + { + $fp_sequence = "12345"; + $this->assertContains('',AuthorizeNetDPM::getCreditCardForm('2', $fp_sequence, 'ht', '2', '1', true)); + } + + public function testRelayResponseUrl() + { + $return_url = 'http://yourdomain.com'; + + $this->assertContains('window.location="'.$return_url.'";', AuthorizeNetDPM::getRelayResponseSnippet($return_url)); + } + +} \ No newline at end of file diff --git a/anet_php_sdk/tests/AuthorizeNetSIM_Test.php b/anet_php_sdk/tests/AuthorizeNetSIM_Test.php new file mode 100755 index 0000000..62ef5a3 --- /dev/null +++ b/anet_php_sdk/tests/AuthorizeNetSIM_Test.php @@ -0,0 +1,56 @@ +assertEquals("8FC33C32ABB3EDD8BBC4BE3E904CB47E",$message->generateHash()); + } + + public function testAmount() + { + $_POST['x_amount'] = "4.12"; + $_POST['x_response_code'] = "1"; + $message = new AuthorizeNetSIM("528udYYwz","test"); + $this->assertEquals("4.12",$message->amount); + $this->assertTrue($message->approved); + } + + public function testIsAuthNet() + { + $_POST['x_amount'] = "4.12"; + $_POST['x_trans_id'] = "123"; + $_POST['x_MD5_Hash'] = "8FC33C32ABB3EDD8BBC4BE3E904CB47E"; + $message = new AuthorizeNetSIM("528udYYwz","test"); + $this->assertTrue($message->isAuthorizeNet()); + + + $_POST['x_amount'] = "4.12"; + $_POST['x_trans_id'] = "123"; + $_POST['x_MD5_Hash'] = "8FC33C32BB3EDD8BBC4BE3E904CB47E"; + $message = new AuthorizeNetSIM("528udYYwz","test"); + $this->assertFalse($message->isAuthorizeNet()); + } + + public function testIsError() + { + $_POST['x_amount'] = "4.12"; + $_POST['x_response_code'] = "3"; + $_POST['x_ship_to_state'] = "CA"; + $message = new AuthorizeNetSIM("528udYYwz","test"); + $this->assertEquals("3",$message->response_code); + $this->assertTrue($message->error); + $this->assertFalse($message->approved); + $this->assertEquals("CA",$message->ship_to_state); + } + + + + +} \ No newline at end of file diff --git a/anet_php_sdk/tests/AuthorizeNetSSL_Test.php b/anet_php_sdk/tests/AuthorizeNetSSL_Test.php new file mode 100755 index 0000000..b4191e1 --- /dev/null +++ b/anet_php_sdk/tests/AuthorizeNetSSL_Test.php @@ -0,0 +1,23 @@ +&1", $output, $return_value); + $this->assertEquals(0, $return_value); + $this->assertTrue(in_array('Verify return code: 0 (ok)', array_map('trim', $output))); + exec("echo | openssl s_client -connect apitest.authorize.net:443 -showcerts -verify 10 -CAfile ../lib/ssl/cert.pem 2>&1", $output, $return_value); + $this->assertEquals(0, $return_value); + $this->assertTrue(in_array('Verify return code: 0 (ok)', array_map('trim', $output))); + } + + public function testLiveSSLCertIsValid() + { + exec("echo | openssl s_client -connect secure.authorize.net:443 -showcerts -verify 10 -CAfile ../lib/ssl/cert.pem 2>&1", $output, $return_value); + $this->assertEquals(0, $return_value); + $this->assertTrue(in_array('Verify return code: 0 (ok)', array_map('trim', $output))); + exec("echo | openssl s_client -connect api.authorize.net:443 -showcerts -verify 10 -CAfile ../lib/ssl/cert.pem 2>&1", $output, $return_value); + $this->assertEquals(0, $return_value); + $this->assertTrue(in_array('Verify return code: 0 (ok)', array_map('trim', $output))); + } +} diff --git a/anet_php_sdk/tests/AuthorizeNetTD_Test.php b/anet_php_sdk/tests/AuthorizeNetTD_Test.php new file mode 100755 index 0000000..4e12168 --- /dev/null +++ b/anet_php_sdk/tests/AuthorizeNetTD_Test.php @@ -0,0 +1,96 @@ +getSettledBatchList(); + $this->assertTrue($response->isOk()); + $this->assertEquals("I00001",(string)array_pop($response->xpath("messages/message/code"))); + } + + public function testGetSettledBatchListIncludeStatistics() + { + $request = new AuthorizeNetTD; + $response = $request->getSettledBatchList(true); + $this->assertTrue($response->isOk()); + } + + public function testGetSettledBatchListForMonth() + { + $request = new AuthorizeNetTD; + $response = $request->getSettledBatchListForMonth(); + $this->assertTrue($response->isOk()); + } + + public function testGetTransactionsForDay() + { + $request = new AuthorizeNetTD; + $transactions = $request->getTransactionsForDay(12, 8, 2010); + $this->assertTrue(is_array($transactions)); + } + + public function testGetTransactionList() + { + $request = new AuthorizeNetTD; + $response = $request->getSettledBatchList(); + $this->assertTrue($response->isOk()); + $batches = $response->xpath("batchList/batch"); + $batch_id = (string)$batches[0]->batchId; + $response = $request->getTransactionList($batch_id); + $this->assertTrue($response->isOk()); + } + + public function testGetTransactionDetails() + { + $sale = new AuthorizeNetAIM; + $amount = rand(1, 100); + $response = $sale->authorizeAndCapture($amount, '4012888818888', '04/17'); + $this->assertTrue($response->approved); + + $transId = $response->transaction_id; + + $request = new AuthorizeNetTD; + $response = $request->getTransactionDetails($transId); + $this->assertTrue($response->isOk()); + + $this->assertEquals($transId, (string)$response->xml->transaction->transId); + $this->assertEquals($amount, (string)$response->xml->transaction->authAmount); + $this->assertEquals("Visa", (string)$response->xml->transaction->payment->creditCard->cardType); + + } + + public function testGetUnsettledTransactionList() + { + $sale = new AuthorizeNetAIM; + $amount = rand(1, 100); + $response = $sale->authorizeAndCapture($amount, '4012888818888', '04/17'); + $this->assertTrue($response->approved); + + $request = new AuthorizeNetTD; + $response = $request->getUnsettledTransactionList(); + $this->assertTrue($response->isOk()); + $this->assertTrue($response->xml->transactions->count() >= 1); + } + + public function testGetBatchStatistics() + { + $request = new AuthorizeNetTD; + $response = $request->getSettledBatchList(); + $this->assertTrue($response->isOk()); + $this->assertTrue($response->xml->batchList->count() >= 1); + $batchId = $response->xml->batchList->batch[0]->batchId; + + $request = new AuthorizeNetTD; + $response = $request->getBatchStatistics($batchId); + $this->assertTrue($response->isOk()); + } + + +} \ No newline at end of file diff --git a/anet_php_sdk/tests/AuthorizeNet_SOAP_Test.php b/anet_php_sdk/tests/AuthorizeNet_SOAP_Test.php new file mode 100755 index 0000000..20b87d7 --- /dev/null +++ b/anet_php_sdk/tests/AuthorizeNet_SOAP_Test.php @@ -0,0 +1,31 @@ +assertTrue($client->saveSoapDocumentation($filepath) > 1); + unlink($filepath); + } + + public function testGetCustomerIds () + { + $client = new AuthorizeNetSOAP; + $result = $client->GetCustomerProfileIds( + array( + 'merchantAuthentication' => array( + 'name' => AUTHORIZENET_API_LOGIN_ID, + 'transactionKey' => AUTHORIZENET_TRANSACTION_KEY, + ), + ) + ); + $customer_ids = $result->GetCustomerProfileIdsResult->ids->long; + $this->assertTrue(is_array($customer_ids)); + } + +} \ No newline at end of file diff --git a/anet_php_sdk/tests/AuthorizeNet_Test_Config.php b/anet_php_sdk/tests/AuthorizeNet_Test_Config.php new file mode 100755 index 0000000..1038042 --- /dev/null +++ b/anet_php_sdk/tests/AuthorizeNet_Test_Config.php @@ -0,0 +1,47 @@ +

AuthorizeNet_SOAP_

AuthorizeNetAIM_Sandbox_

AuthorizeNetAIM_Live_

AuthorizeNetARB_

AuthorizeNetCIM_

AuthorizeNetCP_

AuthorizeNetDPM_

AuthorizeNetSIM_

AuthorizeNetTD_

\ No newline at end of file diff --git a/css/glm-donate-admin.css b/css/glm-donate-admin.css new file mode 100755 index 0000000..254f0ac --- /dev/null +++ b/css/glm-donate-admin.css @@ -0,0 +1,302 @@ +/* +* GLM-donate - Default Stylesheet +*/ + +h1.donate-title { + color:#ddd; + margin-bottom:20px; +} + +#glm-donate-tab-settings th { + width:280px; +} + +#glm-donate-tab-settings ul { + padding-left:20px; +} + +#glm-donate-tab-settings li { + list-style: disc; + list-style-type:none; +} + +/* jQuery Tabs */ + +ul#glm-donate-tabs-nav { + position:relative; + margin-bottom:10px; + height:41px; + overflow:visible; + border-bottom:1px solid #ddd +} + +ul#glm-donate-tabs-nav li { + text-align:center; + position:relative; + display:block; + float:left; + width:130px; + height:40px; + margin:0 10px 0 2px; + border-top:1px solid #cccccc; + border-left:1px solid #cccccc; + border-right:1px solid #cccccc; + background: #f2f2f2; + overflow:visible; + -moz-border-radius-topleft: 7px; + -moz-border-radius-topright: 0px; + -webkit-border-radius: 7px 7px 0px 0px; + border-radius: 7px 7px 0px 0px; + opacity:0.8; +} + +ul#glm-donate-tabs-nav li.ui-state-active, +ul#glm-donate-tabs-nav li:hover { + background: #fff; + opacity:1; +} + +ul#glm-donate-tabs-nav li.ui-state-active a:before, +ul#glm-donate-tabs-nav li:hover a:before { + position: absolute; + content: " "; + top:0; + bottom:-1px; + left:0; + right:0; + border-bottom:1px solid #fff; + z-index:200; +} + +ul#glm-donate-tabs-nav li a { + position:absolute; + top:0; + left:0; + color:#777; + display:block; + padding:10px 15px; + height:20px; + line-height:20px; + width:100px; + text-decoration: none; + text-shadow: 0 1px 1px rgba(255,255,255,0.8); + text-transform:uppercase; + overflow:visible; +} + +ul#glm-donate-tabs-nav li.ui-state-active { + background: #fff; +} + +ul#glm-donate-tabs-nav li.ui-state-active a { + color:#555; +} + +/* Transactions Table */ + +table.glm-donate-projects, +table.glm-donate-transactions { + margin-top:20px; + border-spacing: 0px; + width:95%; +} + +table.glm-donate-projects thead, +table.glm-donate-transactions thead { + position:relative; + background-color:#f2f2f2; +} + +table.glm-donate-projects tr.glm-donate-absolute, +table.glm-donate-transactions tr.glm-donate-absolute { + position:absolute; + z-index:0; + width:95%; + height:38px; +} + +table.glm-donate-projects tr.glm-donate-absolute:before, +table.glm-donate-transactions tr.glm-donate-absolute:before { + content: ''; + position:absolute; + z-index:2; + display:block; + top:1px; + left:0; + bottom:1px; + right:0; + -webkit-border-radius: 7px; + -moz-border-radius: 7px; + border-radius: 7px; + -webkit-box-shadow: inset 0px 1px 1px 0px rgba(0, 0, 0, 0.15),inset 0px 2px 3px 1px rgba(0, 0, 0, 0.1); + -moz-box-shadow: inset 0px 1px 1px 0px rgba(0, 0, 0, 0.15),inset 0px 2px 3px 1px rgba(0, 0, 0, 0.1); + box-shadow: inset 0px 1px 1px 0px rgba(0, 0, 0, 0.15),inset 0px 2px 3px 1px rgba(0, 0, 0, 0.1); +} + +table.glm-donate-projects th, +table.glm-donate-transactions th { + border-top: 1px solid #fff; + border-bottom: 1px solid #ddd; +} + +table.glm-donate-projects th, +table.glm-donate-transactions th { + text-align:left; + color:#777; + text-shadow: 0 1px 0px #ffffff; +} + + +table.glm-donate-transactions td img.avatar { + float:left; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; +} + +table.glm-donate-transactions td span.donate-name { + line-height:30px; + padding-left:15px; +} + +table.glm-donate-transactions td.donate-comment { + font-style:italic; + font-family:serif; + color:#777; + font-size:14px; + line-height:14px; +} + +table.glm-donate-transactions span.donate-netamount { + color:#07DE00; + font-weight:bold; + font-size:14px; +} + +table.glm-donate-projects th:first-child, +table.glm-donate-transactions th:first-child { + -moz-border-radius-topleft: 7px; + -moz-border-radius-topright: 0px; + -moz-border-radius-bottomright: 0px; + -moz-border-radius-bottomleft: 7px; + -webkit-border-radius: 7px 0px 0px 7px; + border-radius: 7px 0px 0px 7px; +} + +table.glm-donate-projects th:last-child, +table.glm-donate-transactions th:last-child { + -moz-border-radius-topleft: 0px; + -moz-border-radius-topright: 7px; + -moz-border-radius-bottomright: 7px; + -moz-border-radius-bottomleft: 0px; + -webkit-border-radius: 0px 7px 7px 0px; + border-radius: 0px 7px 7px 0px; +} + +table.glm-donate-projects tr td, +table.glm-donate-transactions tr td { + border-bottom: 1px solid #ddd; +} + +table.glm-donate-projects tr th, +table.glm-donate-projects tr td, +table.glm-donate-transactions tr th, +table.glm-donate-transactions tr td { + padding: 10px 15px; +} + +.dot-donate-live { + margin-right:10px; + position:relative; + top:2px; + display:inline-block; + background:#07DE00; + width:12px; + height:12px; + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; + -webkit-box-shadow: inset 0px 3px 2px 1px rgba(255, 255, 255, 0.2); + -moz-box-shadow: inset 0px 3px 2px 1px rgba(255, 255, 255, 0.2); + box-shadow: inset 0px 5px 3px 1px rgba(255, 255, 255, 0.2); +} + +.dot-donate-public { + margin-right:10px; + position:relative; + top:2px; + display:inline-block; + background:#0068DE; + width:12px; + height:12px; + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; + -webkit-box-shadow: inset 0px 3px 2px 1px rgba(255, 255, 255, 0.2); + -moz-box-shadow: inset 0px 3px 2px 1px rgba(255, 255, 255, 0.2); + box-shadow: inset 0px 5px 3px 1px rgba(255, 255, 255, 0.2); +} + +.dot-donate-test { + margin-right:10px; + position:relative; + top:2px; + display:inline-block; + background:#ddd; + width:12px; + height:12px; + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; + -webkit-box-shadow: inset 0px 2px 2px 1px rgba(0,0,0, 0.1); + -moz-box-shadow: inset 0px 2px 2px 1px rgba(0,0,0, 0.1); + box-shadow: inset 0px 2px 3px 1px rgba(0,0,0, 0.1); +} + +.progress-donate-wrap { + position:relative; + display:block; + background:#ddd; + width:100px; + height:16px; + -webkit-border-radius: 8px; + -moz-border-radius: 8px; + border-radius: 8px; + -webkit-box-shadow: inset 0px 2px 2px 1px rgba(0,0,0, 0.1); + -moz-box-shadow: inset 0px 2px 2px 1px rgba(0,0,0, 0.1); + box-shadow: inset 0px 2px 3px 1px rgba(0,0,0, 0.1); +} + +.progress-donate-value { + margin-right:10px; + position:absolute; + z-index:50; + top:2px; + left:2px; + display:block; + background:#0068DE; + height:12px; + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; + -webkit-box-shadow: inset 0px 3px 2px 1px rgba(255, 255, 255, 0.2); + -moz-box-shadow: inset 0px 3px 2px 1px rgba(255, 255, 255, 0.2); + box-shadow: inset 0px 5px 3px 1px rgba(255, 255, 255, 0.2); +} + +#glm-donate-tab-transactions form.pagination { + display:inline; + float:left; + margin:10px 10px 0 0; +} + +.glm-donate-absolute +{ +background:linear-gradient(to top, #373737 0px, #464646 5px) repeat scroll 0 0 #464646; +color:#ffffff; +} + +.required { + color: red; + padding-left: 5px; +} diff --git a/css/glm-donate-display.css b/css/glm-donate-display.css new file mode 100755 index 0000000..1a6a946 --- /dev/null +++ b/css/glm-donate-display.css @@ -0,0 +1,351 @@ +/* +* GLM-donate - Default Stylesheet +*/ + +#glm-donate-wrap { + display:block; + padding:10px; + margin:0px; + width: 400px; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important; +} + +/* Payment Form Link */ + +#glm-donate-modal-button { + margin:20px 0; + padding: 8px 15px; + min-width:100px; + display:inline-block; + text-align:center; + font-weight: bold; + font-size: 12px; + background: #1275FF; + border: 1px solid #155FB0; + color: white; + text-decoration: none; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); + background-image: -webkit-gradient(linear, left top, left bottom, from(#77B7FF), to(#017AFF)); + background-image: -moz-linear-gradient(top, #77B7FF, #017AFF); + background-image: -o-linear-gradient(top, #77B7FF, #017AFF); + -webkit-box-shadow: inset 0 1px 0 #98c9ff; + -moz-box-shadow: inset 0 1px 0 #98c9ff; + box-shadow: inset 0 1px 0 #98c9ff; + -o-border-radius: 4px; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + border-radius: 4px; + cursor: pointer; cursor: hand; +} + +#glm-donate-types { + display:block; + width:256px; + height:18px; + background: url('../images/types.png') no-repeat top left; + margin-bottom:20px; +} + +/* Payment Form Elements */ + +form#glm-donate-payment-form { + display:block; +} + +.donate-row-right, +.donate-row-left{width:50%;} + +form#glm-donate-payment-form h2.donate-header { + padding:10px; + color:#fff; + font-size:14px; + font-weight:bold; + text-shadow: 0 -1px 1px rgba(0,0,0,0.3); + border-top:1px solid #268DFC; + border-bottom:1px solid #004EA2; + background:#0068DE; + margin-bottom:10px; + -moz-border-radius-topleft: 5px; + -moz-border-radius-topright: 5px; + -moz-border-radius-bottomright: 0px; + -moz-border-radius-bottomleft: 0px; + -webkit-border-radius: 5px 5px 0px 0px; + border-radius: 5px 5px 0px 0px; +} + +form#glm-donate-payment-form p.donate-display-comment { + margin:3px 0; + font-size:12px; + color:#777; +} + +form#glm-donate-payment-form label { + letter-spacing:1px; + text-transform:uppercase; +} + +form#glm-donate-payment-form .donate-row { + overflow:visible; + clear:both; + padding:5px 10px; +} + +form#glm-donate-payment-form .donate-row-left, +form#glm-donate-payment-form .donate-row-right { + float:left; + overflow:auto; +} + +form#glm-donate-payment-form .donate-submit-button { + position:relative; + margin:10px; + padding: 8px 15px; + display:block; + font-weight: bold; + font-size: 12px; + background: #1275FF; + border: 1px solid #155FB0; + color: white; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); + background-image: -webkit-gradient(linear, left top, left bottom, from(#77B7FF), to(#017AFF)); + background-image: -moz-linear-gradient(top, #77B7FF, #017AFF); + background-image: -o-linear-gradient(top, #77B7FF, #017AFF); + -webkit-box-shadow: inset 0 1px 0 #98c9ff; + -moz-box-shadow: inset 0 1px 0 #98c9ff; + box-shadow: inset 0 1px 0 #98c9ff; + -o-border-radius: 4px; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + border-radius: 4px; + cursor: pointer; cursor: hand; +} + +.donate-spinner { + display:none; + margin:10px; + padding: 8px 15px; + height:15px; + width:70px; + content:" "; + background: url('../images/spinner.gif') no-repeat 50% 50%; + border: 1px solid #afd5ff; + -o-border-radius: 4px; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; +} + +.donate-valid { + color: #638731 !important; + background-color:#d9fba8 !important; +} + +.donate-invalid { + color:#873d31 !important; + background-color:#fbbcb1 !important; +} + +.glm-donate-poweredby { + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important; + color:#777; + font-size:10px; + padding:0 20px; +} + +.glm-donate-poweredby a { + color:#0068DE; + text-decoration: none; +} + +/* Response Styling */ + +.glm-donate-notification { + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 12px; + width:360px; + padding:10px; + margin:10px 0 10px 10px; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; +} + +.glm-donate-currency { + text-transform: uppercase; +} + +.glm-donate-success { + color:#345607; + background-color:#D1F2A5; + text-shadow:0 1px 1px rgba(255,255,255,0.2); +} + +.glm-donate-failure { + color:#4E1E0F; + background-color:#FF9F80; + text-shadow:0 1px 1px rgba(255,255,255,0.1); +} + +/* Form Styling */ + + +form#glm-donate-payment-form .glm-donate-details label { + color:#777; +} + +form#glm-donate-payment-form .glm-donate-card label { + color:#0068DE; +} + +form#glm-donate-payment-form .glm-donate-card input { + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; +} + +form#glm-donate-payment-form .glm-donate-card input.card-cvc { + width:120px; +} + +form#glm-donate-payment-form label, +form#glm-donate-payment-form input, +form#glm-donate-payment-form select, +form#glm-donate-payment-form textarea { + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important; + font-size: 14px !important; + font-weight: normal; + line-height: normal; + margin-bottom: 3px !important; +} +form#glm-donate-payment-form textarea, +form#glm-donate-payment-form input { + position:relative; + width:338px; + background-color:#fff; +} + +input.glm-donate-name {background: url('../images/h-name.png') no-repeat 8px 8px;} +input.glm-donate-email {background: url('../images/h-email.png') no-repeat 8px 10px;} +textarea.glm-donate-comment {background: url('../images/h-comment.png') no-repeat 8px 10px;} +input.glm-donate-card-amount {background: url('../images/h-amount.png') no-repeat 8px 8px;} +input.card-number {background: url('../images/h-card.png') no-repeat 8px 10px;} +input.card-cvc {background: url('../images/h-cvc.png') no-repeat 8px 10px;} + +form#glm-donate-payment-form select { + cursor: pointer; +} + +input[type=checkbox], input[type=radio] { + cursor: pointer; +} + +.donate-expiry { + font-size:12px; + letter-spacing:1px; + color:#bbb; + text-shadow:0 1px 0 #fff; +} + +form#glm-donate-payment-form select { + margin-top:0px !important; + display:block; + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + padding: 2px 7px 2px 7px !important; + height: auto !important; + text-shadow: 0 1px 0 white; + background-image: -webkit-gradient(linear, left top, left bottom, from(#F9F9F9), to(#E8E8E8)); + background-image: -moz-linear-gradient(top, #F9F9F9, #E8E8E8); + background-image: -o-linear-gradient(top, #F9F9F9, #E8E8E8); + -webkit-box-shadow: inset 0 1px 0 white; + -moz-box-shadow: inset 0 1px 0 white; + box-shadow: inset 0 1px 0 white; +} + +form#glm-donate-payment-form select:hover { + background-image: -webkit-gradient(linear, left top, left bottom, from(#E8E8E8), to(#F9F9F9)); + background-image: -moz-linear-gradient(top, #E8E8E8, #F9F9F9); + background-image: -o-linear-gradient(top, #E8E8E8, #F9F9F9); +} + +form#glm-donate-payment-form input, +form#glm-donate-payment-form textarea, +form#glm-donate-payment-form select, +form#glm-donate-payment-form .uneditable-input { + display: inline-block; + height: 18px; + padding: 8px 8px 8px 32px; + font-size: 13px; + line-height: 18px; + color: #808080; + border: 1px solid #ccc; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; +} + +form#glm-donate-payment-form input[type=checkbox], form#glm-donate-payment-form input[type=radio] { + width: auto; + height: auto; + padding: 0; + margin: 3px 0; + *margin-top: 0; + /* IE6-7 */ + + line-height: normal; + border: none; +} + +form#glm-donate-payment-form select { + height: 27px; + line-height: 27px; +} + +form#glm-donate-payment-form input[type=button], form#glm-donate-payment-form input[type=reset], form#glm-donate-payment-form input[type=submit] { + width: auto; + height: auto; +} + +form#glm-donate-payment-form input[type=checkbox] { + position:relative; + top:2px; + margin-right:5px; +} + +form#glm-donate-payment-form select[multiple] { + height: inherit; + background-color: #ffffff; +} +form#glm-donate-payment-form textarea { + height: auto; +} + +:-moz-placeholder { + color: #bfbfbf; +} +::-webkit-input-placeholder { + color: #bfbfbf; +} +form#glm-donate-payment-form input, form#glm-donate-payment-form textarea { + -webkit-transition: border linear 0.2s, box-shadow linear 0.2s; + -moz-transition: border linear 0.2s, box-shadow linear 0.2s; + -ms-transition: border linear 0.2s, box-shadow linear 0.2s; + -o-transition: border linear 0.2s, box-shadow linear 0.2s; + transition: border linear 0.2s, box-shadow linear 0.2s; + -webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1); + -moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1); + box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1); +} +form#glm-donate-payment-form input:focus, form#glm-donate-payment-form textarea:focus { + outline: 0; + border-color: rgba(0, 104, 222, 0.8); + -webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(0, 104, 222, 0.6); + -moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(0, 104, 222, 0.6); + box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(0, 104, 222, 0.6); +} +input[type=file]:focus, input[type=checkbox]:focus, select:focus { + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; + outline: 1px dotted #666; +} diff --git a/css/glm-donate-thickbox.css b/css/glm-donate-thickbox.css new file mode 100755 index 0000000..171f7bb --- /dev/null +++ b/css/glm-donate-thickbox.css @@ -0,0 +1,187 @@ + +/* ----------------------------------------------------------------------------------------------------------------*/ +/* ---------->>> thickbox specific link and font settings <<<------------------------------------------------------*/ +/* ----------------------------------------------------------------------------------------------------------------*/ +#TB_window { + font: 12px "Helvetica Neue", Helvetica, Arial, sans-serif; + color: #333333; +} + +#TB_secondLine { + font: 10px "Helvetica Neue", Helvetica, Arial, sans-serif; + color:#666666; +} + +#TB_window a:link {color: #666666;} +#TB_window a:visited {color: #666666;} +#TB_window a:hover {color: #000;} +#TB_window a:active {color: #666666;} +#TB_window a:focus{color: #666666;} + +/* ----------------------------------------------------------------------------------------------------------------*/ +/* ---------->>> thickbox settings <<<-----------------------------------------------------------------------------*/ +/* ----------------------------------------------------------------------------------------------------------------*/ +#TB_overlay { + position: fixed; + z-index:10000; + top: 0px; + left: 0px; + height:100%; + width:100%; +} + +.TB_overlayMacFFBGHack {background: url(macFFBgHack.png) repeat;} +.TB_overlayBG { + background-color:#000; + -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=75)"; + filter:alpha(opacity=75); + -moz-opacity: 0.75; + opacity: 0.75; +} + +* html #TB_overlay { /* ie6 hack */ + position: absolute; + height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'); +} + +#TB_window { + position: fixed; + background: #ffffff; + z-index: 10002; + color:#000000; + visibility: hidden; + text-align:left; + top:50%; + left:50%; + -moz-box-shadow: rgba(0,0,0,1) 0 4px 30px; + -webkit-box-shadow: rgba(0,0,0,1) 0 4px 30px; + -khtml-box-shadow: rgba(0,0,0,1) 0 4px 30px; + box-shadow: rgba(0,0,0,1) 0 4px 30px; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; + overflow:hidden !important; +} + +#TB_window iframe { + overflow:hidden !important; +} + +* html #TB_window { /* ie6 hack */ + position: absolute; + margin-top: expression(0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px'); +} + +#TB_window img#TB_Image { + display:block; + margin: 15px 0 0 15px; + border-right: 1px solid #ccc; + border-bottom: 1px solid #ccc; + border-top: 1px solid #666; + border-left: 1px solid #666; +} + +#TB_caption{ + height:25px; + padding:7px 30px 10px 25px; + float:left; +} + +#TB_closeWindow{ + height:25px; + padding:11px 25px 10px 0; + float:right; +} + +#TB_closeAjaxWindow{ + padding:6px 10px 0; + text-align:right; + float:right; +} + +#TB_ajaxWindowTitle{ + float:left; + padding:6px 10px 0; +} + +#TB_title{ + color:#fff; + font-size:14px; + font-weight:bold; + text-shadow: 0 -1px 1px rgba(0,0,0,0.3); + background: #2F7ED6; + -webkit-box-shadow: inset 0px 1px 0px 0px #75acea; + -moz-box-shadow: inset 0px 1px 0px 0px #75acea; + box-shadow: inset 0px 1px 0px 0px #75acea; + background-image: -webkit-gradient(linear, left top, left bottom, from(#60A0E7), to(#3A7AC1)); + background-image: -moz-linear-gradient(top, #60A0E7, #3A7AC1); + background-image: -o-linear-gradient(top, #60A0E7, #3A7AC1); + padding:10px; + height:27px; + -moz-border-radius-topleft: 5px; + -moz-border-radius-topright: 5px; + -moz-border-radius-bottomright: 0px; + -moz-border-radius-bottomleft: 0px; + -webkit-border-radius: 5px 5px 0px 0px; + border-radius: 5px 5px 0px 0px; +} + +#TB_ajaxContent{ + clear:both; + padding:2px 15px 15px 15px; + overflow:auto; + text-align:left; + line-height:1.4em; +} + +#TB_ajaxContent.TB_modal{ + padding:15px; +} + +#TB_ajaxContent p{ + padding:5px 0px 5px 0px; +} + +#TB_load{ + position: fixed; + display:none; + z-index:10003; + top: 50%; + left: 50%; + background-color: #E8E8E8; + border: 1px solid #555; + margin: -45px 0pt 0pt -125px; + padding: 40px 15px 15px; +} + +* html #TB_load { /* ie6 hack */ +position: absolute; +margin-top: expression(0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px'); +} + +#TB_HideSelect{ + z-index:9999; + position:fixed; + top: 0; + left: 0; + background-color:#fff; + border:none; + filter:alpha(opacity=0); + -moz-opacity: 0; + opacity: 0; + height:100%; + width:100%; +} + +* html #TB_HideSelect { /* ie6 hack */ + position: absolute; + height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'); +} + +#TB_iframeContent{ + clear:both; + border:none; + margin-bottom:-1px; + _margin-bottom:1px; + overflow:hidden !important; +} diff --git a/css/glm-donate-widget.css b/css/glm-donate-widget.css new file mode 100755 index 0000000..9e879db --- /dev/null +++ b/css/glm-donate-widget.css @@ -0,0 +1,62 @@ +.glm-donate-recent { + +} + +.glm-donate-recent .donate-item { + min-height:70px; + position:relative; + margin:5px 0; +} + +.glm-donate-recent .donate-item img.avatar { + position:absolute; + top:0; + left:0; + width:50px; + height:50px; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; +} + +.glm-donate-recent .donate-item .donate-recent-comment { + padding-left:60px; +} + +.glm-donate-recent .donate-item .donate-recent-content:before { + content:'\2018'; +} + +.glm-donate-recent .donate-item .donate-recent-content:after { + content:'\2019'; +} + +.glm-donate-recent .donate-item .donate-recent-name { + margin: 0 0 0.5em 0; + font-weight:bold; +} + +.glm-donate-recent .donate-item .donate-recent-content { + color:#777; +} + + +.donate_btn_submit +{ +height: 28px; +float: none; +padding: 0 22px; +margin: 0 28px 0 218px; +background: #608e3a; +border: none; +line-height: 28px; +font-size: 14px; +color: #ffffff; +font-family: 'proxima-nova'; +font-weight: bold; +border-radius: 15px; +-webkit-border-radius: 15px; +-moz-border-radius: 15px; +} +.donate_btn_submit:hover { background:#4e7a29; } + diff --git a/includes/donate-display.php b/includes/donate-display.php new file mode 100755 index 0000000..b079fca --- /dev/null +++ b/includes/donate-display.php @@ -0,0 +1,1391 @@ +get_results( "SELECT * FROM ".$wpdb->prefix."donate_setting" ); + define("AUTHORIZENET_API_LOGIN_ID",$mysetting[0]->api_login); // Add your API LOGIN ID + define("AUTHORIZENET_TRANSACTION_KEY",$mysetting[0]->key); // Add your API transaction key + if($mysetting[0]->mod==0){ + define("AUTHORIZENET_SANDBOX",true); // Set to false to test against production + define("TEST_REQUEST", true); // You may want to set to true if testing against production + } + else + { + define("AUTHORIZENET_SANDBOX",false); // Set to false to test against production + define("TEST_REQUEST", false); + } + // You only need to adjust the two variables below if testing DPM + define("AUTHORIZENET_MD5_SETTING",""); // Add your MD5 Setting. + + $REQUEST = $_REQUEST; + if($paypalp = authorizepayment($METHOD_TO_USE,$REQUEST,$address1,$city,$state,$country,$zipcode,$emailaddress,$plan)) + { + $sql = "INSERT INTO `".$wpdb->prefix."donate` (`first_name`, `last_name`, `organization`, `address`, `city`, `country`, `state`, `zip`, `phone`, `email`, `donation_type`, `amount`, `invoice_num`,`comment`, `status`,`date`) + VALUES ('".$first_name."', '".$last_name."','".$organization."','".$address."','".$city."','".$country."','".$state."','".$zip."','".$phone."','".$email."','".$donation_type."','".$amount."','".$invoice_num."','".$comment."', '1',now());"; + $wpdb->query($sql); + + $post = get_post($post->ID); + $slug = $post->post_name; + + header("Location:".site_url().$_SERVER['REQUEST_URI']); + exit; + } + else + { + header("Location:".site_url().$_SERVER['REQUEST_URI']); + exit; + } + + } + } + +function wp_donate_form() { + ob_start(); + global $wpdb; + ?> + + + + diff --git a/includes/donate-display_1.php b/includes/donate-display_1.php new file mode 100644 index 0000000..7dd6fb4 --- /dev/null +++ b/includes/donate-display_1.php @@ -0,0 +1,1367 @@ +get_results( "SELECT * FROM ".$wpdb->prefix."donate_setting" ); + define("AUTHORIZENET_API_LOGIN_ID",$mysetting[0]->api_login); // Add your API LOGIN ID + define("AUTHORIZENET_TRANSACTION_KEY",$mysetting[0]->key); // Add your API transaction key + if($mysetting[0]->mod==0){ + define("AUTHORIZENET_SANDBOX",true); // Set to false to test against production + define("TEST_REQUEST", true); // You may want to set to true if testing against production + } + else + { + define("AUTHORIZENET_SANDBOX",false); // Set to false to test against production + define("TEST_REQUEST", false); + } + // You only need to adjust the two variables below if testing DPM + define("AUTHORIZENET_MD5_SETTING",""); // Add your MD5 Setting. + + $REQUEST = $_REQUEST; + if($paypalp = authorizepayment($METHOD_TO_USE,$REQUEST,$address1,$city,$state,$country,$zipcode,$emailaddress,$plan)) + { + $sql = "INSERT INTO `".$wpdb->prefix."donate` (`first_name`, `last_name`, `organization`, `address`, `city`, `country`, `state`, `zip`, `phone`, `email`, `donation_type`, `amount`, `comment`, `status`,`date`) + VALUES ('".$first_name."', '".$last_name."','".$organization."','".$address."','".$city."','".$country."','".$state."','".$zip."','".$phone."','".$email."','".$donation_type."','".$amount."','".$comment."', '1',now());"; + $wpdb->query($sql); + + $post = get_post($post->ID); + $slug = $post->post_name; + + header("Location:".site_url().$_SERVER['REQUEST_URI']); + exit; + } + else + { + header("Location:".site_url().$_SERVER['REQUEST_URI']); + exit; + } + + } + } + +function wp_donate_form() { + ob_start(); + global $wpdb; + ?> + + + + diff --git a/includes/donate-function.php b/includes/donate-function.php new file mode 100755 index 0000000..fbdfc4e --- /dev/null +++ b/includes/donate-function.php @@ -0,0 +1,290 @@ +setSandbox(AUTHORIZENET_SANDBOX); + $transaction->setFields( + array( + 'amount' => $REQUEST['amount'], + 'invoice_num' => $REQUEST['invoice_num'], + 'card_num' => $REQUEST['x_card_num'], + 'exp_date' => $REQUEST['exp_month'].'/'.$REQUEST['exp_year'], + 'first_name' => $REQUEST['first_name'], + 'last_name' => $REQUEST['last_name'], + 'address' => $REQUEST['address'], + 'city' => $REQUEST['city'], + 'state' => $REQUEST['state'], + 'country' => $REQUEST['country'], + 'zip' => $REQUEST['zip'], + 'email' => $REQUEST['email'], + ) + ); + $response = $transaction->authorizeAndCapture(); + if ($response->approved) + { + $_SESSION['donate_msg'] = $response->response_reason_text; + return true; + } + else + { + //echo "1"; + $_SESSION['donate_msg'] = $response->response_reason_text; + } + } + elseif (count($REQUEST)) + { + $response = new AuthorizeNetSIM; + if ($response->isAuthorizeNet()) + { + if ($response->approved) + { + // Transaction approved! Do your logic here. + // Redirect the user back to your site. + //$return_url = $site_root . 'thank_you_page.php?transaction_id=' .$response->transaction_id; + //echo "2"; + + return true; + } + else + { + // There was a problem. Do your logic here. + // Redirect the user back to your site. + $_SESSION['donate_msg'] = $response->response_reason_text; + // echo "3"; + header("Location:".site_url().$_SERVER['REQUEST_URI']); + exit; + + } + echo AuthorizeNetDPM::getRelayResponseSnippet($return_url); + } + else + { + //echo "4"; + $_SESSION['donate_msg'] = "MD5 Hash failed. Check to make sure your MD5 Setting matches the one in"; + } + } + + } +} + +function checkInvoice($invoice_num) { + if (!preg_match("/^[0-9]{5}$/", $invoice_num)) { + return false; + } + return true; +} + +function checkCreditCard($cardnumber, $cardname, &$errornumber, &$errortext) { + + // Define the cards we support. You may add additional card types. + // Name: As in the selection box of the form - must be same as user's + // Length: List of possible valid lengths of the card number for the card + // prefixes: List of possible prefixes for the card + // checkdigit Boolean to say whether there is a check digit + // Don't forget - all but the last array definition needs a comma separator! + + $cards = array(array('name' => 'AMEX', + 'length' => '15', + 'prefixes' => '34,37', + 'checkdigit' => true + ), + array('name' => 'Diners Club Carte Blanche', + 'length' => '14', + 'prefixes' => '300,301,302,303,304,305', + 'checkdigit' => true + ), + array('name' => 'DINERS', + 'length' => '14,16', + 'prefixes' => '305,36,38,54,55', + 'checkdigit' => true + ), + array('name' => 'Discover', + 'length' => '16', + 'prefixes' => '6011,622,64,65', + 'checkdigit' => true + ), + array('name' => 'Diners Club Enroute', + 'length' => '15', + 'prefixes' => '2014,2149', + 'checkdigit' => true + ), + array('name' => 'JCB', + 'length' => '16', + 'prefixes' => '35', + 'checkdigit' => true + ), + array('name' => 'Maestro', + 'length' => '12,13,14,15,16,18,19', + 'prefixes' => '5018,5020,5038,6304,6759,6761', + 'checkdigit' => true + ), + array('name' => 'MASTERCARD', + 'length' => '16', + 'prefixes' => '51,52,53,54,55', + 'checkdigit' => true + ), + array('name' => 'Solo', + 'length' => '16,18,19', + 'prefixes' => '6334,6767', + 'checkdigit' => true + ), + array('name' => 'Switch', + 'length' => '16,18,19', + 'prefixes' => '4903,4905,4911,4936,564182,633110,6333,6759', + 'checkdigit' => true + ), + array('name' => 'VISA', + 'length' => '16', + 'prefixes' => '4', + 'checkdigit' => true + ), + array('name' => 'VISA Electron', + 'length' => '16', + 'prefixes' => '417500,4917,4913,4508,4844', + 'checkdigit' => true + ), + array('name' => 'LaserCard', + 'length' => '16,17,18,19', + 'prefixes' => '6304,6706,6771,6709', + 'checkdigit' => true + ) + ); + + $ccErrorNo = 0; + + $ccErrors [0] = 'Please enter a valid ' . $cardname . ' number.'; + $ccErrors [1] = "No card number provided"; + $ccErrors [2] = "Credit card number has invalid format"; + $ccErrors [3] = "Credit card number is invalid"; + $ccErrors [4] = "Credit card number is wrong length"; + + // Establish card type + $cardType = -1; + for ($i = 0; $i < sizeof($cards); $i++) { + + // See if it is this card (ignoring the case of the string) + if (strtolower($cardname) == strtolower($cards[$i]['name'])) { + $cardType = $i; + break; + } + } + + // If card type not found, report an error + if ($cardType == -1) { + $errornumber = 0; + $errortext = $ccErrors [$errornumber]; + return false; + } + + // Ensure that the user has provided a credit card number + if (strlen($cardnumber) == 0) { + $errornumber = 1; + $errortext = $ccErrors [$errornumber]; + return false; + } + + // Remove any spaces from the credit card number + $cardNo = str_replace(' ', '', $cardnumber); + + // Check that the number is numeric and of the right sort of length. + if (!preg_match("/^[0-9]{13,19}$/", $cardNo)) { + $errornumber = 2; + $errortext = $ccErrors [$errornumber]; + return false; + } + + + // Now check the modulus 10 check digit - if required + if ($cards[$cardType]['checkdigit']) { + $checksum = 0; // running checksum total + $mychar = ""; // next char to process + $j = 1; // takes value of 1 or 2 + // Process each digit one by one starting at the right + for ($i = strlen($cardNo) - 1; $i >= 0; $i--) { + + // Extract the next digit and multiply by 1 or 2 on alternative digits. + $calc = $cardNo{$i} * $j; + + // If the result is in two digits add 1 to the checksum total + if ($calc > 9) { + $checksum = $checksum + 1; + $calc = $calc - 10; + } + + // Add the units element to the checksum total + $checksum = $checksum + $calc; + + // Switch the value of j + if ($j == 1) { + $j = 2; + } else { + $j = 1; + }; + } + + // All done - if checksum is divisible by 10, it is a valid modulus 10. + // If not, report an error. + if ($checksum % 10 != 0) { + $errornumber = 3; + $errortext = $ccErrors [$errornumber]; + return false; + } + } + + // The following are the card-specific checks we undertake. + // Load an array with the valid prefixes for this card + $prefix = explode(',', $cards[$cardType]['prefixes']); + + // Now see if any of them match what we have in the card number + $PrefixValid = false; + for ($i = 0; $i < sizeof($prefix); $i++) { + $exp = '/^' . $prefix[$i] . '/'; + if (preg_match($exp, $cardNo)) { + $PrefixValid = true; + break; + } + } + + // If it isn't a valid prefix there's no point at looking at the length + if (!$PrefixValid) { + $errornumber = 3; + $errortext = $ccErrors [$errornumber]; + return false; + } + + // See if the length is valid for this card + $LengthValid = false; + $lengths = explode(',', $cards[$cardType]['length']); + for ($j = 0; $j < sizeof($lengths); $j++) { + if (strlen($cardNo) == $lengths[$j]) { + $LengthValid = true; + break; + } + } + + // See if all is OK by seeing if the length was valid. + if (!$LengthValid) { + $errornumber = 4; + $errortext = $ccErrors [$errornumber]; + return false; + }; + + // The credit card is in the required format. + return true; +} + + +?> diff --git a/includes/donate-options.php b/includes/donate-options.php new file mode 100755 index 0000000..d914db3 --- /dev/null +++ b/includes/donate-options.php @@ -0,0 +1,199 @@ + + query($wpdb->prepare("DELETE FROM ".$wpdb->prefix."donate WHERE id = %d",$_GET['id'])); + header("Location:".site_url().'/wp-admin/admin.php?page=wp_donate'); + exit; + } + elseif($_GET['id']!='') + { + ?> +
+

WP Donate

+
+ + + + get_results( "SELECT * FROM ".$wpdb->prefix."donate where id='".$_GET['id']."'" ); + foreach($myrows as $myrows_value) + { + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
First Name :first_name;?>
Last Name :last_name;?>
Organization :organization;?>
Address :address;?>
City :city;?>
Country :country;?>
State :state;?>
Zip : zip;?>
Phone :phone;?>
Email :email;?>
Donation Type :donation_type;?>
Amount :$amount;?>
Invoice Number: invoice_num;?>
Comment :comment;?>
Date :date;?>
Action : status==1){echo "Complete";} else {echo "Pending";}?>
/wp-admin/admin.php?page=wp_donate' value="Back" />
+
+
+ + + +
+

WP Donate

+ +
+
+ + get_results( "SELECT * FROM ".$wpdb->prefix."donate"); + if(count($myrows)>0) + { + ?> + + + + + + + + + + + + + + + + + + + + + +
PersonEmailAmountDateCommentAction
first_name.' '.$myrows_value->last_name ;?>email;?>$amount;?>date;?>comment;?>Delete
+
+
+ get_results( "SELECT * FROM ".$wpdb->prefix."donate_setting" ); + ?> +
+ +
    +
  • + Authorize.net Mode + +
  • +
  • + API Login + +
  • +
  • + Transaction Key + +
  • +
    + +
+
+
+ +
+ diff --git a/js/glm-donate.js b/js/glm-donate.js new file mode 100755 index 0000000..89ee1f7 --- /dev/null +++ b/js/glm-donate.js @@ -0,0 +1,117 @@ +/** + * GLM-donate + * + * @since 1.4 + * + */ + +// var glm-donate-key declared in DOM from localized script + +donate.setPublishableKey( wpdonatekey ); + +// donate Token Creation & Event Handling + +jQuery(document).ready(function($) { + + var resetdonateForm = function() { + $("#glm-donate-payment-form").get(0).reset(); + $('input').removeClass('donate-valid donate-invalid'); + } + + function donateResponseHandler(status, response) { + if (response.error) { + + $('.donate-submit-button').prop("disabled", false).css("opacity","1.0"); + $(".payment-errors").show().html(response.error.message); + + } else { + + var form$ = $("#glm-donate-payment-form"); + var token = response['id']; + form$.append(""); + + var newdonateForm = form$.serialize(); + + $.ajax({ + type : "post", + dataType : "json", + url : ajaxurl, + data : newdonateForm, + success: function(response) { + + $('.glm-donate-details').prepend(response); + $('.donate-submit-button').prop("disabled", false).css("opacity","1.0"); + resetdonateForm(); + + } + + }); + + } + } + + $("#glm-donate-payment-form").submit(function(event) { + + event.preventDefault(); + $(".glm-donate-notification").hide(); + + $('.donate-submit-button').prop("disabled", true).css("opacity","0.4"); + + var amount = $('.glm-donate-card-amount').val() * 100; //amount you want to charge in cents + + donate.createToken({ + name: $('.glm-donate-name').val(), + number: $('.card-number').val(), + cvc: $('.card-cvc').val(), + exp_month: $('.card-expiry-month').val(), + exp_year: $('.card-expiry-year').val() + }, donateResponseHandler); + + // prevent the form from submitting with the default action + + return false; + + }); +}); + +// Form Validation & Enhancement + +jQuery(document).ready(function($) { + + $('.card-number').focusout( function() { + + var cardValid = donate.validateCardNumber( $(this).val() ); + var cardType = donate.cardType( $(this).val() ); + + // Card Number Validation + + if ( cardValid ) { + $(this).removeClass('donate-invalid').addClass('donate-valid'); + } else { + $(this).removeClass('donate-valid').addClass('donate-invalid'); + } + + // Card Type Information + + /* + if ( cardType && cardValid ) { + // Display Card Logo + } + */ + + }); + + // CVC Validation + + $('.card-cvc').focusout( function() { + + if ( donate.validateCVC( $(this).val() ) ) { + $(this).removeClass('donate-invalid').addClass('donate-valid'); + } else { + $(this).removeClass('donate-valid').addClass('donate-invalid'); + } + + }); + +}); + diff --git a/js/list.min.js b/js/list.min.js new file mode 100755 index 0000000..27cac39 --- /dev/null +++ b/js/list.min.js @@ -0,0 +1 @@ +(function(d,e){var a=d.document,c;var b=function(g,t,p){var r=this,o,q,n,s,i,f,h,m="";this.listContainer=a.getElementById(g);this.items=[];this.searched=false;this.filtered=false;this.list=null;this.templateEngines={};this.maxVisibleItemsCount=t.maxVisibleItemsCount||200;q=function(u,w){w.list=w.list||g;w.listClass=w.listClass||"list";w.searchClass=w.searchClass||"search";w.sortClass=w.sortClass||"sort";o=new f(r,w);r.list=c.getByClass(w.listClass,r.listContainer,true);c.addEvent(c.getByClass(w.searchClass,r.listContainer),"keyup",r.search);h=c.getByClass(w.sortClass,r.listContainer);c.addEvent(h,"click",r.sort);if(w.valueNames){var x=n.get(),v=w.valueNames;if(w.indexAsync){n.indexAsync(x,v)}else{n.index(x,v)}}if(u!==e){r.add(u)}};n={get:function(){var w=r.list.childNodes,v=[];for(var x=0,u=w.length;x0){setTimeout(function(){n.indexAsync(u,v)},10)}}};this.add=function(v,A){if(A){l(v,A)}var y=[],x=false;if(v[0]===e){v=[v]}for(var w=0,u=v.length;wr.maxVisibleItemsCount)?true:false;z=new i(v[w],e,x)}if(!x){o.add(z,t)}r.items.push(z);y.push(z)}return y};var l=function(v,x,u){var w=v.splice(0,100);u=u||[];u=u.concat(r.add(w));if(v.length>0){setTimeout(function(){l(v,x,u)},10)}else{x(u)}};this.remove=function(z,y,v){var x=0;for(var w=0,u=r.items.length;w"});w=w.replace(/<\/?[^>]+(>|$)/g,"");v=v.toString().replace(/&(lt|gt);/g,function(x,D){return(D=="lt")?"<":">"});v=v.replace(/<\/?[^>]+(>|$)/g,"");var z=this.chunkify(w);var B=this.chunkify(v);for(var u=0;z[u]&&B[u];u++){if(z[u]!==B[u]){var C=Number(z[u]),A=Number(B[u]);if(y){if(C==z[u]&&A==B[u]){return C-A}else{return(z[u]>B[u])?1:-1}}else{if(C==z[u]&&A==B[u]){return A-C}else{return(z[u]>B[u])?-1:1}}}}return z.length-B.length},chunkify:function(A){var D=[],v=0,C=-1,B=0,z,w;while(z=(w=A.charAt(v++)).charCodeAt(0)){var u=(z==45||z==46||(z>=48&&z<=57));if(u!==B){D[++C]="";B=u}D[C]+=w}return D}};this.search=function(F,w){var v=[],E,D,C,B,z,w=(w===e)?r.items[0].values():w,F=(F===e)?"":F,A=F.target||F.srcElement;F=(A===e)?F.toLowerCase():A.value.toLowerCase();z=r.items;F=F.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");o.clear();if(F===""){k.search();r.searched=false;j()}else{r.searched=true;for(var x=0,u=z.length;x-1)){E=true}}}if(E){D.found=true;v.push(D)}else{D.found=false}}j()}m=F;return v};this.filter=function(z){var y=e;k.filter();if(z===e){r.filtered=false}else{y=[];r.filtered=true;var x=r.items;for(var v=0,u=x.length;v=1){k.removeChild(k.firstChild)}}}};c={getByClass:(function(){if(a.getElementsByClassName){return function(g,f,h){if(h){return f.getElementsByClassName(g)[0]}else{return f.getElementsByClassName(g)}}}else{return function(m,g,o){var p=[],q="*";if(g==null){g=a}var k=g.getElementsByTagName(q);var f=k.length;var n=new RegExp("(^|\\s)"+m+"(\\s|$)");for(var l=0,h=0;l0))){return true}return false},hasClass:function(h,g){var f=this.getAttribute(h,"class");return(f.search(g)>-1)},addClass:function(h,g){if(!this.hasClass(h,g)){var f=this.getAttribute(h,"class");f=f+" "+g+" ";f=f.replace(/\s{2,}/g," ");h.setAttribute("class",f)}},removeClass:function(h,g){if(this.hasClass(h,g)){var f=this.getAttribute(h,"class");f=f.replace(g,"");h.setAttribute("class",f)}}};d.List=b;d.ListJsHelpers=c})(window); \ No newline at end of file diff --git a/js/paymentmethods.js b/js/paymentmethods.js new file mode 100755 index 0000000..73a3d7f --- /dev/null +++ b/js/paymentmethods.js @@ -0,0 +1,19 @@ +function PaymentMethod(name,creditCard,cardType,cardCvv,cardHolderName,enableRecurring){this.name=name;this.creditCard=creditCard;this.cardType=cardType;this.cardCvv=cardCvv;this.cardHolderName=cardHolderName;this.enableRecurring=enableRecurring;} +PaymentMethod.prototype.getName=function(){return this.name;} +PaymentMethod.prototype.getCreditCard=function(){return this.creditCard;} +PaymentMethod.prototype.getCardType=function(){return this.cardType;} +PaymentMethod.prototype.getCardCvv=function(){return this.cardCvv;} +PaymentMethod.prototype.getCardHolderName=function(){return this.cardHolderName;} +PaymentMethod.prototype.getEnableRecurring=function(){return this.enableRecurring;} +function PaymentMethods(){this.length=0;this.methods=new Array();} +PaymentMethods.prototype.Add=function(paymentMethod){this.methods[this.length]=paymentMethod;this.length=this.length+1;} +PaymentMethods.prototype.Find=function(name){for(var i=0;i0) +show=recurrings[form.campaign_id.value];} +if(method.getEnableRecurring()&&show){trDonationType.style.display='';if(form.donation_type[1].checked){trFrequency.style.display='';if(trNumberDonations){trNumberDonations.style.display='';}}}else{trDonationType.style.display='none';trFrequecy.style.display='none';if(trNumberDonations){trNumberDonations.style.display='none';} +form.donation_type[0].checked=true;}}} \ No newline at end of file diff --git a/readme.txt b/readme.txt new file mode 100755 index 0000000..606090d --- /dev/null +++ b/readme.txt @@ -0,0 +1,68 @@ +=== glm-donate === +Contributors: ketanajani +Donate link: http://webconfines.com +Tags: donate, authorizeNet , credit card, payment, pay, transfer, charge, widget, form, chargly, recurly, recent, donation, donations, charity, transaction, money, wordpress +Requires at least: 3.0 +Tested up to: 3.6 +Stable tag: 0.6 +License: GPLv2 or later +License URI: http://www.gnu.org/licenses/gpl-2.0.html + +GLM-donate provides a payment form and recent donor by utilizing AuthorizeNet. + +== Description == + +WP Donate provides a payment form and recent donor widget by utilizing Authorize.net. + +What glm-donate provides: + +1. Listing of donor at admin area +1. At admin area it allows to set details related to payment gateway +1. From displayed at client side using Shortcode +1. Autherize.net payment gateway integration for accepting donation + +If you need any modification in plugin or need some extra functionality than please let us know here http://www.webconfines.com/contact-us + +== Installation == + +WP Donate can be used by either calling up a simple shortcode or adding the function to your template as below: + +1. Upload the folder `glm-donate` to the `/wp-content/plugins/` directory +1. Activate the plugin through the 'Plugins' menu in WordPress +1. Go to WP Donate (for both Test & Live) +1. Place `[Display Donate]` in your content or `` in your template. + +== Frequently Asked Questions == += Will it work on my Theme? = +GLM-donate features an inline form so that it can fit any theme. that you can customize it yourself. += Can I expand this plugin = +Yes you can customize or expand plugin by adding new payment gateways to receive donation or customization can be made in form related to fields. += About SSL = +In order to process transactions in a secure manner, you need to [purchase an SSL Certificate](http://www.noeltock.com/sslcertificates/). This way consumers can purchase/donate with confidence. There are multiple plugins for then enforcing that SSL be used on your page, [here's one](http://wordpress.org/extend/plugins/wordpress-https/). += Support available? = +If you need any modification in plugin or need some extra functionality than please let us know here http://www.webconfines.com/contact-us += What are limitations of this plugin? = +It is only available to users with Authorize.Net payment gateway to receive donations. + +== Screenshots == +1. screenshot-1.png +2. screenshot-2.png +3. screenshot-3.png +3. screenshot-4.png + +== Changelog == + += 1.2 = +* Provided some more details about plugin + += 1.3 = +* Removed error message and redirected to correct page after success. + += 1.4 = +* Modified database interactions for improvements and solved page redirect bug after successful payment by providing robust solution. + += 1.5 = +* Modified donation limit. Earlier it was minimum $10 and maximum $1000, now minimum is $1 and maximum is $100000 + +== Upgrade Notice == +Nothing yet diff --git a/screenshot-1.png b/screenshot-1.png new file mode 100755 index 0000000..d0d0b21 Binary files /dev/null and b/screenshot-1.png differ diff --git a/screenshot-2.png b/screenshot-2.png new file mode 100755 index 0000000..417bd9d Binary files /dev/null and b/screenshot-2.png differ diff --git a/screenshot-3.png b/screenshot-3.png new file mode 100755 index 0000000..6080c30 Binary files /dev/null and b/screenshot-3.png differ diff --git a/screenshot-4.png b/screenshot-4.png new file mode 100755 index 0000000..2efd9b3 Binary files /dev/null and b/screenshot-4.png differ diff --git a/wp-donate.php b/wp-donate.php new file mode 100755 index 0000000..33d7da6 --- /dev/null +++ b/wp-donate.php @@ -0,0 +1,124 @@ +query("INSERT INTO `".$wpdb->prefix."donate_setting` (`id`, `mod`, `api_login`, `key`) VALUES ('1', '', '', '')"); + $wpdb->query("UPDATE `".$wpdb->prefix."donate_setting` SET `mod` = '".$_REQUEST['authnet_mode']."',`api_login` = '".$_REQUEST['x_login']."',`key` = '".$_REQUEST['x_tran_key']."' WHERE `id` =1"); + } +} + +register_activation_hook( __FILE__, 'donate_install' ); + +global $donate_db_version; +$donate_db_version = "1.0"; + +function donate_install() { + global $wpdb; + global $donate_db_version; + + $table_name = $wpdb->prefix . "donate"; + $sql = "CREATE TABLE IF NOT EXISTS `$table_name` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `first_name` varchar(255) CHARACTER SET utf8 NOT NULL, + `last_name` varchar(255) CHARACTER SET utf8 NOT NULL, + `organization` varchar(255) CHARACTER SET utf8 NOT NULL, + `address` varchar(255) CHARACTER SET utf8 NOT NULL, + `city` varchar(255) CHARACTER SET utf8 NOT NULL, + `country` varchar(255) CHARACTER SET utf8 NOT NULL, + `state` varchar(255) CHARACTER SET utf8 NOT NULL, + `zip` varchar(255) CHARACTER SET utf8 NOT NULL, + `phone` varchar(255) NOT NULL, + `email` varchar(255) NOT NULL, + `donation_type` varchar(255) NOT NULL, + `amount` varchar(255) NOT NULL, + `comment` text NOT NULL, + `status` varchar(255) NOT NULL, + `date` datetime NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `id` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1"; + +$donate_setting = $wpdb->prefix . "donate_setting"; +$donate_setting_sql = "CREATE TABLE IF NOT EXISTS `$donate_setting` ( +`id` int(11) NOT NULL AUTO_INCREMENT, +`mod` varchar(255) NOT NULL, +`api_login` varchar(255) NOT NULL, +`key` varchar(255) NOT NULL, +PRIMARY KEY (`id`), +UNIQUE KEY `id` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2"; + + require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); + dbDelta( $sql ); + dbDelta( $donate_setting_sql ); + + add_option( "donate_db_version", $donate_db_version ); +} + +function donate_install_data() { + global $wpdb; + $welcome_name = "Mr. WordPress"; + $welcome_text = "Congratulations, you just completed the installation!"; + $rows_affected = $wpdb->insert( $table_name, array( 'time' => current_time('mysql'), 'name' => $welcome_name, 'text' => $welcome_text ) ); +} +?>