Adding payment library
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 8 Dec 2017 21:48:31 +0000 (16:48 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 8 Dec 2017 21:48:31 +0000 (16:48 -0500)
also updating the member billing statement model view.

217 files changed:
classes/data/dataInvoices.php
lib/paymentProcessors/Authorize.Net/AIM_guide-1.pdf [new file with mode: 0644]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/AuthorizeNet.php [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/License.pdf [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/README [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/README.html [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/doc/AIM.markdown [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/doc/ARB.markdown [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/doc/CIM.markdown [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/doc/CP.markdown [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/doc/DPM.markdown [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/doc/SIM.markdown [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/doc/SOAP.markdown [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/doc/TD.markdown [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/AuthorizeNetAIM.php [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/AuthorizeNetARB.php [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/AuthorizeNetCIM.php [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/AuthorizeNetCP.php [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/AuthorizeNetDPM.php [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/AuthorizeNetSIM.php [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/AuthorizeNetSOAP.php [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/AuthorizeNetTD.php [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/shared/AuthorizeNetRequest.php [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/shared/AuthorizeNetResponse.php [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/shared/AuthorizeNetTypes.php [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/shared/AuthorizeNetXMLResponse.php [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/ssl/cert.pem [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNetAIM_Test.php [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNetARB_Test.php [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNetCIM_Test.php [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNetCP_Test.php [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNetDPM_Test.php [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNetSIM_Test.php [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNetSSL_Test.php [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNetTD_Test.php [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNet_SOAP_Test.php [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNet_Test_Config.php [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/README [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/domain.crt [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/report.html [new file with mode: 0755]
lib/paymentProcessors/Authorize.Net/paymentGateway.php [new file with mode: 0644]
lib/paymentProcessors/MerchantSolutions/paymentGateway.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/assets/x-click-but6.gif [new file with mode: 0755]
lib/paymentProcessors/PayPal/paymentGateway.php [new file with mode: 0755]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/.coveralls.yml [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/.gitignore [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/.travis.yml [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/CHANGELOG.md [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/LICENSE.txt [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/README.md [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/build.xml [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/composer.json [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Address.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Amount.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Authorization.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Capture.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/CreditCard.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/CreditCardHistory.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/CreditCardToken.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Details.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/FundingInstrument.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/HyperSchema.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Item.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/ItemList.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Links.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Payee.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Payer.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/PayerInfo.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Payment.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/PaymentExecution.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/PaymentHistory.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/RedirectUrls.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Refund.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/RelatedResources.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Sale.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/ShippingAddress.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Transaction.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Transactions.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Auth/OAuthTokenCredential.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Rest/ApiContext.php [new file with mode: 0755]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Rest/IResource.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Rest/RestHandler.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/phpunit.xml [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/AddressTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/AmountTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/AuthorizationTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/CaptureTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/CreditCardHistoryTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/CreditCardTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/CreditCardTokenTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/DetailsTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/FundingInstrumentTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/ItemListTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/ItemTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/LinksTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/PayeeTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/PayerInfoTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/PayerTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/PaymentHistoryTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/PaymentTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/RefundTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/RelatedResourcesTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/SaleTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/ShippingAddressTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/TransactionTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Auth/OAuthTokenCredentialTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/ArrayClass.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/ArrayUtilTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/ChildClass.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/ModelTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/NestedClass.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/SimpleClass.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/UserAgentTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Constants.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Rest/CallTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/bootstrap.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/sdk_config.ini [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/.gitignore [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/CHANGELOG.md [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/LICENSE.txt [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/README.md [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/build.xml [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/composer.json [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/IPPCredential.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/IPPThirdPartyAuthorization.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/AuthSignature.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/MockOAuthDataStore.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthConsumer.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthDataStore.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthRequest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthServer.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthSignatureMethod.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthSignatureMethodHmacSha1.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthSignatureMethodPLAINTEXT.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthSignatureMethodRsaSha1.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthToken.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthUtil.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Openid/PPOpenIdAddress.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Openid/PPOpenIdError.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Openid/PPOpenIdSession.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Openid/PPOpenIdTokeninfo.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Openid/PPOpenIdUserinfo.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/PPCertificateCredential.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/PPSignatureCredential.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/PPSubjectAuthorization.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/PPTokenAuthorization.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Common/PPApiContext.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Common/PPArrayUtil.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Common/PPModel.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Common/PPReflectionUtil.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Common/PPUserAgent.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPAPIService.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPBaseService.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPConfigManager.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPConnectionManager.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPConstants.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPCredentialManager.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPHttpConfig.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPHttpConnection.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPLoggingManager.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPMessage.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPRequest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPUtils.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPXmlMessage.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/cacert.pem [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Exception/OAuthException.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Exception/PPConfigurationException.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Exception/PPConnectionException.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Exception/PPInvalidCredentialException.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Exception/PPMissingCredentialException.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Exception/PPTransformerException.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Formatter/FormatterFactory.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Formatter/IPPFormatter.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Formatter/PPNVPFormatter.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Formatter/PPSOAPFormatter.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/IPPHandler.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPAuthenticationHandler.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPCertificateAuthHandler.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPGenericServiceHandler.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPMerchantServiceHandler.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPOpenIdHandler.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPPlatformServiceHandler.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPSignatureAuthHandler.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/IPN/PPIPNMessage.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Transport/PPRestCall.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/Openid/PPOpenIdAddressTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/Openid/PPOpenIdSessionTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/Openid/PPOpenIdTokeninfoTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/Openid/PPOpenIdUserinfoTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPAPIServiceTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPBaseServiceTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPBootStrap.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPCertificateCredentialTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPConfigManagerTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPConfigurationExceptionTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPConnectionExceptionTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPConnectionManagerTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPCredentialManagerTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPIPNMessageTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPInvalidCredentialExceptionTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPLoggingManagerTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPMessageTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPMissingCredentialExceptionTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPSignatureCredentialTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPUtilsTest.php [new file with mode: 0644]
lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/sdk_config.ini [new file with mode: 0644]
lib/paymentProcessors/PayPal/test.php [new file with mode: 0755]
lib/paymentProcessors/TestByCardNumber/paymentGateway.php [new file with mode: 0644]
lib/paymentProcessors/TestGood/paymentGateway.php [new file with mode: 0644]
lib/paymentProcessors/readme.txt [new file with mode: 0644]
models/admin/billing/invoices.php
models/admin/member/billing.php
models/admin/member/savebilling.php [new file with mode: 0644]
setup/databaseScripts/create_database_V0.0.2.sql
setup/validActions.php
views/admin/billing/invoices.html
views/admin/member/index.html [new file with mode: 0644]

index e1ede13..cf342ef 100644 (file)
@@ -210,8 +210,8 @@ class GlmDataInvoices extends GlmDataAbstract
         $sql = "
         SELECT A.ref_name
           FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices I
-        LEFT OUTER JOIN " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts A
-        ON ( I.account = A.id )";
+          LEFT OUTER JOIN " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts A ON ( I.account = A.id )
+         WHERE I.id = " . $r['id'];
         $r['member_name'] = $this->wpdb->get_var( $sql );
         return $r;
     }
diff --git a/lib/paymentProcessors/Authorize.Net/AIM_guide-1.pdf b/lib/paymentProcessors/Authorize.Net/AIM_guide-1.pdf
new file mode 100644 (file)
index 0000000..4ed80c0
Binary files /dev/null and b/lib/paymentProcessors/Authorize.Net/AIM_guide-1.pdf differ
diff --git a/lib/paymentProcessors/Authorize.Net/anet_php_sdk/AuthorizeNet.php b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/AuthorizeNet.php
new file mode 100755 (executable)
index 0000000..31fdaa9
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+/**
+ * The AuthorizeNet PHP SDK. Include this file in your project.
+ *
+ * @package AuthorizeNet
+ */
+require dirname(__FILE__) . '/lib/shared/AuthorizeNetRequest.php';
+require dirname(__FILE__) . '/lib/shared/AuthorizeNetTypes.php';
+require dirname(__FILE__) . '/lib/shared/AuthorizeNetXMLResponse.php';
+require dirname(__FILE__) . '/lib/shared/AuthorizeNetResponse.php';
+require dirname(__FILE__) . '/lib/AuthorizeNetAIM.php';
+require dirname(__FILE__) . '/lib/AuthorizeNetARB.php';
+require dirname(__FILE__) . '/lib/AuthorizeNetCIM.php';
+require dirname(__FILE__) . '/lib/AuthorizeNetSIM.php';
+require dirname(__FILE__) . '/lib/AuthorizeNetDPM.php';
+require dirname(__FILE__) . '/lib/AuthorizeNetTD.php';
+require dirname(__FILE__) . '/lib/AuthorizeNetCP.php';
+
+if (class_exists("SoapClient")) {
+    require dirname(__FILE__) . '/lib/AuthorizeNetSOAP.php';
+}
+/**
+ * Exception class for AuthorizeNet PHP SDK.
+ *
+ * @package AuthorizeNet
+ */
+class AuthorizeNetException extends Exception
+{
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/Authorize.Net/anet_php_sdk/License.pdf b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/License.pdf
new file mode 100755 (executable)
index 0000000..86d1834
Binary files /dev/null and b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/License.pdf differ
diff --git a/lib/paymentProcessors/Authorize.Net/anet_php_sdk/README b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/README
new file mode 100755 (executable)
index 0000000..e706a1d
--- /dev/null
@@ -0,0 +1,230 @@
+By:
+    Authorize.Net
+    http://developer.authorize.net
+    http://community.developer.authorize.net
+
+License:
+    See License.pdf
+
+About:
+    A PHP library for working with all Authorize.Net APIs.
+
+Files:
+    - AuthorizeNet.php                       -> 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:
+    <?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:
+    - 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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/README.html b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/README.html
new file mode 100755 (executable)
index 0000000..795637a
--- /dev/null
@@ -0,0 +1,358 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
+  "http://www.w3.org/TR/html4/loose.dtd">
+<html lang='en'>
+<head>
+<title> PHP SDK README </title>
+<style type="text/css">
+body {
+       min-width: 768px;
+       font-family: "Helvetica Neue","Lucida Grande","Segoe UI",Arial,Helvetica,Verdana,sans-serif;
+       color: #333333;
+       font-size: 0.8em;
+}
+code {
+       font-family: 'Courier New';
+       font-size: 1.0em;
+       color: #000000;
+       background-color: #f1f1f1;
+       white-space: pre;
+       line-height: 1;
+       display: block;
+       margin-left: 3%;
+       margin-right: 3%;
+       padding: 10px;
+}
+table {
+       border-collapse: collapse;
+       width: 94%;
+       margin: 3%;
+       margin-right: 3%;
+       margin-top: 0px;
+       margin-bottom: 0px;
+}
+td {
+       padding: 3px;
+       border: solid 1px #cccccc;
+}
+ul {
+       margin-top: 0px;
+}
+h1,h2,h3,h6 {
+       margin: 0px;
+       padding: 0px;
+       text-align: center;
+}
+h4,h5 {
+       margin-bottom: 0px;
+       padding-bottom: 5px;
+}
+.indent {
+       display: block;
+       margin-left: 3%;
+}
+.sc0 {
+       font-weight: bold;
+}
+.sc18 {
+       color: #FF0000;
+}
+.sc119 {
+       color: #808080;
+}
+.sc120 {
+       color: #808080;
+}
+.sc121 {
+       font-weight: bold;
+       color: #0000FF;
+}
+.sc123 {
+       color: #000080;
+}
+.sc125 {
+       color: #008000;
+}
+.sc127 {
+       color: #8000FF;
+}
+</style>
+</head>
+
+<body>
+<h1>Authorize.Net PHP SDK</h1>
+<h2>version 3.1.2</h2>
+<h6><a href='http://developer.authorize.net'>http://developer.authorize.net</a></h6>
+<h6><a href='http://community.developer.authorize.net'>http://community.developer.authorize.net</a></h6>
+
+<br/>
+<h4>License</h4>
+<span class='indent'>Authorize.Net<br />
+    See <a href='./License.pdf'>License.pdf</a>
+</span>
+
+<br/>
+<h4>About</h4>
+<span class='indent'>A PHP library for working with all Authorize.Net APIs.
+</span>
+
+<br/>
+<h4>Files</h4>
+<table>
+<tr><td>Authorize.Net.php</td><td>Includes all classes. Include this file in your project.</td></tr>
+<tr><td>AuthorizeNet.php</td><td>Includes all classes. Include this file in your project.</td></tr>
+<tr><td>lib/AuthorizeNetAIM.php</td><td>AIM API.</td></tr>
+<tr><td>lib/AuthorizeNetARB.php</td><td>-> ARB API.</td></tr>
+<tr><td>lib/AuthorizeNetCIM.php</td><td>CIM API.</td></tr>
+<tr><td>lib/AuthorizeNetSIM.php</td><td>SIM API.</td></tr>
+<tr><td>lib/AuthorizeNetTD.php</td><td>Reporting API.</td></tr>
+<tr><td>lib/AuthorizeNetCP.php</td><td>Card Present API.</td></tr>
+<tr><td>lib/AuthorizeNetDPM.php</td><td>Direct Post Method Helpers.</td></tr>
+<tr><td>lib/AuthorizeNetSOAP.php</td><td>Class to assist with using the SOAP API.</td></tr>
+<tr><td>lib/shared/AuthorizeNetRequest.php</td><td>Class to connect to AuthorizeNet.</td></tr>
+<tr><td>lib/shared/AuthorizeNetTypes.php</td><td>Classes for AuthorizeNet Datatypes.</td></tr>
+<tr><td>lib/shared/AuthorizeNetResponse.php</td><td>Class to parse AuthorizeNet NVP Responses.</td></tr>
+<tr><td>lib/shared/AuthorizeNetXMLResponse.php</td><td>Class to parse AuthorizeNet XML Responses.</td></tr>
+<tr><td>lib/ssl/cert.pem</td><td>The AuthorizeNet Certificate bundle.</td></tr>
+<tr><td>tests/</td><td>Tests &amp; examples for each of the API methods.</td></tr>
+<tr><td>README</td><td>Plain text version of this file.</td></tr>
+<tr><td>README.html</td><td>This file.</td></tr>
+</table>
+
+<br />
+<h4>Requirements</h4>
+<ul>
+    <li>cURL PHP Extension</li>
+    <li>PHP 5.2+</li>
+    <li>An Authorize.Net Merchant Account or Test Account. You can get a free test account at <a href='http://developer.authorize.net/testaccount/'>http://developer.authorize.net/testaccount/</a></li>
+</ul>
+
+<h4>Install</h4>
+<ul>
+    <li>Include the 'AuthorizeNet.php' file in your application.
+    <li>Use your desired API.
+</ul>
+    
+<h4>Usage Examples:</h4>
+       <span class='indent'>See below for basic usage examples. View the tests/ folder for more examples of each API.</span>
+      
+<h5>AuthorizeNetAIM.php Quick Usage Example</h5>
+<code><span class="sc18">&lt;?php</span><span class="sc118">
+    </span><span class="sc121">require_once</span><span class="sc118"> </span><span class="sc120">'anet_php_sdk/AuthorizeNet.php'</span><span class="sc127">;</span><span class="sc118"> 
+    define</span><span class="sc127">(</span><span class="sc119">"AUTHORIZENET_API_LOGIN_ID"</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc119">"YOURLOGIN"</span><span class="sc127">);</span><span class="sc118">
+    define</span><span class="sc127">(</span><span class="sc119">"AUTHORIZENET_TRANSACTION_KEY"</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc119">"YOURKEY"</span><span class="sc127">);</span><span class="sc118">
+    define</span><span class="sc127">(</span><span class="sc119">"AUTHORIZENET_SANDBOX"</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc121">true</span><span class="sc127">);</span><span class="sc118">
+    </span><span class="sc123">$sale</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc121">new</span><span class="sc118"> AuthorizeNetAIM</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$sale</span><span class="sc127">-&gt;</span><span class="sc118">amount </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc119">"5.99"</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$sale</span><span class="sc127">-&gt;</span><span class="sc118">card_num </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc120">'6011000000000012'</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$sale</span><span class="sc127">-&gt;</span><span class="sc118">exp_date </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc120">'04/15'</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$response</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc123">$sale</span><span class="sc127">-&gt;</span><span class="sc118">authorizeAndCapture</span><span class="sc127">();</span><span class="sc118">
+    </span><span class="sc121">if</span><span class="sc118"> </span><span class="sc127">(</span><span class="sc123">$response</span><span class="sc127">-&gt;</span><span class="sc118">approved</span><span class="sc127">)</span><span class="sc118"> </span><span class="sc127">{</span><span class="sc118">
+        </span><span class="sc123">$transaction_id</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc123">$response</span><span class="sc127">-&gt;</span><span class="sc118">transaction_id</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc127">}</span><span class="sc118">
+</span><span class="sc18">?&gt;</span><span class="sc0"></span>
+</code>
+
+<h5>AuthorizeNetAIM.php Advanced Usage Example</h5>
+<code><span class="sc18">&lt;?php</span><span class="sc118">
+    </span><span class="sc121">require_once</span><span class="sc118"> </span><span class="sc120">'anet_php_sdk/AuthorizeNet.php'</span><span class="sc127">;</span><span class="sc118"> 
+    define</span><span class="sc127">(</span><span class="sc119">"AUTHORIZENET_API_LOGIN_ID"</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc119">"YOURLOGIN"</span><span class="sc127">);</span><span class="sc118">
+    define</span><span class="sc127">(</span><span class="sc119">"AUTHORIZENET_TRANSACTION_KEY"</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc119">"YOURKEY"</span><span class="sc127">);</span><span class="sc118">
+    define</span><span class="sc127">(</span><span class="sc119">"AUTHORIZENET_SANDBOX"</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc121">true</span><span class="sc127">);</span><span class="sc118">
+    </span><span class="sc123">$auth</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc121">new</span><span class="sc118"> AuthorizeNetAIM</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$auth</span><span class="sc127">-&gt;</span><span class="sc118">amount </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc119">"45.00"</span><span class="sc127">;</span><span class="sc118">
+
+    </span><span class="sc125">// Use eCheck:</span><span class="sc118">
+    </span><span class="sc123">$auth</span><span class="sc127">-&gt;</span><span class="sc118">setECheck</span><span class="sc127">(</span><span class="sc118">
+        </span><span class="sc120">'121042882'</span><span class="sc127">,</span><span class="sc118">
+        </span><span class="sc120">'123456789123'</span><span class="sc127">,</span><span class="sc118">
+        </span><span class="sc120">'CHECKING'</span><span class="sc127">,</span><span class="sc118">
+        </span><span class="sc120">'Bank of Earth'</span><span class="sc127">,</span><span class="sc118">
+        </span><span class="sc120">'Jane Doe'</span><span class="sc127">,</span><span class="sc118">
+        </span><span class="sc120">'WEB'</span><span class="sc118">
+    </span><span class="sc127">);</span><span class="sc118">
+    
+    </span><span class="sc125">// Set multiple line items:</span><span class="sc118">
+    </span><span class="sc123">$auth</span><span class="sc127">-&gt;</span><span class="sc118">addLineItem</span><span class="sc127">(</span><span class="sc120">'item1'</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc120">'Golf tees'</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc120">'Blue tees'</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc120">'2'</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc120">'5.00'</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc120">'N'</span><span class="sc127">);</span><span class="sc118">
+    </span><span class="sc123">$auth</span><span class="sc127">-&gt;</span><span class="sc118">addLineItem</span><span class="sc127">(</span><span class="sc120">'item2'</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc120">'Golf shirt'</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc120">'XL'</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc120">'1'</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc120">'40.00'</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc120">'N'</span><span class="sc127">);</span><span class="sc118">
+    
+    </span><span class="sc125">// Set Invoice Number:</span><span class="sc118">
+    </span><span class="sc123">$auth</span><span class="sc127">-&gt;</span><span class="sc118">invoice_num </span><span class="sc127">=</span><span class="sc118"> time</span><span class="sc127">();</span><span class="sc118">
+    
+    </span><span class="sc125">// Set a Merchant Defined Field:</span><span class="sc118">
+    </span><span class="sc123">$auth</span><span class="sc127">-&gt;</span><span class="sc118">setCustomField</span><span class="sc127">(</span><span class="sc119">"entrance_source"</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc119">"Search Engine"</span><span class="sc127">);</span><span class="sc118">
+    
+    </span><span class="sc125">// Authorize Only:</span><span class="sc118">
+    </span><span class="sc123">$response</span><span class="sc118">  </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc123">$auth</span><span class="sc127">-&gt;</span><span class="sc118">authorizeOnly</span><span class="sc127">();</span><span class="sc118">
+
+    </span><span class="sc121">if</span><span class="sc118"> </span><span class="sc127">(</span><span class="sc123">$response</span><span class="sc127">-&gt;</span><span class="sc118">approved</span><span class="sc127">)</span><span class="sc118"> </span><span class="sc127">{</span><span class="sc118">
+        </span><span class="sc123">$auth_code</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc123">$response</span><span class="sc127">-&gt;</span><span class="sc118">transaction_id</span><span class="sc127">;</span><span class="sc118">
+        
+        </span><span class="sc125">// Now capture:</span><span class="sc118">
+        </span><span class="sc123">$capture</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc121">new</span><span class="sc118"> AuthorizeNetAIM</span><span class="sc127">;</span><span class="sc118">
+        </span><span class="sc123">$capture_response</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc123">$capture</span><span class="sc127">-&gt;</span><span class="sc118">priorAuthCapture</span><span class="sc127">(</span><span class="sc123">$auth_code</span><span class="sc127">);</span><span class="sc118">
+        
+        </span><span class="sc125">// Now void:</span><span class="sc118">
+        </span><span class="sc123">$void</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc121">new</span><span class="sc118"> AuthorizeNetAIM</span><span class="sc127">;</span><span class="sc118">
+        </span><span class="sc123">$void_response</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc123">$void</span><span class="sc127">-&gt;</span><span class="sc118">void</span><span class="sc127">(</span><span class="sc123">$capture_response</span><span class="sc127">-&gt;</span><span class="sc118">transaction_id</span><span class="sc127">);</span><span class="sc118">
+    </span><span class="sc127">}</span><span class="sc118">
+</span><span class="sc18">?&gt;</span><span class="sc0"></span>
+</code>
+       
+<h5>AuthorizeNetARB.php Usage Example</h5>
+<code><span class="sc18">&lt;?php</span><span class="sc118">
+    </span><span class="sc121">require_once</span><span class="sc118"> </span><span class="sc120">'anet_php_sdk/AuthorizeNet.php'</span><span class="sc127">;</span><span class="sc118">
+    define</span><span class="sc127">(</span><span class="sc119">"AUTHORIZENET_API_LOGIN_ID"</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc119">"YOURLOGIN"</span><span class="sc127">);</span><span class="sc118">
+    define</span><span class="sc127">(</span><span class="sc119">"AUTHORIZENET_TRANSACTION_KEY"</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc119">"YOURKEY"</span><span class="sc127">);</span><span class="sc118">
+    </span><span class="sc123">$subscription</span><span class="sc118">                          </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc121">new</span><span class="sc118"> AuthorizeNet_Subscription</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$subscription</span><span class="sc127">-&gt;</span><span class="sc118">name                    </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc119">"PHP Monthly Magazine"</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$subscription</span><span class="sc127">-&gt;</span><span class="sc118">intervalLength          </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc119">"1"</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$subscription</span><span class="sc127">-&gt;</span><span class="sc118">intervalUnit            </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc119">"months"</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$subscription</span><span class="sc127">-&gt;</span><span class="sc118">startDate               </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc119">"2011-03-12"</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$subscription</span><span class="sc127">-&gt;</span><span class="sc118">totalOccurrences        </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc119">"12"</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$subscription</span><span class="sc127">-&gt;</span><span class="sc118">amount                  </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc119">"12.99"</span><span class="sc127">);</span><span class="sc118">
+    </span><span class="sc123">$subscription</span><span class="sc127">-&gt;</span><span class="sc118">creditCardCardNumber    </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc119">"6011000000000012"</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$subscription</span><span class="sc127">-&gt;</span><span class="sc118">creditCardExpirationDate</span><span class="sc127">=</span><span class="sc118"> </span><span class="sc119">"2018-10"</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$subscription</span><span class="sc127">-&gt;</span><span class="sc118">creditCardCardCode      </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc119">"123"</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$subscription</span><span class="sc127">-&gt;</span><span class="sc118">billToFirstName         </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc119">"Rasmus"</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$subscription</span><span class="sc127">-&gt;</span><span class="sc118">billToLastName          </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc119">"Doe"</span><span class="sc127">;</span><span class="sc118">
+
+    </span><span class="sc125">// Create the subscription.</span><span class="sc118">
+    </span><span class="sc123">$request</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc121">new</span><span class="sc118"> AuthorizeNetARB</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$response</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc123">$request</span><span class="sc127">-&gt;</span><span class="sc118">createSubscription</span><span class="sc127">(</span><span class="sc123">$subscription</span><span class="sc127">);</span><span class="sc118">
+    </span><span class="sc123">$subscription_id</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc123">$response</span><span class="sc127">-&gt;</span><span class="sc118">getSubscriptionId</span><span class="sc127">();</span><span class="sc118">
+</span><span class="sc18">?&gt;</span><span class="sc0"></span>
+</code>
+
+<h5>AuthorizeNetCIM.php Usage Example</h5>
+<code><span class="sc18">&lt;?php</span><span class="sc118">
+    </span><span class="sc121">require_once</span><span class="sc118"> </span><span class="sc120">'anet_php_sdk/AuthorizeNet.php'</span><span class="sc127">;</span><span class="sc118">
+    define</span><span class="sc127">(</span><span class="sc119">"AUTHORIZENET_API_LOGIN_ID"</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc119">"YOURLOGIN"</span><span class="sc127">);</span><span class="sc118">
+    define</span><span class="sc127">(</span><span class="sc119">"AUTHORIZENET_TRANSACTION_KEY"</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc119">"YOURKEY"</span><span class="sc127">);</span><span class="sc118">
+    </span><span class="sc123">$request</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc121">new</span><span class="sc118"> AuthorizeNetCIM</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc125">// Create new customer profile</span><span class="sc118">
+    </span><span class="sc123">$customerProfile</span><span class="sc118">                    </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc121">new</span><span class="sc118"> AuthorizeNetCustomer</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$customerProfile</span><span class="sc127">-&gt;</span><span class="sc118">description       </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc119">"Description of customer"</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$customerProfile</span><span class="sc127">-&gt;</span><span class="sc118">merchantCustomerId</span><span class="sc127">=</span><span class="sc118"> time</span><span class="sc127">();</span><span class="sc118">
+    </span><span class="sc123">$customerProfile</span><span class="sc127">-&gt;</span><span class="sc118">email             </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc119">"test@domain.com"</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$response</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc123">$request</span><span class="sc127">-&gt;</span><span class="sc118">createCustomerProfile</span><span class="sc127">(</span><span class="sc123">$customerProfile</span><span class="sc127">);</span><span class="sc118">
+    </span><span class="sc121">if</span><span class="sc118"> </span><span class="sc127">(</span><span class="sc123">$response</span><span class="sc127">-&gt;</span><span class="sc118">isOk</span><span class="sc127">())</span><span class="sc118"> </span><span class="sc127">{</span><span class="sc118">
+        </span><span class="sc123">$customerProfileId</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc123">$response</span><span class="sc127">-&gt;</span><span class="sc118">getCustomerProfileId</span><span class="sc127">();</span><span class="sc118">
+    </span><span class="sc127">}</span><span class="sc118">
+</span><span class="sc18">?&gt;</span><span class="sc0"></span>
+</code>
+
+<h5>AuthorizeNetSIM.php Usage Example</h5>
+<code><span class="sc18">&lt;?php</span><span class="sc118">
+    </span><span class="sc121">require_once</span><span class="sc118"> </span><span class="sc120">'anet_php_sdk/AuthorizeNet.php'</span><span class="sc127">;</span><span class="sc118">
+    define</span><span class="sc127">(</span><span class="sc119">"AUTHORIZENET_API_LOGIN_ID"</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc119">"YOURLOGIN"</span><span class="sc127">);</span><span class="sc118">
+    define</span><span class="sc127">(</span><span class="sc119">"AUTHORIZENET_MD5_SETTING"</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc119">""</span><span class="sc127">);</span><span class="sc118">
+    </span><span class="sc123">$message</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc121">new</span><span class="sc118"> AuthorizeNetSIM</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc121">if</span><span class="sc118"> </span><span class="sc127">(</span><span class="sc123">$message</span><span class="sc127">-&gt;</span><span class="sc118">isAuthorizeNet</span><span class="sc127">())</span><span class="sc118"> </span><span class="sc127">{</span><span class="sc118">
+        </span><span class="sc123">$transactionId</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc123">$message</span><span class="sc127">-&gt;</span><span class="sc118">transaction_id</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc127">}</span><span class="sc118">
+</span><span class="sc18">?&gt;</span><span class="sc0"></span>
+</code>
+
+<h5>AuthorizeNetDPM.php Usage Example</h5>
+<code><span class="sc18">&lt;?php</span><span class="sc118"> </span><span class="sc125">// Filename: direct_post.php</span><span class="sc118">
+    </span><span class="sc121">require_once</span><span class="sc118"> </span><span class="sc120">'anet_php_sdk/AuthorizeNet.php'</span><span class="sc127">;</span><span class="sc118"> </span><span class="sc125">// The SDK</span><span class="sc118">
+    </span><span class="sc123">$url</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc119">"http://YOUR_DOMAIN.com/direct_post.php"</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$api_login_id</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc120">'YOUR_API_LOGIN_ID'</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$transaction_key</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc120">'YOUR_TRANSACTION_KEY'</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$md5_setting</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc120">'YOUR_MD5_SETTING'</span><span class="sc127">;</span><span class="sc118"> </span><span class="sc125">// Your MD5 Setting</span><span class="sc118">
+    </span><span class="sc123">$amount</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc119">"5.99"</span><span class="sc127">;</span><span class="sc118">
+    AuthorizeNetDPM</span><span class="sc127">::</span><span class="sc118">directPostDemo</span><span class="sc127">(</span><span class="sc123">$url</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc123">$api_login_id</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc123">$transaction_key</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc123">$amount</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc123">$md5_setting</span><span class="sc127">);</span><span class="sc118">
+</span><span class="sc18">?&gt;</span><span class="sc0"></span>
+</code>
+
+<h5>AuthorizeNetCP.php Usage Example</h5>
+<code><span class="sc18">&lt;?php</span><span class="sc118">
+    </span><span class="sc121">require_once</span><span class="sc118"> </span><span class="sc120">'anet_php_sdk/AuthorizeNet.php'</span><span class="sc127">;</span><span class="sc118">
+    define</span><span class="sc127">(</span><span class="sc119">"AUTHORIZENET_API_LOGIN_ID"</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc119">"YOURLOGIN"</span><span class="sc127">);</span><span class="sc118">
+    define</span><span class="sc127">(</span><span class="sc119">"AUTHORIZENET_TRANSACTION_KEY"</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc119">"YOURKEY"</span><span class="sc127">);</span><span class="sc118">
+    define</span><span class="sc127">(</span><span class="sc119">"AUTHORIZENET_MD5_SETTING"</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc119">""</span><span class="sc127">);</span><span class="sc118">
+    </span><span class="sc123">$sale</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc121">new</span><span class="sc118"> AuthorizeNetCP</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$sale</span><span class="sc127">-&gt;</span><span class="sc118">amount </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc120">'59.99'</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$sale</span><span class="sc127">-&gt;</span><span class="sc118">device_type </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc120">'4'</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$sale</span><span class="sc127">-&gt;</span><span class="sc118">setTrack1Data</span><span class="sc127">(</span><span class="sc120">'%B4111111111111111^CARDUSER/JOHN^1803101000000000020000831000000?'</span><span class="sc127">);</span><span class="sc118">
+    </span><span class="sc123">$response</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc123">$sale</span><span class="sc127">-&gt;</span><span class="sc118">authorizeAndCapture</span><span class="sc127">();</span><span class="sc118">
+    </span><span class="sc123">$trans_id</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc123">$response</span><span class="sc127">-&gt;</span><span class="sc118">transaction_id</span><span class="sc127">;</span><span class="sc118">
+</span><span class="sc18">?&gt;</span><span class="sc0"></span>
+</code>
+
+<h5>AuthorizeNetTD.php Usage Example</h5>
+<code><span class="sc18">&lt;?php</span><span class="sc118">
+    </span><span class="sc121">require_once</span><span class="sc118"> </span><span class="sc120">'anet_php_sdk/AuthorizeNet.php'</span><span class="sc127">;</span><span class="sc118">
+    define</span><span class="sc127">(</span><span class="sc119">"AUTHORIZENET_API_LOGIN_ID"</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc119">"YOURLOGIN"</span><span class="sc127">);</span><span class="sc118">
+    define</span><span class="sc127">(</span><span class="sc119">"AUTHORIZENET_TRANSACTION_KEY"</span><span class="sc127">,</span><span class="sc118"> </span><span class="sc119">"YOURKEY"</span><span class="sc127">);</span><span class="sc118">
+    </span><span class="sc123">$request</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc121">new</span><span class="sc118"> AuthorizeNetTD</span><span class="sc127">;</span><span class="sc118">
+    </span><span class="sc123">$response</span><span class="sc118"> </span><span class="sc127">=</span><span class="sc118"> </span><span class="sc123">$request</span><span class="sc127">-&gt;</span><span class="sc118">getTransactionDetails</span><span class="sc127">(</span><span class="sc119">"12345"</span><span class="sc127">);</span><span class="sc118">
+    </span><span class="sc121">echo</span><span class="sc118"> </span><span class="sc123">$response</span><span class="sc127">-&gt;</span><span class="sc118">xml</span><span class="sc127">-&gt;</span><span class="sc118">transaction</span><span class="sc127">-&gt;</span><span class="sc118">transactionStatus</span><span class="sc127">;</span><span class="sc118">
+</span><span class="sc18">?&gt;</span>
+</code>
+    
+<br />
+<h4>Test Credit Card Numbers</h4>
+<table>
+       <tr><td>American Express Test Card</td><td>370000000000002</td></tr>
+       <tr><td>Discover Test Card</td><td>6011000000000012</td></tr>
+       <tr><td>Visa Test Card</td><td>4007000000027</td></tr>
+       <tr><td>Second Visa Test Card</td><td>4012888818888</td></tr>
+       <tr><td>JCB</td><td>3088000000000017</td></tr>
+       <tr><td>Diners Club/ Carte Blanche</td><td>38000000000006</td></tr>
+</table>
+<span class='indent'><small>Set the expiration date to anytime in the future.</small></span>
+<br />
+
+<h4>PHPDoc:</h4>
+  <span class='indent'>To autogenerate PHPDocs run</span>
+  <code>phpdoc -t phpdocs/ -f AuthorizeNet.php -d lib</code>
+
+<h4>Release Notes</h4>
+    <span class='indent'>
+    <em>Version 1.1.8</em>
+    <ul>
+        <li>
+            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.
+        </li>
+        <li>
+            Removed an unused validationMode argument in CIM::updateCustomerProfile. The parameter used to be ignored, now its removed.
+        </li>
+        <li>
+            Enhanced the tests with checks for single digit months in expiration date support and SSL certificate validity.
+        </li>
+    </ul>
+  <em>Version 1.1.7</em>
+  <ul>
+    <li>Added getBatchStatisticsRequest and getUnsettledTransactionListRequest support to the SDK.</li>
+  </ul>
+  <em>Version 1.1.6</em>
+  <ul>
+    <li>Added the HTML version of the README to the distributed bundle. It was missing in version 1.1.5.</li>
+  </ul>
+  <em>Version 1.1.5</em>
+  <ul>
+    <li>Added HTML version of README.</li>
+  </ul>
+  <em>Version 1.1.4</em>
+  <ul>
+    <li>Updated the cert.pem bundle to include the new secure.authorize.net SSL certificate.</li>
+  </ul>
+       <em>Version 1.1.3</em>
+       <ul>
+    <li>Added more documentation</li>
+    <li>Improved support for all Transaction Details API methods.</li>
+    <li>Added support for the Card Present API.</li>
+    <li>Added easier xpath support to XML Response class.</li>
+    <li>Added ability to use DPM sample app with production account.</li>
+       </ul>
+    <em>Version 1.1.2</em>
+       <ul>
+    <li>Added getValidationResponses method to CIM Response for parsing the validation results when validating payment profiles.</li>
+    <li>Added support for UpdateSplitTenderGroup method to CIM request.</li>
+    <li>Bug fix. In CIM requests using validation mode the the validation mode element should have been added to the end of the request.</li>
+    <li>Bug fix. In AIM Response class where $response->account_number was returning the wrong value.</li>
+       </ul>
+       </span>
+</body>
+</html>
\ No newline at end of file
diff --git a/lib/paymentProcessors/Authorize.Net/anet_php_sdk/doc/AIM.markdown b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/doc/AIM.markdown
new file mode 100755 (executable)
index 0000000..2ae1541
--- /dev/null
@@ -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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/doc/ARB.markdown b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/doc/ARB.markdown
new file mode 100755 (executable)
index 0000000..1d4bb92
--- /dev/null
@@ -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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/doc/CIM.markdown b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/doc/CIM.markdown
new file mode 100755 (executable)
index 0000000..bbe8a3b
--- /dev/null
@@ -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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/doc/CP.markdown b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/doc/CP.markdown
new file mode 100755 (executable)
index 0000000..96ea161
--- /dev/null
@@ -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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/doc/DPM.markdown b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/doc/DPM.markdown
new file mode 100755 (executable)
index 0000000..115cc9d
--- /dev/null
@@ -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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/doc/SIM.markdown b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/doc/SIM.markdown
new file mode 100755 (executable)
index 0000000..ee38e59
--- /dev/null
@@ -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:
+
+<form method="post" action="https://test.authorize.net/gateway/transact.dll">
+<?php
+$amount = "9.99";
+$fp_sequence = "123";
+$time = time();
+
+$fingerprint = AuthorizeNetSIM_Form::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'       => $fingerprint,
+    'x_fp_timestamp'  => $time,
+    'x_relay_response'=> "FALSE",
+    'x_login'         => $api_login_id,
+    )
+);
+echo $sim->getHiddenFieldString();?>
+<input type="submit" value="Buy Now">
+</form>
+
+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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/doc/SOAP.markdown b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/doc/SOAP.markdown
new file mode 100755 (executable)
index 0000000..a535f00
--- /dev/null
@@ -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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/doc/TD.markdown b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/doc/TD.markdown
new file mode 100755 (executable)
index 0000000..c9a1bfb
--- /dev/null
@@ -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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/AuthorizeNetAIM.php b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/AuthorizeNetAIM.php
new file mode 100755 (executable)
index 0000000..d63f98c
--- /dev/null
@@ -0,0 +1,502 @@
+<?php
+/**
+ * Easily interact with the Authorize.Net AIM API.
+ *
+ * Example Authorize and Capture Transaction against the Sandbox:
+ * <code>
+ * <?php require_once 'AuthorizeNet.php'
+ * $sale = new AuthorizeNetAIM;
+ * $sale->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;
+ * }
+ * ?>
+ * </code>
+ *
+ * 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 LIVE_URL = 'http://ws6.gaslightmedia.com/AuthorizeNetRelay/glmAuthNetRelay/AuthNetRelayProduction.php';
+    //const SANDBOX_URL = 'https://test.authorize.net/gateway/transact.dll';
+    const SANDBOX_URL = 'http://ws6.gaslightmedia.com/AuthorizeNetRelay/glmAuthNetRelay/AuthNetRelayTest.php';
+
+    /**
+     * 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_number       = $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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/AuthorizeNetARB.php b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/AuthorizeNetARB.php
new file mode 100755 (executable)
index 0000000..8df101a
--- /dev/null
@@ -0,0 +1,159 @@
+<?php
+/**
+ * Easily interact with the Authorize.Net ARB XML API.
+ *
+ * @package    AuthorizeNet
+ * @subpackage AuthorizeNetARB
+ * @link       http://www.authorize.net/support/ARB_guide.pdf ARB Guide
+ */
+
+
+/**
+ * A class to send a request to the ARB XML API.
+ *
+ * @package    AuthorizeNet
+ * @subpackage AuthorizeNetARB
+ */
+class AuthorizeNetARB extends AuthorizeNetRequest
+{
+
+    const LIVE_URL = "https://api.authorize.net/xml/v1/request.api";
+    const SANDBOX_URL = "https://apitest.authorize.net/xml/v1/request.api";
+
+    private $_request_type;
+    private $_request_payload;
+    
+    /**
+     * Optional. Used if the merchant wants to set a reference ID.
+     *
+     * @param string $refId
+     */
+    public function setRefId($refId)
+    {
+        $this->_request_payload = ($refId ? "<refId>$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>$subscriptionId</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>$subscriptionId</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>$subscriptionId</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 =<<<XML
+<?xml version="1.0" encoding="utf-8"?>
+<ARB{$this->_request_type} xmlns= "AnetApi/xml/v1/schema/AnetApiSchema.xsd">
+    <merchantAuthentication>
+        <name>{$this->_api_login}</name>
+        <transactionKey>{$this->_transaction_key}</transactionKey>
+    </merchantAuthentication>
+    {$this->_request_payload}
+</ARB{$this->_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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/AuthorizeNetCIM.php b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/AuthorizeNetCIM.php
new file mode 100755 (executable)
index 0000000..eb44342
--- /dev/null
@@ -0,0 +1,511 @@
+<?php
+/**
+ * Easily interact with the Authorize.Net CIM XML API.
+ *
+ * @package    AuthorizeNet
+ * @subpackage AuthorizeNetCIM
+ * @link       http://www.authorize.net/support/CIM_XML_guide.pdf CIM XML Guide
+ */
+
+
+
+/**
+ * A class to send a request to the CIM XML API.
+ *
+ * @package    AuthorizeNet
+ * @subpackage AuthorizeNetCIM
+ */ 
+class AuthorizeNetCIM extends AuthorizeNetRequest
+{
+
+    const LIVE_URL = "https://api.authorize.net/xml/v1/request.api";
+    const SANDBOX_URL = "https://apitest.authorize.net/xml/v1/request.api";
+
+    
+    private $_xml;
+    private $_refId = false;
+    private $_validationMode = "none"; // "none","testMode","liveMode"
+    private $_extraOptions;
+    private $_transactionTypes = array(
+        'AuthOnly',
+        'AuthCapture',
+        'CaptureOnly',
+        'PriorAuthCapture',
+        'Refund',
+        'Void',
+    );
+    
+    /**
+     * Optional. Used if the merchant wants to set a reference ID.
+     *
+     * @param string $refId
+     */
+    public function setRefId($refId)
+    {
+        $this->_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></extraOptions>",'<extraOptions><![CDATA[' . $this->_extraOptions . ']]></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 = '<?xml version="1.0" encoding="utf-8"?><'.$request_type.' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"></'.$request_type.'>';
+        $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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/AuthorizeNetCP.php b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/AuthorizeNetCP.php
new file mode 100755 (executable)
index 0000000..1ff0a3d
--- /dev/null
@@ -0,0 +1,222 @@
+<?php
+/**
+ * Easily interact with the Authorize.Net Card Present API.
+ *
+ *
+ * @package    AuthorizeNet
+ * @subpackage AuthorizeNetCP
+ * @link       http://www.authorize.net/support/CP_guide.pdf Card Present Guide
+ */
+
+/**
+ * Builds and sends an AuthorizeNet CP Request.
+ *
+ * @package    AuthorizeNet
+ * @subpackage AuthorizeNetCP
+ */
+class AuthorizeNetCP extends AuthorizeNetAIM
+{
+    
+    const LIVE_URL = 'https://cardpresent.authorize.net/gateway/transact.dll';
+    
+    public $verify_x_fields = false; 
+    
+    /**
+     * 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(
+        "cpversion" => "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") {
+                
+                $this->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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/AuthorizeNetDPM.php b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/AuthorizeNetDPM.php
new file mode 100755 (executable)
index 0000000..5e693cc
--- /dev/null
@@ -0,0 +1,237 @@
+<?php
+/**
+ * Demonstrates the Direct Post Method.
+ *
+ * To implement the Direct Post Method you need to implement 3 steps:
+ *
+ * Step 1: Add necessary hidden fields to your checkout form and make your form is set to post to AuthorizeNet.
+ *
+ * Step 2: Receive a response from AuthorizeNet, do your business logic, and return
+ *         a relay response snippet with a url to redirect the customer to.
+ *
+ * Step 3: Show a receipt page to your customer.
+ *
+ * This class is more for demonstration purposes than actual production use.
+ *
+ *
+ * @package    AuthorizeNet
+ * @subpackage AuthorizeNetDPM
+ */
+
+/**
+ * A class that demonstrates the DPM method.
+ *
+ * @package    AuthorizeNet
+ * @subpackage AuthorizeNetDPM
+ */
+class AuthorizeNetDPM extends AuthorizeNetSIM_Form
+{
+
+    const LIVE_URL = 'https://secure.authorize.net/gateway/transact.dll';
+    const SANDBOX_URL = 'https://test.authorize.net/gateway/transact.dll';
+
+    /**
+     * Implements all 3 steps of the Direct Post Method for demonstration
+     * purposes.
+     */
+    public static function directPostDemo($url, $api_login_id, $transaction_key, $amount = "0.00", $md5_setting = "")
+    {
+        
+        // Step 1: Show checkout form to customer.
+        if (!count($_POST) && !count($_GET))
+        {
+            $fp_sequence = time(); // Any sequential number like an invoice number.
+            echo AuthorizeNetDPM::getCreditCardForm($amount, $fp_sequence, $url, $api_login_id, $transaction_key);
+        }
+        // Step 2: Handle AuthorizeNet Transaction Result & return snippet.
+        elseif (count($_POST)) 
+        {
+            $response = new AuthorizeNetSIM($api_login_id, $md5_setting);
+            if ($response->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 "<html><head><script language=\"javascript\">
+                <!--
+                window.location=\"{$redirect_url}\";
+                //-->
+                </script>
+                </head><body><noscript><meta http-equiv=\"refresh\" content=\"1;url={$redirect_url}\"></noscript></body></html>";
+    }
+    
+    /**
+     * 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 = '
+        <style>
+        fieldset {
+            overflow: auto;
+            border: 0;
+            margin: 0;
+            padding: 0; }
+
+        fieldset div {
+            float: left; }
+
+        fieldset.centered div {
+            text-align: center; }
+
+        label {
+            color: #183b55;
+            display: block;
+            margin-bottom: 5px; }
+
+        label img {
+            display: block;
+            margin-bottom: 5px; }
+
+        input.text {
+            border: 1px solid #bfbab4;
+            margin: 0 4px 8px 0;
+            padding: 6px;
+            color: #1e1e1e;
+            -webkit-border-radius: 5px;
+            -moz-border-radius: 5px;
+            border-radius: 5px;
+            -webkit-box-shadow: inset 0px 5px 5px #eee;
+            -moz-box-shadow: inset 0px 5px 5px #eee;
+            box-shadow: inset 0px 5px 5px #eee; }
+        .submit {
+            display: block;
+            background-color: #76b2d7;
+            border: 1px solid #766056;
+            color: #3a2014;
+            margin: 13px 0;
+            padding: 8px 16px;
+            -webkit-border-radius: 12px;
+            -moz-border-radius: 12px;
+            border-radius: 12px;
+            font-size: 14px;
+            -webkit-box-shadow: inset 3px -3px 3px rgba(0,0,0,.5), inset 0 3px 3px rgba(255,255,255,.5), inset -3px 0 3px rgba(255,255,255,.75);
+            -moz-box-shadow: inset 3px -3px 3px rgba(0,0,0,.5), inset 0 3px 3px rgba(255,255,255,.5), inset -3px 0 3px rgba(255,255,255,.75);
+            box-shadow: inset 3px -3px 3px rgba(0,0,0,.5), inset 0 3px 3px rgba(255,255,255,.5), inset -3px 0 3px rgba(255,255,255,.75); }
+        </style>
+        <form method="post" action="'.$post_url.'">
+                '.$hidden_fields.'
+            <fieldset>
+                <div>
+                    <label>Credit Card Number</label>
+                    <input type="text" class="text" size="15" name="x_card_num" value="'.($prefill ? '6011000000000012' : '').'"></input>
+                </div>
+                <div>
+                    <label>Exp.</label>
+                    <input type="text" class="text" size="4" name="x_exp_date" value="'.($prefill ? '04/17' : '').'"></input>
+                </div>
+                <div>
+                    <label>CCV</label>
+                    <input type="text" class="text" size="4" name="x_card_code" value="'.($prefill ? '782' : '').'"></input>
+                </div>
+            </fieldset>
+            <fieldset>
+                <div>
+                    <label>First Name</label>
+                    <input type="text" class="text" size="15" name="x_first_name" value="'.($prefill ? 'John' : '').'"></input>
+                </div>
+                <div>
+                    <label>Last Name</label>
+                    <input type="text" class="text" size="14" name="x_last_name" value="'.($prefill ? 'Doe' : '').'"></input>
+                </div>
+            </fieldset>
+            <fieldset>
+                <div>
+                    <label>Address</label>
+                    <input type="text" class="text" size="26" name="x_address" value="'.($prefill ? '123 Main Street' : '').'"></input>
+                </div>
+                <div>
+                    <label>City</label>
+                    <input type="text" class="text" size="15" name="x_city" value="'.($prefill ? 'Boston' : '').'"></input>
+                </div>
+            </fieldset>
+            <fieldset>
+                <div>
+                    <label>State</label>
+                    <input type="text" class="text" size="4" name="x_state" value="'.($prefill ? 'MA' : '').'"></input>
+                </div>
+                <div>
+                    <label>Zip Code</label>
+                    <input type="text" class="text" size="9" name="x_zip" value="'.($prefill ? '02142' : '').'"></input>
+                </div>
+                <div>
+                    <label>Country</label>
+                    <input type="text" class="text" size="22" name="x_country" value="'.($prefill ? 'US' : '').'"></input>
+                </div>
+            </fieldset>
+            <input type="submit" value="BUY" class="submit buy">
+        </form>';
+        return $form;
+    }
+
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/AuthorizeNetSIM.php b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/AuthorizeNetSIM.php
new file mode 100755 (executable)
index 0000000..60297e5
--- /dev/null
@@ -0,0 +1,212 @@
+<?php
+/**
+ * Easily use the Authorize.Net Server Integration Method(SIM).
+ *
+ * @package    AuthorizeNet
+ * @subpackage AuthorizeNetSIM
+ * @link       http://www.authorize.net/support/SIM_guide.pdf SIM Guide
+ */
+
+/**
+ * Easily parse an AuthorizeNet SIM Response.
+ * @package    AuthorizeNet
+ * @subpackage AuthorizeNetSIM
+ */
+class AuthorizeNetSIM extends AuthorizeNetResponse
+{
+
+    // For ARB transactions
+    public $subscription_id;
+    public $subscription_paynum;
+
+    /**
+     * Constructor.
+     *
+     * @param string $api_login_id
+     * @param string $md5_setting For verifying an Authorize.Net message.
+     */
+    public function __construct($api_login_id = false, $md5_setting = false)
+    {
+        $this->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 .= '<input type="hidden" name="'.$key.'" value="'.$value.'">';
+            }
+        }
+        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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/AuthorizeNetSOAP.php b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/AuthorizeNetSOAP.php
new file mode 100755 (executable)
index 0000000..36c30a4
--- /dev/null
@@ -0,0 +1,99 @@
+<?php
+/**
+ * A simple wrapper for the SOAP API as well as a helper function
+ * to generate a documentation file from the WSDL.
+ *
+ * @package    AuthorizeNet
+ * @subpackage AuthorizeNetSoap
+ */
+
+/**
+ * A simple wrapper for the SOAP API as well as a helper function
+ * to generate a documentation file from the WSDL.
+ *
+ * @package    AuthorizeNet
+ * @subpackage AuthorizeNetSoap
+ * @todo       Make the doc file a usable class.
+ */
+class AuthorizeNetSOAP extends SoapClient
+{
+    const WSDL_URL = "https://api.authorize.net/soap/v1/Service.asmx?WSDL";
+    const LIVE_URL = "https://api.authorize.net/soap/v1/Service.asmx";
+    const SANDBOX_URL = "https://apitest.authorize.net/soap/v1/Service.asmx";
+    
+    public $sandbox;
+    
+    /**
+     * Constructor
+     */
+    public function __construct()
+    {
+        parent::__construct(self::WSDL_URL);
+        $this->__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 =  "<?php\n";
+        $string .= "/**\n";
+        $string .= " * Auto generated documentation for the AuthorizeNetSOAP API.\n";
+        $string .= " * Generated " . date("m/d/Y") . "\n";
+        $string .= " */\n";
+        $string .= "class AuthorizeNetSOAP\n";
+        $string .= "{\n" . $this->getSoapMethods() . "\n}\n\n" . $this->getSoapTypes() ."\n\n ?>";
+        return file_put_contents($path, $string);
+    }
+    
+    
+    
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/AuthorizeNetTD.php b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/AuthorizeNetTD.php
new file mode 100755 (executable)
index 0000000..e98a6cd
--- /dev/null
@@ -0,0 +1,209 @@
+<?php
+/**
+ * Easily interact with the Authorize.Net Transaction Details XML API.
+ *
+ * @package    AuthorizeNet
+ * @subpackage AuthorizeNetTD
+ * @link       http://www.authorize.net/support/ReportingGuide_XML.pdf Transaction Details XML Guide
+ */
+
+
+/**
+ * A class to send a request to the Transaction Details XML API.
+ *
+ * @package    AuthorizeNet
+ * @subpackage AuthorizeNetTD
+ */ 
+class AuthorizeNetTD extends AuthorizeNetRequest
+{
+
+    const LIVE_URL = "https://api.authorize.net/xml/v1/request.api";
+    const SANDBOX_URL = "https://apitest.authorize.net/xml/v1/request.api";
+    
+    private $_xml;
+    
+    /**
+     * This function returns information about a settled batch: Batch ID, Settlement Time, & 
+     * Settlement State. If you specify includeStatistics, you also receive batch statistics 
+     * by payment type.
+     *
+     *
+     * The detault date range is one day (the previous 24 hour period). The maximum date range is 31 
+     * days. The merchant time zone is taken into consideration when calculating the batch date range, 
+     * unless the Z is specified in the first and last settlement date
+     *
+     * @param bool   $includeStatistics
+     * @param string $firstSettlementDate //  yyyy-mmddTHH:MM:SS
+     * @param string $lastSettlementDate  //  yyyy-mmddTHH:MM:SS
+     * @param bool   $utc                 //  Use UTC instead of merchant time zone setting
+     *
+     * @return AuthorizeNetTD_Response
+     */
+    public function getSettledBatchList($includeStatistics = false, $firstSettlementDate = false, $lastSettlementDate = false, $utc = true)
+    {
+        $utc = ($utc ? "Z" : "");
+        $this->_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 = '<?xml version="1.0" encoding="utf-8"?><'.$request_type.' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"></'.$request_type.'>';
+        $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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/shared/AuthorizeNetRequest.php b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/shared/AuthorizeNetRequest.php
new file mode 100755 (executable)
index 0000000..a0749e0
--- /dev/null
@@ -0,0 +1,121 @@
+<?php
+/**
+ * Sends requests to the Authorize.Net gateways.
+ *
+ * @package    AuthorizeNet
+ * @subpackage AuthorizeNetRequest
+ */
+abstract class AuthorizeNetRequest
+{
+
+    protected $_api_login;
+    protected $_transaction_key;
+    protected $_post_string;
+    public $VERIFY_PEER = true; // Set to false if getting connection errors.
+    protected $_sandbox = true;
+    protected $_log_file = false;
+
+    /**
+     * Set the _post_string
+     */
+    abstract protected function _setPostString();
+
+    /**
+     * Handle the response string
+     */
+    abstract protected function _handleResponse($string);
+
+    /**
+     * Get the post url. We need this because until 5.3 you
+     * you could not access child constants in a parent class.
+     */
+    abstract protected function _getPostUrl();
+
+    /**
+     * Constructor.
+     *
+     * @param string $api_login_id       The Merchant's API Login ID.
+     * @param string $transaction_key The Merchant's Transaction Key.
+     */
+    public function __construct($api_login_id = false, $transaction_key = false)
+    {
+        $this->_api_login = ($api_login_id ? $api_login_id : (defined('AUTHORIZENET_API_LOGIN_ID') ? AUTHORIZENET_API_LOGIN_ID : ""));
+        $this->_transaction_key = ($transaction_key ? $transaction_key : (defined('AUTHORIZENET_TRANSACTION_KEY') ? AUTHORIZENET_TRANSACTION_KEY : ""));
+        $this->_sandbox = (defined('AUTHORIZENET_SANDBOX') ? AUTHORIZENET_SANDBOX : true);
+        $this->_log_file = (defined('AUTHORIZENET_LOG_FILE') ? AUTHORIZENET_LOG_FILE : false);
+    }
+
+    /**
+     * 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);  // Not used when submitting through our AuthNetRelay
+        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);
+    }
+
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/shared/AuthorizeNetResponse.php b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/shared/AuthorizeNetResponse.php
new file mode 100755 (executable)
index 0000000..7b96cb9
--- /dev/null
@@ -0,0 +1,75 @@
+<?php
+/**
+ * Base class for the AuthorizeNet AIM & SIM Responses.
+ *
+ * @package    AuthorizeNet
+ * @subpackage    AuthorizeNetResponse
+ */
+
+
+/**
+ * Parses an AuthorizeNet Response.
+ *
+ * @package AuthorizeNet
+ * @subpackage    AuthorizeNetResponse
+ */
+class AuthorizeNetResponse
+{
+
+    const APPROVED = 1;
+    const DECLINED = 2;
+    const ERROR = 3;
+    const HELD = 4;
+    
+    public $approved;
+    public $declined;
+    public $error;
+    public $held;
+    public $response_code;
+    public $response_subcode;
+    public $response_reason_code;
+    public $response_reason_text;
+    public $authorization_code;
+    public $avs_response;
+    public $transaction_id;
+    public $invoice_number;
+    public $description;
+    public $amount;
+    public $method;
+    public $transaction_type;
+    public $customer_id;
+    public $first_name;
+    public $last_name;
+    public $company;
+    public $address;
+    public $city;
+    public $state;
+    public $zip_code;
+    public $country;
+    public $phone;
+    public $fax;
+    public $email_address;
+    public $ship_to_first_name;
+    public $ship_to_last_name;
+    public $ship_to_company;
+    public $ship_to_address;
+    public $ship_to_city;
+    public $ship_to_state;
+    public $ship_to_zip_code;
+    public $ship_to_country;
+    public $tax;
+    public $duty;
+    public $freight;
+    public $tax_exempt;
+    public $purchase_order_number;
+    public $md5_hash;
+    public $card_code_response;
+    public $cavv_response; // cardholder_authentication_verification_response
+    public $account_number;
+    public $card_type;
+    public $split_tender_id;
+    public $requested_amount;
+    public $balance_on_card;
+    public $response; // The response string from AuthorizeNet.
+
+}
diff --git a/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/shared/AuthorizeNetTypes.php b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/shared/AuthorizeNetTypes.php
new file mode 100755 (executable)
index 0000000..42dd20f
--- /dev/null
@@ -0,0 +1,323 @@
+<?php
+/**
+ * Classes for the various AuthorizeNet data types.
+ *
+ * @package    AuthorizeNet
+ * @subpackage AuthorizeNetCIM
+ */
+
+
+/**
+ * A class that contains all fields for a CIM Customer Profile.
+ *
+ * @package    AuthorizeNet
+ * @subpackage AuthorizeNetCIM
+ */
+class AuthorizeNetCustomer
+{
+    public $merchantCustomerId;
+    public $description;
+    public $email;
+    public $paymentProfiles = array();
+    public $shipToList = array();
+    public $customerProfileId;
+    
+}
+/**
+ * A class that contains all fields for a CIM Address.
+ *
+ * @package    AuthorizeNet
+ * @subpackage AuthorizeNetCIM
+ */
+class AuthorizeNetAddress
+{
+    public $firstName;
+    public $lastName;
+    public $company;
+    public $address;
+    public $city;
+    public $state;
+    public $zip;
+    public $country;
+    public $phoneNumber;
+    public $faxNumber;
+    public $customerAddressId;
+}
+
+/**
+ * A class that contains all fields for a CIM Payment Profile.
+ *
+ * @package    AuthorizeNet
+ * @subpackage AuthorizeNetCIM
+ */
+class AuthorizeNetPaymentProfile
+{
+    
+    public $customerType;
+    public $billTo;
+    public $payment;
+    public $customerPaymentProfileId;
+    
+    public function __construct()
+    {
+        $this->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 = "<subscription>
+    <name>{$this->name}</name>
+    <paymentSchedule>
+        <interval>
+            <length>{$this->intervalLength}</length>
+            <unit>{$this->intervalUnit}</unit>
+        </interval>
+        <startDate>{$this->startDate}</startDate>
+        <totalOccurrences>{$this->totalOccurrences}</totalOccurrences>
+        <trialOccurrences>{$this->trialOccurrences}</trialOccurrences>
+    </paymentSchedule>
+    <amount>{$this->amount}</amount>
+    <trialAmount>{$this->trialAmount}</trialAmount>
+    <payment>
+        <creditCard>
+            <cardNumber>{$this->creditCardCardNumber}</cardNumber>
+            <expirationDate>{$this->creditCardExpirationDate}</expirationDate>
+            <cardCode>{$this->creditCardCardCode}</cardCode>
+        </creditCard>
+        <bankAccount>
+            <accountType>{$this->bankAccountAccountType}</accountType>
+            <routingNumber>{$this->bankAccountRoutingNumber}</routingNumber>
+            <accountNumber>{$this->bankAccountAccountNumber}</accountNumber>
+            <nameOnAccount>{$this->bankAccountNameOnAccount}</nameOnAccount>
+            <echeckType>{$this->bankAccountEcheckType}</echeckType>
+            <bankName>{$this->bankAccountBankName}</bankName>
+        </bankAccount>
+    </payment>
+    <order>
+        <invoiceNumber>{$this->orderInvoiceNumber}</invoiceNumber>
+        <description>{$this->orderDescription}</description>
+    </order>
+    <customer>
+        <id>{$this->customerId}</id>
+        <email>{$this->customerEmail}</email>
+        <phoneNumber>{$this->customerPhoneNumber}</phoneNumber>
+        <faxNumber>{$this->customerFaxNumber}</faxNumber>
+    </customer>
+    <billTo>
+        <firstName>{$this->billToFirstName}</firstName>
+        <lastName>{$this->billToLastName}</lastName>
+        <company>{$this->billToCompany}</company>
+        <address>{$this->billToAddress}</address>
+        <city>{$this->billToCity}</city>
+        <state>{$this->billToState}</state>
+        <zip>{$this->billToZip}</zip>
+        <country>{$this->billToCountry}</country>
+    </billTo>
+    <shipTo>
+        <firstName>{$this->shipToFirstName}</firstName>
+        <lastName>{$this->shipToLastName}</lastName>
+        <company>{$this->shipToCompany}</company>
+        <address>{$this->shipToAddress}</address>
+        <city>{$this->shipToCity}</city>
+        <state>{$this->shipToState}</state>
+        <zip>{$this->shipToZip}</zip>
+        <country>{$this->shipToCountry}</country>
+    </shipTo>
+</subscription>";
+        
+        $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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/shared/AuthorizeNetXMLResponse.php b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/shared/AuthorizeNetXMLResponse.php
new file mode 100755 (executable)
index 0000000..ede7854
--- /dev/null
@@ -0,0 +1,128 @@
+<?php
+/**
+ * Base class for the AuthorizeNet ARB & CIM Responses.
+ *
+ * @package    AuthorizeNet
+ * @subpackage AuthorizeNetXML
+ */
+
+/**
+ * Base class for the AuthorizeNet ARB & CIM Responses.
+ *
+ * @package    AuthorizeNet
+ * @subpackage AuthorizeNetXML
+ */
+class AuthorizeNetXMLResponse
+{
+
+    public $xml; // Holds a SimpleXML Element with response.
+
+    /**
+     * Constructor. Parses the AuthorizeNet response string.
+     *
+     * @param string $response The response from the AuthNet server.
+     */
+    public function __construct($response)
+    {
+        $this->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 = "</$elementName>";
+        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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/ssl/cert.pem b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/lib/ssl/cert.pem
new file mode 100755 (executable)
index 0000000..b59fbb0
--- /dev/null
@@ -0,0 +1,253 @@
+-----BEGIN CERTIFICATE-----
+MIIEYTCCA0mgAwIBAgIESyDOMjANBgkqhkiG9w0BAQUFADCBsTELMAkGA1UEBhMC
+VVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0
+Lm5ldC9ycGEgaXMgaW5jb3Jwb3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMW
+KGMpIDIwMDkgRW50cnVzdCwgSW5jLjEuMCwGA1UEAxMlRW50cnVzdCBDZXJ0aWZp
+Y2F0aW9uIEF1dGhvcml0eSAtIEwxQzAeFw0xMDAzMzExNzA0MDBaFw0xMjAzMzAx
+NzMzNTdaMIGVMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQG
+A1UEBxMNTW91bnRhaW4gVmlldzEgMB4GA1UEChMXQ3liZXJzb3VyY2UgQ29ycG9y
+YXRpb24xHTAbBgNVBAsTFFBsYXRpbnVtU1NMIFdpbGRjYXJkMRgwFgYDVQQDFA8q
+LmF1dGhvcml6ZS5uZXQwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAOSIsv0X
+OFMm2cV74o2jSF7zkNGeLHkPsI10xsFXTG1xqjzq4eImAReA3eIp1oHvLmji4kea
+rmTbxoURYdsRsWkx61b2vDrKJwjGU+hPvTYna0M4I9fpDgmp7e/Q5TJBWqI7BX9N
+2ccL95/2rV0g021JJhkqYMDFERTYRqkLFLfNAgMBAAGjggEdMIIBGTALBgNVHQ8E
+BAMCBaAwEwYDVR0lBAwwCgYIKwYBBQUHAwEwMwYDVR0fBCwwKjAooCagJIYiaHR0
+cDovL2NybC5lbnRydXN0Lm5ldC9sZXZlbDFjLmNybDAzBggrBgEFBQcBAQQnMCUw
+IwYIKwYBBQUHMAGGF2h0dHA6Ly9vY3NwLmVudHJ1c3QubmV0MEAGA1UdIAQ5MDcw
+NQYJKoZIhvZ9B0sCMCgwJgYIKwYBBQUHAgEWGmh0dHA6Ly93d3cuZW50cnVzdC5u
+ZXQvcnBhMB8GA1UdIwQYMBaAFB7xq4kG+EkPATN37hR67hl8kyhNMB0GA1UdDgQW
+BBQ/gzreJ5piCG2MLGy5XOBCVB9iTTAJBgNVHRMEAjAAMA0GCSqGSIb3DQEBBQUA
+A4IBAQCK6J1LZ3kGde6kzS4aGnPq5WUnJTdwB/ASIB15OOdK20Mdi7D0zF0Aevew
++f73shY3f7eozVmh8aCb7uDRojrBgLGdtj0vcRiqUm+e1LKf9p0XPdFMLGzh2E2W
++eLhBTMEYOgGPQDY/sf2MEKHRIgobccFI3LUUXylncY6+UKtUWJQ114duoZH0+o+
+RIlSRgGsGNYkWJ9+jeI6acvG15ahIzIfUx8m0vQp0Nri9/3p/HOezQjNdN0knTlR
+pRbXZJ65zOig2wjt4an0OfYnOcqpJ/2yslCv0/jKwumHeygVt68l3J4rH7nUwUzs
+B+JUkDiJgBD/+BFADuJkTJLMcn6t
+-----END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIE8jCCA9qgAwIBAgIEOGPp/DANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChML
+RW50cnVzdC5uZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9DUFNfMjA0OCBp
+bmNvcnAuIGJ5IHJlZi4gKGxpbWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAxOTk5
+IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNVBAMTKkVudHJ1c3QubmV0IENlcnRp
+ZmljYXRpb24gQXV0aG9yaXR5ICgyMDQ4KTAeFw0wOTEyMTAyMDQzNTRaFw0xOTEy
+MTAyMTEzNTRaMIGxMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNRW50cnVzdCwgSW5j
+LjE5MDcGA1UECxMwd3d3LmVudHJ1c3QubmV0L3JwYSBpcyBpbmNvcnBvcmF0ZWQg
+YnkgcmVmZXJlbmNlMR8wHQYDVQQLExYoYykgMjAwOSBFbnRydXN0LCBJbmMuMS4w
+LAYDVQQDEyVFbnRydXN0IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gTDFDMIIB
+IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAl6MtPJ7eBdoTwhGNnY7jf8dL
+flqfs/9iq3PIKGu6EGSChxPNVxj/KM7A5g4GkVApg9Hywyrb2NtOBMwA64u2lty8
+qvpSdwTB2xnkrpz9PIsD7028GgNl+cGxP3KG8jiqGa4QiHgo2nXDPQKCApy5wWV3
+diRMmPdtMTj72/7bNwJ2oRiXpszeIAlJNiRpQvbkN2LxWW2pPO00nKOO29w61/cK
+b+8u2NWTWnrtCElo4kHjWpDBhlX8UUOd4LLEZ7TLMjEl8FSfS9Fv29Td/K9ebHiQ
+ld7KOki5eTybGdZ1BaD5iNfB6KUJ5BoV3IcjqrJ1jGMlh9j4PabCzGb/pWZoVQID
+AQABo4IBCzCCAQcwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wMwYI
+KwYBBQUHAQEEJzAlMCMGCCsGAQUFBzABhhdodHRwOi8vb2NzcC5lbnRydXN0Lm5l
+dDAyBgNVHR8EKzApMCegJaAjhiFodHRwOi8vY3JsLmVudHJ1c3QubmV0LzIwNDhj
+YS5jcmwwOwYDVR0gBDQwMjAwBgRVHSAAMCgwJgYIKwYBBQUHAgEWGmh0dHA6Ly93
+d3cuZW50cnVzdC5uZXQvcnBhMB0GA1UdDgQWBBQe8auJBvhJDwEzd+4Ueu4ZfJMo
+TTAfBgNVHSMEGDAWgBRV5IHREYC+2Im5CKMx+aEkCRa5cDANBgkqhkiG9w0BAQUF
+AAOCAQEAB/ZfgoR/gEDHkDRGQiQDzi+ruoOeJXMN7awFacaH7aNc8lfBsUl2mk3y
+P93kDv4LPrmY2TKVHTL0Ae6cyMjlP+BTdmL83attPZSQ8sCzPJgnNl4olyL8G0DT
+Kw2ttVdt3w/jS+9zAhBl+hvQrDHV4w/oujIwg+5K0L/fIpB6vuw6G8RJBB3xroB3
+PEII26c7KKaAAQPmOaPr34BZG/MsvtxyRHmgbAelbU1EjkJoypR8Lja6hZ7NqsRe
+PFS+/i/qaZ0cHimbltjI/lGQ8SSmkAaz8Cmi/3gud1xFIdlEADHzvjJP9QoyDfz8
+uhZ2VrLWSJLyi6Y+t6xcaeoLP2ZFuQ==
+-----END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIEnzCCBAigAwIBAgIERp6RGjANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UEBhMC
+VVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50cnVzdC5u
+ZXQvQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMc
+KGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVzdC5u
+ZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wOTAz
+MjMxNTE4MjdaFw0xOTAzMjMxNTQ4MjdaMIG0MRQwEgYDVQQKEwtFbnRydXN0Lm5l
+dDFAMD4GA1UECxQ3d3d3LmVudHJ1c3QubmV0L0NQU18yMDQ4IGluY29ycC4gYnkg
+cmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5u
+ZXQgTGltaXRlZDEzMDEGA1UEAxMqRW50cnVzdC5uZXQgQ2VydGlmaWNhdGlvbiBB
+dXRob3JpdHkgKDIwNDgpMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
+rU1LqRKGsuqjIAcVFmQqK0vRvwtKTY7tgHalZ7d4QMBzQshowNtTK91euHaYNZOL
+Gp18EzoOH1u3Hs/lJBQesYGpjX24zGtLA/ECDNyrpUAkAH90lKGdCCmziAv1h3ed
+Vc3kw37XamSrhRSGlVuXMlBvPci6Zgzj/L24ScF2iUkZ/cCovYmjZy/Gn7xxGWC4
+LeksyZB2ZnuU4q941mVTXTzWnLLPKQP5L6RQstRIzgUyVYr9smRMDuSYB3Xbf9+5
+CFVghTAp+XtIpGmG4zU/HoZdenoVve8AjhUiVBcAkCaTvA5JaJG/+EfTnZVCwQ5N
+328mz8MYIWJmQ3DW1cAH4QIDAQABo4IBJzCCASMwDgYDVR0PAQH/BAQDAgEGMA8G
+A1UdEwEB/wQFMAMBAf8wMwYIKwYBBQUHAQEEJzAlMCMGCCsGAQUFBzABhhdodHRw
+Oi8vb2NzcC5lbnRydXN0Lm5ldDAzBgNVHR8ELDAqMCigJqAkhiJodHRwOi8vY3Js
+LmVudHJ1c3QubmV0L3NlcnZlcjEuY3JsMDsGA1UdIAQ0MDIwMAYEVR0gADAoMCYG
+CCsGAQUFBwIBFhpodHRwOi8vd3d3LmVudHJ1c3QubmV0L0NQUzAdBgNVHQ4EFgQU
+VeSB0RGAvtiJuQijMfmhJAkWuXAwHwYDVR0jBBgwFoAU8BdiE1U9s/8KAGv7UISX
+8+1i0BowGQYJKoZIhvZ9B0EABAwwChsEVjcuMQMCAIEwDQYJKoZIhvcNAQEFBQAD
+gYEAj2WiMI4mq4rsNRaY6QPwjRdfvExsAvZ0UuDCxh/O8qYRDKixDk2Ei3E277M1
+RfPB+JbFi1WkzGuDFiAy2r77r5u3n+F+hJ+ePFCnP1zCvouGuAiS7vhCKw0T43aF
+SApKv9ClOwqwVLht4wj5NI0LjosSzBcaM4eVyJ4K3FBTF3s=
+-----END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIE2DCCBEGgAwIBAgIEN0rSQzANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UEBhMC
+VVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50cnVzdC5u
+ZXQvQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMc
+KGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVzdC5u
+ZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05OTA1
+MjUxNjA5NDBaFw0xOTA1MjUxNjM5NDBaMIHDMQswCQYDVQQGEwJVUzEUMBIGA1UE
+ChMLRW50cnVzdC5uZXQxOzA5BgNVBAsTMnd3dy5lbnRydXN0Lm5ldC9DUFMgaW5j
+b3JwLiBieSByZWYuIChsaW1pdHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBF
+bnRydXN0Lm5ldCBMaW1pdGVkMTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUg
+U2VydmVyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGdMA0GCSqGSIb3DQEBAQUA
+A4GLADCBhwKBgQDNKIM0VBuJ8w+vN5Ex/68xYMmo6LIQaO2f55M28Qpku0f1BBc/
+I0dNxScZgSYMVHINiC3ZH5oSn7yzcdOAGT9HZnuMNSjSuQrfJNqc1lB5gXpa0zf3
+wkrYKZImZNHkmGw6AIr1NJtl+O3jEP/9uElY3KDegjlrgbEWGWG5VLbmQwIBA6OC
+AdcwggHTMBEGCWCGSAGG+EIBAQQEAwIABzCCARkGA1UdHwSCARAwggEMMIHeoIHb
+oIHYpIHVMIHSMQswCQYDVQQGEwJVUzEUMBIGA1UEChMLRW50cnVzdC5uZXQxOzA5
+BgNVBAsTMnd3dy5lbnRydXN0Lm5ldC9DUFMgaW5jb3JwLiBieSByZWYuIChsaW1p
+dHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBFbnRydXN0Lm5ldCBMaW1pdGVk
+MTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUgU2VydmVyIENlcnRpZmljYXRp
+b24gQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMCmgJ6AlhiNodHRwOi8vd3d3LmVu
+dHJ1c3QubmV0L0NSTC9uZXQxLmNybDArBgNVHRAEJDAigA8xOTk5MDUyNTE2MDk0
+MFqBDzIwMTkwNTI1MTYwOTQwWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAU8Bdi
+E1U9s/8KAGv7UISX8+1i0BowHQYDVR0OBBYEFPAXYhNVPbP/CgBr+1CEl/PtYtAa
+MAwGA1UdEwQFMAMBAf8wGQYJKoZIhvZ9B0EABAwwChsEVjQuMAMCBJAwDQYJKoZI
+hvcNAQEFBQADgYEAkNwwAvpkdMKnCqV8IY00F6j7Rw7/JXyNEwr75Ji174z4xRAN
+95K+8cPV1ZVqBLssziY2ZcgxxufuP+NXdYR6Ee9GTxj005i7qIcyunL2POI9n9cd
+2cNgQ4xYDiKWL2KjLB+6rQXvqzJ4h6BUcxm1XAX5Uj5tLUUL9wqT6u0G+bI=
+-----END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIDSTCCArKgAwIBAgIQfmO9EP9/fYY45sRzhqgfGzANBgkqhkiG9w0BAQUFADBM
+MQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkg
+THRkLjEWMBQGA1UEAxMNVGhhd3RlIFNHQyBDQTAeFw0wOTA0MDkwMDAwMDBaFw0x
+MTA0MTEyMzU5NTlaMIGPMQswCQYDVQQGEwJVUzENMAsGA1UECBMEVXRhaDEWMBQG
+A1UEBxMNQW1lcmljYW4gRm9yazEcMBoGA1UEChMTQXV0aG9yaXplLk5ldCBDb3Jw
+LjEcMBoGA1UECxMTQVVUSE9SSVpFLk5FVCBDT1JQLjEdMBsGA1UEAxMUc2VjdXJl
+LmF1dGhvcml6ZS5uZXQwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAN0dh86L
+70MHbun7wTNGV0pNXsnebt3z9mCpndLUiBp5J/b57hQO5/HvevkhkDyCrky/Dn7y
+4SEJh6RHYuP4ZBk30DS8iH5dWCRHqSQgpMKhUl/+D7KHbVqgPzOpOR44TiSa1P5m
+Fv0qicvRR3iwSK/6ESywNvEJk1iiYPnpnnlvAgMBAAGjgecwgeQwDAYDVR0TAQH/
+BAIwADA2BgNVHR8ELzAtMCugKaAnhiVodHRwOi8vY3JsLnRoYXd0ZS5jb20vVGhh
+d3RlU0dDQ0EuY3JsMCgGA1UdJQQhMB8GCCsGAQUFBwMBBggrBgEFBQcDAgYJYIZI
+AYb4QgQBMHIGCCsGAQUFBwEBBGYwZDAiBggrBgEFBQcwAYYWaHR0cDovL29jc3Au
+dGhhd3RlLmNvbTA+BggrBgEFBQcwAoYyaHR0cDovL3d3dy50aGF3dGUuY29tL3Jl
+cG9zaXRvcnkvVGhhd3RlX1NHQ19DQS5jcnQwDQYJKoZIhvcNAQEFBQADgYEARa0l
+PaGn4TOw3KOMVu8eiSdho4Nmal6u9AWE3rWHDakO2/a1AkZTM2/Wpt6KI3fp6WWK
+LSsa9wLoVYSJ6pI7bmiJTvyx42yPP0PZXQSz05PHgTEGyW2jAn4N1hFvbTj28mZT
+jv2jd12xgrmX34nulLdydNaM8J7CauhMvqwwvZ0=
+-----END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIDIzCCAoygAwIBAgIEMAAAAjANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJV
+UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xNzA1BgNVBAsTLkNsYXNzIDMgUHVi
+bGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQwNTEzMDAw
+MDAwWhcNMTQwNTEyMjM1OTU5WjBMMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhh
+d3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEWMBQGA1UEAxMNVGhhd3RlIFNHQyBD
+QTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA1NNn0I0Vf67NMf59HZGhPwtx
+PKzMyGT7Y/wySweUvW+Aui/hBJPAM/wJMyPpC3QrccQDxtLN4i/1CWPN/0ilAL/g
+5/OIty0y3pg25gqtAHvEZEo7hHUD8nCSfQ5i9SGraTaEMXWQ+L/HbIgbBpV8yeWo
+3nWhLHpo39XKHIdYYBkCAwEAAaOB/jCB+zASBgNVHRMBAf8ECDAGAQH/AgEAMAsG
+A1UdDwQEAwIBBjARBglghkgBhvhCAQEEBAMCAQYwKAYDVR0RBCEwH6QdMBsxGTAX
+BgNVBAMTEFByaXZhdGVMYWJlbDMtMTUwMQYDVR0fBCowKDAmoCSgIoYgaHR0cDov
+L2NybC52ZXJpc2lnbi5jb20vcGNhMy5jcmwwMgYIKwYBBQUHAQEEJjAkMCIGCCsG
+AQUFBzABhhZodHRwOi8vb2NzcC50aGF3dGUuY29tMDQGA1UdJQQtMCsGCCsGAQUF
+BwMBBggrBgEFBQcDAgYJYIZIAYb4QgQBBgpghkgBhvhFAQgBMA0GCSqGSIb3DQEB
+BQUAA4GBAFWsY+reod3SkF+fC852vhNRj5PZBSvIG3dLrWlQoe7e3P3bB+noOZTc
+q3J5Lwa/q4FwxKjt6lM07e8eU9kGx1Yr0Vz00YqOtCuxN5BICEIlxT6Ky3/rbwTR
+bcV0oveifHtgPHfNDs5IAn8BL7abN+AqKjbc1YXWrOU/VG+WHgWv
+-----END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkG
+A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz
+cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2
+MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV
+BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmlt
+YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN
+ADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE
+BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is
+I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G
+CSqGSIb3DQEBAgUAA4GBALtMEivPLCYATxQT3ab7/AoRhIzzKBxnki98tsX63/Do
+lbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59AhWM1pF+NEHJwZRDmJXNyc
+AA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2OmufTqj/ZA1k
+-----END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIFCjCCA/KgAwIBAgIERWua3DANBgkqhkiG9w0BAQUFADCBsDELMAkGA1UEBhMC
+VVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0
+Lm5ldC9DUFMgaXMgaW5jb3Jwb3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMW
+KGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsGA1UEAxMkRW50cnVzdCBSb290IENl
+cnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA5MTIxMDIwNTU0M1oXDTE5MTIxMDIx
+MjU0M1owgbExCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMTkw
+NwYDVQQLEzB3d3cuZW50cnVzdC5uZXQvcnBhIGlzIGluY29ycG9yYXRlZCBieSBy
+ZWZlcmVuY2UxHzAdBgNVBAsTFihjKSAyMDA5IEVudHJ1c3QsIEluYy4xLjAsBgNV
+BAMTJUVudHJ1c3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBMMUUwggEiMA0G
+CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2WwRUd90OJGbcKqHbgMxdx1/9UhZY
+2l+UBqm4trljDEcgguzHlU6LuHdSaj21h6nW4cx05abIwNRWT40u1gg+DExDPvBB
+k15G7znn2WUqDHZQJ71bDTMzB+D3oqmc4REzrWb80ix6qqNzFr6ThXUP1zeM+iO3
+ZPjjTG7tswW94jbbfN52RNqCcna2bv+UodCG9xDNSlqLsHWMZlKATkhMSYOmQNd3
+gRNNXnJ+SEYiqg/iPmWUOOFycf5KcQm6NX9ViT2B1bgoARB3NloQhdK9YIQrSWGU
+DN5MQGoqxHlghCSCMmlKmEviVhC6A0VRINPP2o5UG0W2erqXmlrYxtFfAgMBAAGj
+ggEnMIIBIzAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAzBggrBgEF
+BQcBAQQnMCUwIwYIKwYBBQUHMAGGF2h0dHA6Ly9vY3NwLmVudHJ1c3QubmV0MDMG
+A1UdHwQsMCowKKAmoCSGImh0dHA6Ly9jcmwuZW50cnVzdC5uZXQvcm9vdGNhMS5j
+cmwwOwYDVR0gBDQwMjAwBgRVHSAAMCgwJgYIKwYBBQUHAgEWGmh0dHA6Ly93d3cu
+ZW50cnVzdC5uZXQvQ1BTMB0GA1UdDgQWBBRbQYqyxEPBvb/IVEFVneCWrf+5oTAf
+BgNVHSMEGDAWgBRokORnpKZTgMeGZqTx90tD+4S9bTAZBgkqhkiG9n0HQQAEDDAK
+GwRWNy4xAwIAgTANBgkqhkiG9w0BAQUFAAOCAQEAsjvSnsG8O0i23NhaGGZTw701
+DUhCLDUB2BCi4uONLLqmAxHta7FJy1/N7GCzutQC62FPTn7435BfTtOQAhxS2hIA
+L5tx2gQSFMGQgy4o0hBAEYsmLeuZVVRvYI7Fgx3Aoz/VihQ5ahsN79NadznPabS9
+aW9PeNOhhqObt9f7qi3w+iah+WcsiEulNNWD+0zxW3AiZhubWU9NzpjbQaT+GqPr
+OOb58TkCnUa2ycKePoK2H5/KSqixBl8QNDv92nusM07tprdL85H1nAsRktwTasjV
+8TttlmsB5CNMscHg0hIhnynUrZU9pvfnMsV1twtX2KT5wOzsMjMMTa7oCNXsqg==
+-----END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIEmzCCBASgAwIBAgIEQoctTDANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UEBhMC
+VVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50cnVzdC5u
+ZXQvQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMc
+KGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVzdC5u
+ZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNzAx
+MDUxOTIwMzlaFw0xNzAxMDUxOTUwMzlaMIGwMQswCQYDVQQGEwJVUzEWMBQGA1UE
+ChMNRW50cnVzdCwgSW5jLjE5MDcGA1UECxMwd3d3LmVudHJ1c3QubmV0L0NQUyBp
+cyBpbmNvcnBvcmF0ZWQgYnkgcmVmZXJlbmNlMR8wHQYDVQQLExYoYykgMjAwNiBF
+bnRydXN0LCBJbmMuMS0wKwYDVQQDEyRFbnRydXN0IFJvb3QgQ2VydGlmaWNhdGlv
+biBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2lbZD
+QvrGbSpvSN+UTDlXBe7DeRFBaDbt7P6aAY+hOCj89xBGZi5NHhqxGk7G0cCViLDJ
+/zGLMwPbt4N7PiCEXu2yViin+OC5QHE3xctHDpcqaMAilWIV20fZ9dAr/4JLya0+
+3kzbkIBQPwmKhADsMAo9GM37/SpZmiOVFyxFnh9uQ3ltDFyY/kinxSNHXF79buce
+tPZoRdGGg1uiio2x4ymA/iVxiK2+vI+sUpZLqlGN5BMxGehOTZ/brLNq1bw5VHHK
+enp/kN19HYDZgbtZJsIR/uaT4veA5GX7NDcOKYBwTa84hi6ef1evnheu6xzLKCFf
+thzY56IEIvnT2tjLAgMBAAGjggEnMIIBIzAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0T
+AQH/BAUwAwEB/zAzBggrBgEFBQcBAQQnMCUwIwYIKwYBBQUHMAGGF2h0dHA6Ly9v
+Y3NwLmVudHJ1c3QubmV0MDMGA1UdHwQsMCowKKAmoCSGImh0dHA6Ly9jcmwuZW50
+cnVzdC5uZXQvc2VydmVyMS5jcmwwOwYDVR0gBDQwMjAwBgRVHSAAMCgwJgYIKwYB
+BQUHAgEWGmh0dHA6Ly93d3cuZW50cnVzdC5uZXQvQ1BTMB0GA1UdDgQWBBRokORn
+pKZTgMeGZqTx90tD+4S9bTAfBgNVHSMEGDAWgBTwF2ITVT2z/woAa/tQhJfz7WLQ
+GjAZBgkqhkiG9n0HQQAEDDAKGwRWNy4xAwIAgTANBgkqhkiG9w0BAQUFAAOBgQAM
+sIR8LRP+mj2/GAWVPSBIoxaBhxVQFaSIjZ9g1Dpv6y1uOoakqdLBnYl6CBykLbNH
+jg9kSm9mA4M/TzSUNqopbYuNAiIrjM13pXCVhpHRtr9SvjNqa5n5b+ESvgTLM7/1
+EhpORLpbFk0wufO0dM5u8mhWWN3Yof1UBfQjkYXJ+Q==
+-----END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIFdDCCBFygAwIBAgIETCA3bTANBgkqhkiG9w0BAQUFADCBsTELMAkGA1UE
+BhMCVVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5l
+bnRydXN0Lm5ldC9ycGEgaXMgaW5jb3Jwb3JhdGVkIGJ5IHJlZmVyZW5jZTEf
+MB0GA1UECxMWKGMpIDIwMDkgRW50cnVzdCwgSW5jLjEuMCwGA1UEAxMlRW50
+cnVzdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEwxRTAeFw0xMTAzMjMx
+NjQ4MzhaFw0xMzAzMjIyMzE4MDFaMIH4MQswCQYDVQQGEwJVUzETMBEGA1UE
+CBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzETMBEGCysG
+AQQBgjc8AgEDEwJVUzEZMBcGCysGAQQBgjc8AgECEwhEZWxhd2FyZTEgMB4G
+A1UEChMXQ3liZXJzb3VyY2UgQ29ycG9yYXRpb24xHTAbBgNVBA8TFFByaXZh
+dGUgT3JnYW5pemF0aW9uMRwwGgYDVQQLExNBVVRIT1JJWkUuTkVUIENPUlAu
+MS0wDgYDVQQFEwcyODM4OTIxMBsGA1UEAxMUc2VjdXJlLmF1dGhvcml6ZS5u
+ZXQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvrwbLk7kDJnja
+13i9lcXhYlHIwCTKHegPRuAkGDO6hNH0yNVv10kQSWjKhZ6KnoEA2p0F92FN
+HwFTUfm0QGlaXW9kPc8nUi94hgY05iYwh96FHNdibqeO2r73GGol/RJkUO69
+ekqP1f+ABi7qWguL29cadX1DmOVQSkIeWc0xn9IVgS8dxnDzKwJ+41M5gLfM
+YAJQ/FOwjOpt0j/Kg+38iHZ71FM7ehceYFggn+7y0ZcAcDUx4l6sKBuqFXq7
+viMqP2/Np0TpzmJMi2X8Wy0FDYoilHb9qBJWkl2AYxfjLTTSu27OMAJYyvEM
+RmjOkLn7hQBPoSE6u3UKevtF2WPtAgMBAAGjggFJMIIBRTALBgNVHQ8EBAMC
+BaAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMDMGCCsGAQUFBwEB
+BCcwJTAjBggrBgEFBQcwAYYXaHR0cDovL29jc3AuZW50cnVzdC5uZXQwMwYD
+VR0fBCwwKjAooCagJIYiaHR0cDovL2NybC5lbnRydXN0Lm5ldC9sZXZlbDFl
+LmNybDBBBgNVHSAEOjA4MDYGCmCGSAGG+mwKAQIwKDAmBggrBgEFBQcCARYa
+aHR0cDovL3d3dy5lbnRydXN0Lm5ldC9ycGEwHwYDVR0RBBgwFoIUc2VjdXJl
+LmF1dGhvcml6ZS5uZXQwHwYDVR0jBBgwFoAUW0GKssRDwb2/yFRBVZ3glq3/
+uaEwHQYDVR0OBBYEFGZazQ8qcWqAiT+oFpV/D7WTbcGlMAkGA1UdEwQCMAAw
+DQYJKoZIhvcNAQEFBQADggEBAEG1lvV2JQXDXRmEXkDp5qpF6uj1eNfffViE
+QR6XCLPWIuaEcgnieTfFzRPEYbxzUY9jCqM62U37hUTDdMKjZas7fwaZ8RjE
+wQASNPrIsHFsXEb0Nbz58g3cY00teCH3qQ9N9uW3TC+OXiSz9aSBxYkHD/63
+2D1rzaZLVHXUoReMMbjwf69zLDN7qsy6VDksHMVjqQugZF0ZCLFPPH5jfdAx
+sOtocx7eyUovzO387ve8UMTdw6Anr9Ai7iVaYf4MpMqcuaHVet3QeE97Koy1
+mT3q9FmUGbXM+nCqSs/TQ4jSqOo4zqDnkK/cOgbzjsuJJZ/rCPSxaKvz3b/n
+wMWH7kM=
+-----END CERTIFICATE-----
\ No newline at end of file
diff --git a/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNetAIM_Test.php b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNetAIM_Test.php
new file mode 100755 (executable)
index 0000000..d403735
--- /dev/null
@@ -0,0 +1,888 @@
+<?php
+
+require_once 'AuthorizeNet_Test_Config.php';
+
+class AuthorizeNetAIM_Sandbox_Test extends PHPUnit_Framework_TestCase
+{
+    
+    public function testAuthCapture()
+    {
+        $sale = new AuthorizeNetAIM;
+        $sale->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_number = "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_number, $response->invoice_number);
+        $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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNetARB_Test.php b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNetARB_Test.php
new file mode 100755 (executable)
index 0000000..ef120af
--- /dev/null
@@ -0,0 +1,201 @@
+<?php
+
+require_once 'AuthorizeNet_Test_Config.php';
+
+class AuthorizeNetARB_Test extends PHPUnit_Framework_TestCase
+{
+
+    public function testAllMethods()
+    {
+        // Set the subscription fields.
+        $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";
+        
+        // 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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNetCIM_Test.php b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNetCIM_Test.php
new file mode 100755 (executable)
index 0000000..75c58d9
--- /dev/null
@@ -0,0 +1,355 @@
+<?php
+
+require_once 'AuthorizeNet_Test_Config.php';
+
+
+class AuthorizeNetCIM_Test extends PHPUnit_Framework_TestCase
+{
+    
+  public function testDeleteAllCustomerProfiles()
+  {
+    $request = new AuthorizeNetCIM;
+    $response = $request->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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNetCP_Test.php b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNetCP_Test.php
new file mode 100755 (executable)
index 0000000..aa8c580
--- /dev/null
@@ -0,0 +1,179 @@
+<?php
+
+require_once 'AuthorizeNet_Test_Config.php';
+
+class AuthorizeNetCP_Test extends PHPUnit_Framework_TestCase
+{
+    
+    public function testAuthCapture()
+    {
+        $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);
+    }
+    
+    // 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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNetDPM_Test.php b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNetDPM_Test.php
new file mode 100755 (executable)
index 0000000..78b7e5a
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+
+require_once 'AuthorizeNet_Test_Config.php';
+
+class AuthorizeNetDPM_Test extends PHPUnit_Framework_TestCase
+{ 
+    public function testGenerateFingerprint()
+    {
+        $this->assertEquals("db88bbebb8f699acdbe70daad897a68a",AuthorizeNetDPM::getFingerprint("123","123","123","123","123"));
+    }
+    
+    public function testGetCreditCardForm()
+    {
+        $fp_sequence = "12345";
+        $this->assertContains('<input type="hidden" name="x_fp_sequence" value="'.$fp_sequence.'">',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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNetSIM_Test.php b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNetSIM_Test.php
new file mode 100755 (executable)
index 0000000..62ef5a3
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+
+require_once 'AuthorizeNet_Test_Config.php';
+
+class AuthorizeNetSIM_Test extends PHPUnit_Framework_TestCase
+{
+    
+    public function testGenerateHash()
+    {
+        $_POST['x_amount'] = "4.12";
+        $_POST['x_trans_id'] = "123";
+        $message = new AuthorizeNetSIM("528udYYwz","test");
+        $this->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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNetSSL_Test.php b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNetSSL_Test.php
new file mode 100755 (executable)
index 0000000..b4191e1
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+
+class AuthorizeNetTD_Test extends PHPUnit_Framework_TestCase {
+    public function testSandboxSSLCertIsValid()
+    {
+        exec("echo | openssl s_client -connect test.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 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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNetTD_Test.php b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNetTD_Test.php
new file mode 100755 (executable)
index 0000000..4e12168
--- /dev/null
@@ -0,0 +1,96 @@
+<?php
+
+require_once 'AuthorizeNet_Test_Config.php';
+
+
+class AuthorizeNetTD_Test extends PHPUnit_Framework_TestCase
+{
+
+
+    public function testGetSettledBatchList()
+    {
+        $request = new AuthorizeNetTD;
+        $response = $request->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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNet_SOAP_Test.php b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNet_SOAP_Test.php
new file mode 100755 (executable)
index 0000000..20b87d7
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+
+require_once 'AuthorizeNet_Test_Config.php';
+
+class AuthorizeNet_SOAP_Test extends PHPUnit_Framework_TestCase
+{
+    
+    public function testSaveSoapDoc ()
+    {
+        $filepath = dirname(__FILE__) . "/soap_doc.php";
+        $client = new AuthorizeNetSOAP;
+        $this->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/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNet_Test_Config.php b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/AuthorizeNet_Test_Config.php
new file mode 100755 (executable)
index 0000000..1038042
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+/**
+ * Tests for the AuthorizeNet PHP SDK
+ */
+
+/**
+ * Enter your test account credentials to run tests against sandbox.
+ */
+define("AUTHORIZENET_API_LOGIN_ID", "");
+define("AUTHORIZENET_TRANSACTION_KEY", "");
+define("AUTHORIZENET_MD5_SETTING", "");
+/**
+ * Enter your live account credentials to run tests against production gateway.
+ */
+define("MERCHANT_LIVE_API_LOGIN_ID", "");
+define("MERCHANT_LIVE_TRANSACTION_KEY", "");
+
+/**
+ * Card Present Sandbox Credentials
+ */
+define("CP_API_LOGIN_ID", "");
+define("CP_TRANSACTION_KEY", "");
+
+
+define("AUTHORIZENET_LOG_FILE", dirname(__FILE__) . "/log");
+// Clear logfile
+file_put_contents(AUTHORIZENET_LOG_FILE, "");
+
+
+
+
+
+if (!function_exists('curl_init')) {
+    throw new Exception('AuthorizeNetSDK needs the CURL PHP extension.');
+}
+
+
+if (!function_exists('simplexml_load_file')) {
+  throw new Exception('The AuthorizeNet SDK requires the SimpleXML PHP extension.');
+}
+
+require_once dirname(dirname(__FILE__)) . '/AuthorizeNet.php';
+require_once 'PHPUnit/Framework.php';
+
+if (AUTHORIZENET_API_LOGIN_ID == "") {
+    die('Enter your merchant credentials in '.__FILE__.' before running the test suite.');
+}
diff --git a/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/README b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/README
new file mode 100755 (executable)
index 0000000..062a2d3
--- /dev/null
@@ -0,0 +1,17 @@
+By:
+    Authorize.Net
+    http://developer.authorize.net
+    http://community.developer.authorize.net
+
+About:
+    Integration tests for the AuthorizeNet SDK. These tests are mainly
+    for SDK development. However, you can also browse through these
+    tests to find more usage examples for the various APIs.
+
+Requirements:
+    - PHPUnit
+    - An Authorize.Net Test Account and/or Merchant Account. You can get a 
+      free test account at http://developer.authorize.net/testaccount/
+    
+Usage:
+    - On the command line in this folder run: phpunit .
\ No newline at end of file
diff --git a/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/domain.crt b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/domain.crt
new file mode 100755 (executable)
index 0000000..14e348d
--- /dev/null
@@ -0,0 +1,51 @@
+CONNECTED(00000003)
+---
+Certificate chain
+ 0 s:/C=US/ST=Utah/L=American Fork/O=Authorize.Net Corp./OU=AUTHORIZE.NET CORP./CN=secure.authorize.net
+   i:/C=ZA/O=Thawte Consulting (Pty) Ltd./CN=Thawte SGC CA
+ 1 s:/C=ZA/O=Thawte Consulting (Pty) Ltd./CN=Thawte SGC CA
+   i:/C=US/O=VeriSign, Inc./OU=Class 3 Public Primary Certification Authority
+---
+Server certificate
+-----BEGIN CERTIFICATE-----
+MIIDSTCCArKgAwIBAgIQfmO9EP9/fYY45sRzhqgfGzANBgkqhkiG9w0BAQUFADBM
+MQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkg
+THRkLjEWMBQGA1UEAxMNVGhhd3RlIFNHQyBDQTAeFw0wOTA0MDkwMDAwMDBaFw0x
+MTA0MTEyMzU5NTlaMIGPMQswCQYDVQQGEwJVUzENMAsGA1UECBMEVXRhaDEWMBQG
+A1UEBxMNQW1lcmljYW4gRm9yazEcMBoGA1UEChMTQXV0aG9yaXplLk5ldCBDb3Jw
+LjEcMBoGA1UECxMTQVVUSE9SSVpFLk5FVCBDT1JQLjEdMBsGA1UEAxMUc2VjdXJl
+LmF1dGhvcml6ZS5uZXQwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAN0dh86L
+70MHbun7wTNGV0pNXsnebt3z9mCpndLUiBp5J/b57hQO5/HvevkhkDyCrky/Dn7y
+4SEJh6RHYuP4ZBk30DS8iH5dWCRHqSQgpMKhUl/+D7KHbVqgPzOpOR44TiSa1P5m
+Fv0qicvRR3iwSK/6ESywNvEJk1iiYPnpnnlvAgMBAAGjgecwgeQwDAYDVR0TAQH/
+BAIwADA2BgNVHR8ELzAtMCugKaAnhiVodHRwOi8vY3JsLnRoYXd0ZS5jb20vVGhh
+d3RlU0dDQ0EuY3JsMCgGA1UdJQQhMB8GCCsGAQUFBwMBBggrBgEFBQcDAgYJYIZI
+AYb4QgQBMHIGCCsGAQUFBwEBBGYwZDAiBggrBgEFBQcwAYYWaHR0cDovL29jc3Au
+dGhhd3RlLmNvbTA+BggrBgEFBQcwAoYyaHR0cDovL3d3dy50aGF3dGUuY29tL3Jl
+cG9zaXRvcnkvVGhhd3RlX1NHQ19DQS5jcnQwDQYJKoZIhvcNAQEFBQADgYEARa0l
+PaGn4TOw3KOMVu8eiSdho4Nmal6u9AWE3rWHDakO2/a1AkZTM2/Wpt6KI3fp6WWK
+LSsa9wLoVYSJ6pI7bmiJTvyx42yPP0PZXQSz05PHgTEGyW2jAn4N1hFvbTj28mZT
+jv2jd12xgrmX34nulLdydNaM8J7CauhMvqwwvZ0=
+-----END CERTIFICATE-----
+subject=/C=US/ST=Utah/L=American Fork/O=Authorize.Net Corp./OU=AUTHORIZE.NET CORP./CN=secure.authorize.net
+issuer=/C=ZA/O=Thawte Consulting (Pty) Ltd./CN=Thawte SGC CA
+---
+No client certificate CA names sent
+---
+SSL handshake has read 1791 bytes and written 306 bytes
+---
+New, TLSv1/SSLv3, Cipher is RC4-MD5
+Server public key is 1024 bit
+Compression: NONE
+Expansion: NONE
+SSL-Session:
+    Protocol  : TLSv1
+    Cipher    : RC4-MD5
+    Session-ID: 03130000B43AEDC6A4B731EB5FA519E70B6CAC52856869A8593521601F677C28
+    Session-ID-ctx: 
+    Master-Key: C92AA33E812EFC279AAFF16922CFB3519F94FDA820ED3158A72BD97D3BB2D0EC938E7E71817958DB545EA2E147CCC84A
+    Key-Arg   : None
+    Start Time: 1297707939
+    Timeout   : 300 (sec)
+    Verify return code: 20 (unable to get local issuer certificate)
+---
diff --git a/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/report.html b/lib/paymentProcessors/Authorize.Net/anet_php_sdk/tests/report.html
new file mode 100755 (executable)
index 0000000..764ae3d
--- /dev/null
@@ -0,0 +1 @@
+<html><body><h2 id="AuthorizeNet_SOAP_Test">AuthorizeNet_SOAP_</h2><ul><li>Save soap doc</li><li>Get customer ids</li></ul><h2 id="AuthorizeNetAIM_Sandbox_Test">AuthorizeNetAIM_Sandbox_</h2><ul><li>Auth capture</li><li>Auth capture alternate</li><li>Auth capture short</li><li>Auth capture partial</li><li>Auth capture short no verify</li><li>Aim response fields</li><li>Void</li><li>Void short</li><li>Auth capture e check sandbox</li><li>Amex</li><li>Discover</li><li>Visa</li><li>Auth only</li><li>Auth capture void</li><li>Advanced a i m</li><li>Auth capture custom fields</li><li>Encap character</li><li>Auth capture set multiple custom fields</li><li>Invalid merchant credentials</li><li>Invalid credit card</li><li>Error</li><li>Multiple line items</li><li>All fields long method</li><li>Response methods</li><li>Set bad field</li></ul><h2 id="AuthorizeNetAIM_Live_Test">AuthorizeNetAIM_Live_</h2><ul><li>Auth capture set e check method</li><li>Auth capture e check</li><li>Auth capture live server test request</li><li>Auth capture live server</li><li>Invalid credentials</li></ul><h2 id="AuthorizeNetARB_Test">AuthorizeNetARB_</h2><ul><li><strike>All methods</strike></li><li>Create subscription long</li><li>Create subscription e check</li></ul><h2 id="AuthorizeNetCIM_Test">AuthorizeNetCIM_</h2><ul><li>Delete all customer profiles</li><li>X path</li><li>Create customer profile</li><li>Get customer profile</li><li>Create customer profile with validation mode</li><li>Update split tender group</li><li>All</li><li>Get customer profile ids</li></ul><h2 id="AuthorizeNetCP_Test">AuthorizeNetCP_</h2><ul><li>Auth capture</li><li>Auth capture track 1</li><li>Auth capture track</li><li>Auth capture track 2 error</li><li>Response fields</li><li>Xml response</li><li>Xml response failure</li></ul><h2 id="AuthorizeNetDPM_Test">AuthorizeNetDPM_</h2><ul><li>Generate fingerprint</li><li>Get credit card form</li><li>Relay response url</li></ul><h2 id="AuthorizeNetSIM_Test">AuthorizeNetSIM_</h2><ul><li>Generate hash</li><li>Amount</li><li>Is auth net</li><li>Is error</li></ul><h2 id="AuthorizeNetTD_Test">AuthorizeNetTD_</h2><ul><li>Get settled batch list</li><li>Get settled batch list include statistics</li><li>Get settled batch list for month</li><li>Get transactions for day</li><li>Get transaction list</li><li>Get transaction details</li></ul></body></html>
\ No newline at end of file
diff --git a/lib/paymentProcessors/Authorize.Net/paymentGateway.php b/lib/paymentProcessors/Authorize.Net/paymentGateway.php
new file mode 100644 (file)
index 0000000..c3e7d37
--- /dev/null
@@ -0,0 +1,285 @@
+<?php
+/**
+ * Authorize.net PaymentGateway class
+ *
+ * @category Front-End
+ * @package  EventManagement
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: AuthorizeNet.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ * @link     <>
+ */
+require_once dirname(__FILE__).'/anet_php_sdk/AuthorizeNet.php';
+
+/**
+ * Authorize.net PaymentGateway class
+ *
+ * PHP version 5
+ *
+ * @category Event Management Admin Tickets
+ * @package  EventManagement
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: AuthorizeNet.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ * @link     <>
+ */
+
+class PaymentGateway
+{
+       /**
+        * account
+        *
+        * @var array
+        * @access public
+        */
+       var $account;
+
+       /**
+        * Constructor
+        *
+        * @param array $account Account information
+        *
+        * @access public
+        *
+        * Information provided
+        *
+        * $account
+        *              login                   Authorize.net login
+        *              key                             Authorize.net login key
+        *              test                    Test mode
+        *                                                      0 = Production Mode
+        *                                                      1 = Local Transaction Approval Test
+        *                                                      2 = Local Transaction Decline Test
+        *                                                      3 = On-Line Transaction Test
+        *              conf                    True if Authorize.net should send confirmation E-Mail to customer
+        *              email                   Merchant E-Mail address to receive notices from Authorize.net for the transaction
+        *
+        * Test Account
+        *              login:                  GLM4AuthNet
+        *              PW:                 GLm7AuTHnet
+        * API Access
+        *              API Login ID:           44pvQ8D7d
+        *              Transaction Key:        8rj6ME772K9Pe9pJ
+        *              Secret Question:        Simon
+        * Admin Interface:     https://test.authorize.net/
+        *
+        */
+       public function __construct($account)
+       {
+               $this->account = $account;
+       }
+
+       /**
+        * Process a Payment
+        *
+        * @param payment Array payment information
+        * @param contact Array contact information
+        *
+        * @access public
+        * @return array
+        *
+        * Information provided
+        *
+        * $payment array
+        *              name                            Name of Venue
+        *              charge                          Total to be charged
+        *              cctype                          Card type (not used for Authorize.net)
+        *              ccname                          Name on card (not used for Authorize.net)
+        *              ccnumb                          Card number
+        *              ccexp                           Expiration date (m/y)
+        *              cccode                          Security code on back of card
+        *              invoice                         Invoice # is session ID (or some part thereof)
+        *                                                              Max 20 chars, letters and digits only
+        *                                                              Only last 20 chars used if longer
+        *
+        * $contact array
+        *              fname                           Customer first name
+        *              lname                           Customer last name
+        *              addr1                           Address Line 1
+        *              addr2                           Address Line 2
+        *              city                            City
+        *              state                           State
+        *              country                         Country
+        *              zip                                     ZIP/Postal code
+        *              phone                           Customer phone number
+        *              email                           Customer E-Mail address
+        *
+        * return array
+        *              status                          Numeric return status code
+        *                                                              1               Approved
+        *                                                              2               Bad data supplied
+        *                                                              3               Communications failure
+        *                                                              4               Bad response
+        *                                                              5               Transaction not valid
+        *                                                              6               Merchant account problem
+        *                                                              7               Card declined
+        *              statusText                      Short name of status
+        *              authCode                        Authorization code - blank if card not accepted
+        *              description                     Longer description of result
+        *
+        * Authorize.net test card numbers
+        *              American Express        370000000000002
+     *         Discover                        6011000000000012
+     *         Visa                            4007000000027
+     *                                                 4012888818888
+     *         JCB                                     3088000000000017
+     *                 Diners Club                     38000000000006
+     *                 Carte Blanche           38000000000006
+        */
+       public function processPayment($payment = false, $contact = false)
+       {
+
+               // Check for required data
+               if (!is_array($payment) || !is_array($payment)) {
+                       $resp = array(
+                           'gateway' => 'Authorize.Net',
+                           'status' => 2,
+                               'statusText' => 'Bad Data Supplied',
+                               'authCode' => '',
+                               'description' => 'The required payment and contact information was not supplied.'
+                       );
+                       return $resp;
+               }
+
+               // Create a new sale instance
+               $sale = new AuthorizeNetAIM($this->account['login'], $this->account['key']);
+               $sale->setSandbox(false);
+
+               // Check for local tests that don't require communication with Authorize.net
+               switch ($this->account['test']) {
+
+                       // Local Test
+                       case 1:
+                               // Always return a card approval
+                               $resp = array(
+                    'gateway' => 'Authorize.Net',
+                    'status' => 1,
+                    'statusText' => 'Card Approved',
+                    'authCode' => '000000',
+                    'description' => '(TESTMODE) Local Test - Card Approved'
+                               );
+                               return $resp;
+                               break;
+
+                       // Fail Test
+                       case 2:
+                               $resp = array(
+                    'gateway' => 'Authorize.Net',
+                    'status' => 7,
+                    'statusText' => 'Card Declined',
+                    'authCode' => '',
+                    'description' => '(TESTMODE) Local Test - Card Declined'
+                               );
+                               return $resp;
+                               break;
+
+                       // Online Test
+                       case 3:
+                               // Use the Authorize.net test sandbox
+                               $sale->setSandbox(true);
+                               $sale->test_request = true;
+                               break;
+
+                       // Production Mode
+                       case 0:
+
+                               break;
+               }
+
+               // Provide transaction information - Might want to validate this better some day
+               $sale->amount = $payment['charge'];
+               $sale->card_num = $payment['ccnumb'];
+               $sale->card_code = $payment['cccode'];
+               $sale->exp_date = $payment['ccexp'];
+               $sale->first_name = $contact['fname'];
+               $sale->last_name = $contact['lname'];
+               $sale->address = $contact['addr1'].($contact['addr2']!=''?', '.$contact['addr2']:'');
+               $sale->city = $contact['city'];
+               $sale->state = $contact['state'];
+               $sale->zip = $contact['zip'];
+               $sale->country = $contact['country'];
+               $sale->invoice_num = substr($payment['invoice'], -20);                                  // Only use last 20 chars
+               $sale->description = $payment['name'].' - Event Tickets';
+               $sale->email = $contact['email'];
+               $sale->email_customer = $this->account['conf'];
+               $sale->phone = $contact['phone'];
+
+               // Submit the transaction
+               $response = $sale->authorizeAndCapture();
+
+               /*
+                * Check returned status code
+                * Possible Authorize.net status codes
+                *      1 = approved
+                *      2 = declined
+                *      3 = error
+                *      4 = held for review)
+                *
+                */
+
+        // Compile text and numeric response string to use for certain types of failures
+        $respDescr = $response->response_reason_text.'  '
+            .'('.$response->response_code
+            .','.$response->response_subcode
+            .','.$response->response_reason_code
+            .')';
+
+        // Determine response method
+               switch ($response->response_code) {
+                       case 1:
+                               $resp = array(
+                    'gateway' => 'Authorize.Net',
+                    'status' => 1,
+                    'statusText' => 'Card Approved',
+                    'authCode' => $response->authorization_code,
+                    'description' => $response->response_reason_text
+                               );
+                               break;
+
+                       case 2:
+                               $resp = array(
+                    'gateway' => 'Authorize.Net',
+                    'status' => 7,
+                    'statusText' => 'Card Declined',
+                    'authCode' => '',
+                    'description' => $respDescr
+                               );
+                               break;
+
+                       case 3:
+                               $resp = array(
+                    'gateway' => 'Authorize.Net',
+                    'status' => 3,
+                    'statusText' => 'Transaction Error',
+                    'authCode' => '',
+                    'description' => $respDescr
+                               );
+                               break;
+
+                       case 4:
+                               $resp = array(
+                    'gateway' => 'Authorize.Net',
+                    'status' => 7,
+                    'statusText' => 'Held for review',
+                    'authCode' => '',
+                    'description' => $response->response_reason_text
+                           );
+                               break;
+
+                       default:
+                               $resp = array(
+                    'gateway' => 'Authorize.Net',
+                    'status' => 4,
+                    'statusText' => 'Bad Response',
+                    'authCode' => '',
+                    'description' => $respDescr
+                               );
+                               break;
+
+               }
+
+               return $resp;
+
+       }
+
+}
diff --git a/lib/paymentProcessors/MerchantSolutions/paymentGateway.php b/lib/paymentProcessors/MerchantSolutions/paymentGateway.php
new file mode 100644 (file)
index 0000000..4621c97
--- /dev/null
@@ -0,0 +1,349 @@
+<?php
+/**
+ * Event Management System
+ * Merchant Solutions PaymentGateway class
+ *
+ * @category Front-End
+ * @package  EventManagement
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: classes/paymentProcessors/MerchantSolutions.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ * @link     <>
+ */
+
+/**
+ * MerchantSolutions PaymentGateway class
+ *
+ * PHP version 5
+ *
+ * @category Event Management Admin Tickets
+ * @package  EventManagement
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: classes/paymentProcessors/MerchantSolutions.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ * @link     <>
+ */
+
+define( "MS_WSDL", "https://trans.merchantsolution.com/Web/services/TransactionService?wsdl" );
+
+/**
+ * Merchant Solutions Payment Gateway class
+ *
+ * PHP version 5
+ */
+
+class PaymentGateway
+{
+    /**
+     * Transaction Result
+     *
+     * @var    $result
+     * @access public
+     */
+    public $result = false;
+    /**
+     * Raw response data
+     *
+     * @var    $response
+     * @access public
+     */
+    public $response = false;
+    /**
+     * XML Soap Client Object
+     *
+     * @var    $client
+     * @access public
+     */
+    public $client;
+    /**
+     * Request Object
+     *
+     * @var $request
+     * @access public
+     */
+    public $request;
+
+    /**
+     * Constructor
+     *
+     * @param array $account Account information
+     *
+     * @return boolean    Returns value of $success parameter
+     * @access public
+     *
+     * $account
+        *              acctid                  MerchantSolutions account ID - Use "TEST0" for texting
+        *              merchantpin             MerchantSolutions account PIN - Login to Merchant center, then "FRISK(TM) Management" and "Configure Options"
+        *              test                    Test mode
+        *                                                      0 = Production Mode
+        *                                                      1 = Local Transaction Approval Test
+        *                                                      2 = Local Transaction Decline Test
+        *                                                      3 = On-Line Transaction Test
+        *              conf                    (not used for Merchant Solutions)
+        *              email                   Merchant E-Mail address to receive notices from Merchant Solutions for the transaction
+        *
+     * Test Merchant Account
+     *                 AcctID:                 MSDMO
+     *                 Userid:                 Cscott
+     *                 Password:               Glm3Merch#Sol
+     *                 MerchantPin:    BVR0V3462V5GmZK03MXtWE5u9HeUJX62
+        *
+     */
+    public function __construct($account)
+    {
+
+       // Setup request object
+       $this->request = (object) array(
+                       'acctid' => false,
+                       'merchantpin' => false,
+                       'amount' => false,
+                       'ccnum' => false,
+                       'expmon' => false,
+                       'expyear' => false,
+                       'ccname' => false,
+                       'cardpresent' => 0,
+                       'cardreaderpresent' => 0,
+                       'cvv2' => false,
+                       'accttype' => 1,
+                       'profileactiontype' => 2,
+                       'manualrecurring' => 0,
+                       'avs_override' => 0,
+                       'cvv2_override' => 0,
+                       'loadbalance_override' => 0,
+                       'duplicate_override' => 0,
+                       'accountlookupflag' => 0,
+                       'billaddress' => (object) array(
+                               'addr1' => '',
+                               'addr2' => '',
+                               'city' => '',
+                               'state' => '',
+                               'zip' => '',
+                               'country' => ''
+                       )
+       );
+
+       $this->account = $account;
+       $this->request->acctid = $account['acctid'];
+       $this->request->merchantpin = $account['merchantpin'];
+
+       // Test to see if soap support has been installed
+       if (!extension_loaded('soap')) {
+           trigger_error('*** PHP SOAP not installed and required by MerchantSolutions payment gateway! ***', E_USER_ERROR);
+       }
+
+        // Setup options related to doing the SOAP calls
+        ini_set('soap.wsdl_cache_enabled', 1);
+        use_soap_error_handler(false);
+        $soapOptions = array(
+            "exceptions" => 1,
+            'connection_timeout' => 10
+        );
+
+        // Setup SOAP client and get WSDL for gateway
+        try {
+
+            // XDebug prevents catching fatal errors with the Soap calls
+            if (function_exists('xdebug_disable')) {
+                xdebug_disable();
+            }
+
+            // Create new soap client instance
+            $this->client = @new SoapClient(MS_WSDL, $soapOptions);
+
+            // If XDebug was dissabled, re-enable it
+            if (function_exists('xdebug_enable')) {
+                xdebug_enable();
+            }
+
+            // Indicate setup OK
+                       return true;
+
+        } catch (SoapFault $exception) {
+
+                       return false;
+        }
+
+        return false;
+    }
+
+    /**
+     * Process a Payment
+     *
+     * @param payment Array payment information
+     * @param contact Array contact information
+     *
+     * @access public
+     * @return array
+     *
+     * Information provided
+     *
+     * $payment array
+     *         name                            Name of Venue
+     *         charge                          Total to be charged
+     *         cctype                          Card type
+     *         ccname                          Name on card
+     *         ccnumb                          Card number
+     *         ccexp                           Expiration date (m/y)
+     *         cccode                          Security code on back of card
+     *         invoice                         Invoice # is session ID (or some part thereof)
+     *
+     * $contact array
+     *         fname                           Customer first name
+     *         lname                           Customer last name
+     *         addr1                           Address Line 1
+     *         addr2                           Address Line 2
+     *         city                            City
+     *         state                           State
+     *         country                         Country
+     *         zip                                     ZIP/Postal code
+     *         phone                           Customer phone number
+     *         email                           Customer E-Mail address
+     *
+     * return array
+     *                 status                          Numeric return status code
+     *                                                                 1               Approved
+     *                                                                 2               Bad data supplied
+     *                                                                 3               Communications failure
+     *                                                                 4               Bad response
+     *                                                                 5               Transaction not valid
+     *                                                                 6               Merchant account problem
+     *                                                                 7               Card declined
+     *         statusText                      Short name of status
+     *         authCode                        Authorization code - blank if card not accepted
+     *         description                     Longer description of result
+     *
+     *
+     */
+    public function processPayment($payment = false, $contact = false)
+    {
+
+       // Set data
+       $this->request->amount = $payment['charge'];
+       $this->request->ccnum = $payment['ccnumb'];
+       $exp = explode('/', $payment['ccexp']);
+       $this->request->expmon = $exp[0];
+       $this->request->expyear = $exp[1];
+       $this->request->ccname = $payment['ccname'];
+       $this->request->cvv2 = $payment['cccode'];
+       $this->request->memo = $payment['name'].' - Event Tickets';
+       $this->request->billaddress->addr1 = $contact['addr1'];
+       $this->request->billaddress->addr2 = $contact['addr2'];
+       $this->request->billaddress->city = $contact['city'];
+       $this->request->billaddress->state = $contact['state'];
+       $this->request->billaddress->zip = $contact['zip'];
+       $this->request->billaddress->addr1 = $contact['country'];
+       $this->request->phone = $contact['phone'];
+       $this->request->email = $contact['email'];
+       $this->request->merchantordernumber = substr($payment['invoice'], -20);
+
+       // Check for local tests that don't require communication with Authorize.net
+       switch ($this->account['test']) {
+
+               // Local Test
+               case 1:
+                       // Always return a card approval
+                       $resp = array(
+                    'gateway' => 'MerchantSolutions',
+                    'status' => 1,
+                    'statusText' => 'Card Approved',
+                    'authCode' => '000000',
+                    'description' => '(TESTMODE) Local Test - Card Approved'
+                       );
+                       return $resp;
+                       break;
+
+               // Fail Test
+               case 2:
+                       $resp = array(
+                    'gateway' => 'MerchantSolutions',
+                    'status' => 7,
+                    'statusText' => 'Card Declined',
+                    'authCode' => '',
+                    'description' => '(TESTMODE) Local Test - Card Declined'
+                       );
+                       return $resp;
+                       break;
+
+               // Online Test
+               case 3:
+                       $this->request->acctid = 'TEST0';
+                       break;
+
+                       // Production Mode
+               case 0:
+                       break;
+       }
+
+
+
+        // Try to process the transaction
+        try {
+
+            // Deal with XDebug if that's enabled
+            if (function_exists('xdebug_disable')) {
+                xdebug_disable();
+            }
+
+            // Send request to Merchant Solutions
+            $this->response = $this->client->processCCSale($this->request);
+
+            // Restore XDebug if that was enabled
+            if (function_exists('xdebug_enable')) {
+                xdebug_enable();
+            }
+
+            // If approved
+            if (strtoupper($this->result) == 'APPROVED') {
+
+               $resp = array(
+                    'gateway' => 'MerchantSolutions',
+                    'status' => 1,
+                    'statusText' => 'Card Approved',
+                    'authCode' => $this->response->authcode,
+                    'description' => $this->response->status
+               );
+               return $resp;
+
+            // Must be declined
+            } else {
+
+               $x = explode(":", $this->response->result);
+                               $resp = array(
+                    'gateway' => 'MerchantSolutions',
+                    'status' => 7,
+                    'statusText' => 'Card Declined',
+                    'authCode' => '',
+                    'description' => $x[2]
+                               );
+                               return $resp;
+
+
+            }
+
+        // If there's a communications failure
+        } catch (SoapFault $exception) {
+
+                       // Return communications failure
+               $resp = array(
+                'gateway' => 'MerchantSolutions',
+                'status' => 3,
+                'statusText' => 'Transaction Error',
+                'authCode' => '',
+                'description' => 'Unable to communicate with credit card processing service.'
+                       );
+               return $resp;
+
+        }
+
+        $resp = array(
+            'gateway' => 'MerchantSolutions',
+            'status' => 4,
+            'statusText' => 'Bad Response',
+            'authCode' => '',
+            'description' => 'Received unknown response from the credit card processing service.'
+        );
+        return $resp;
+
+    }
+
+}
diff --git a/lib/paymentProcessors/PayPal/assets/x-click-but6.gif b/lib/paymentProcessors/PayPal/assets/x-click-but6.gif
new file mode 100755 (executable)
index 0000000..5da5a52
Binary files /dev/null and b/lib/paymentProcessors/PayPal/assets/x-click-but6.gif differ
diff --git a/lib/paymentProcessors/PayPal/paymentGateway.php b/lib/paymentProcessors/PayPal/paymentGateway.php
new file mode 100755 (executable)
index 0000000..73a04ad
--- /dev/null
@@ -0,0 +1,591 @@
+<?php
+/**
+ * Event Management System
+ * PayPal Payment PaymentGateway class
+ *
+ * @category Front-End
+ * @package  EventManagement
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: PayPal.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ * @link     <>
+ */
+
+
+/**
+ * Account Information
+ *
+ *  Developer account
+ *             PayPal API:     https://developer.paypal.com/webapps/developer/
+ *             E-Mail Address:         PayPal@n8dnx.org
+ *             Password:                       pAy#glM2Pal
+ *
+ *     PayPal test account
+ *             E-Mail address: paypalAcct2@n8dnx.org
+ *             Password:               {std insecure}2
+ *
+ *     Test credentials
+ *             Test account:   PayPal-facilitator@n8dnx.org
+ *             Endpoint:               api.sandbox.paypal.com
+ *             Client ID:              AY2IlhCAFCgTaYSgrGfBQ0h5WKKgpLwU-jd2QkKsEbDpGEWtCDZKtp2VLhu1
+ *             Secret:                 EOWLsBDrkvdOKUlfhAKJ47aXHBr5xzw-2o7JdLCcLVciGqNGXlhMayP1WKhe
+ *
+ *     Gaslight Media Live credentials
+ *             Endpoint:               api.paypal.com
+ *             Client ID:              AZw7VxC8rVTxlKoZVBd60ugOy_9PZWLDazQHF0RlYYWBQbAvkX2MBLy2vfmQ
+ *             Secret:                 EN3ZaxB4AhZ3J1814MtpfFjUXOqRTR8dto-fhFgk2wuLDTCoPfD0I0Dpbwuu
+ *
+ *     Standard PayPal buttons and images
+ *             https://ppmts.custhelp.com/app/answers/detail/a_id/632
+ *                             https://www.paypal.com/en_US/i/btn/x-click-but6.gif
+ */
+
+/**
+ * EventManagementPayPalPaymentProcessing class
+ *
+ * PHP version 5
+ *
+ * @category Event Management PayPal Payment Processing
+ * @package  EventManagement
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: PayPal.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ * @link     <>
+ */
+
+class PaymentGateway
+{
+       /**
+        * Curl Object
+        *
+        * @var         $curl
+        * @access      private
+        */
+       private $curl = false;
+       /**
+        * Result Status
+        *
+        * @var         $status
+        * @access      public
+        */
+       public $status = false;
+       /**
+        * Access Data
+        *
+        * @var         $access
+        * @access      private
+        */
+       public $access = false;
+       /**
+        * Curl Errors
+        *
+        * @var         $error
+        * @access      public
+        */
+       public $error = '';
+       /**
+        * PayPal Transaction
+        *
+        * @var         $trans
+        * @access      public
+        */
+       public $trans;
+       /**
+        * Test Mode - Use Sandbox
+        *
+        * @var         $sandbox
+        * @access      public
+        */
+       public $sandbox = false;
+       /**
+        * API URLs
+        *
+        * @var         $apiURLs
+        * @access      public
+        */
+       public $apiURLs = false;
+
+    /**
+     * Constructor
+     *
+     * To facilitate continuing after a return URL has been followed
+     * as required to execute or cancel the transaction, the constructor
+     * may optionally take an "access" object created in a previous
+     * instance (probably stored in a session or database) to re-establish
+     * a connection to the same transaction.
+     *
+     * @param array  $account Account information
+     * @param object $access  Access object from previous instance that should
+     *                                                   be used instead of creating a new one
+     * @param object $trans   Transaction object from a previous instance.
+     *
+     * @return boolean    Returns value of $success parameter
+     * @access public
+     *
+     * $account
+        *              clientID                PayPal Client ID
+        *              secret                  PayPal Secret
+        *              returnURL               URL for PayPal to return to after payment confirmation by customer
+        *              cancelURL               URL for PayPal to return to after payment cancelation by customer
+        *              test                    1=Local Test (not available for PayPal), 2=Fail test (not available for PayPal), 3=PayPal Sandbox test, 0=Live production
+        *
+     */
+    public function __construct($account, $access = false, $trans = false)
+    {
+
+               // URLs to use for requests if we're using the development sandbox
+       $sandboxURLs = (object) array(
+                       'access' => 'https://api.sandbox.paypal.com/v1/oauth2/token',
+                       'process' => 'https://api.sandbox.paypal.com/v1/payments/payment',
+                       'execute' => 'https://api.sandbox.paypal.com/v1/payments/payment/{transID}/execute/'
+       );
+
+       // URLs to use for requests if we're doing live transactions
+       $liveURLs = (object) array(
+                       'access' => 'https://api.paypal.com/v1/oauth2/token',
+                       'process' => 'https://api.paypal.com/v1/payments/payment',
+                       'execute' => 'https://api.paypal.com/v1/payments/payment/{transID}/execute/'
+       );
+
+
+       // Save account information
+       $this->account = $account;
+
+       // Check for various test modes
+       switch ($this->account['test']) {
+
+               // Local Test
+               case 1:
+                               break;
+
+                       // Fail Test
+               case 2:
+                               break;
+
+               // Online Test - Use sandbox
+               case 3:
+                       $this->sandbox = true;
+                       $this->apiURLs = $sandboxURLs;
+                       break;
+
+                       // Production Mode
+               case 0:
+                       $this->sandbox = false;
+                       $this->apiURLs = $liveURLs;
+                       break;
+       }
+
+       // Was an access object from a previous instance supplied?
+       if ($access) {
+
+               // Yes, so store that and be done
+               $this->access = $access;
+               $this->status = true;
+
+               // If we also have a transaction object
+               if ($trans) {
+
+                       // Store that
+                       $this->trans = $trans;
+               }
+
+               if (defined('PAYPAL_DEBUG') && PAYPAL_DEBUG) {
+                       echo
+                               '<b>__construct() - Existing Instance</b><p>'
+                               .'Account Data:<br>'
+                               .'<pre>'.print_r($account,1).'</pre>'
+                               .'Access:<br>'
+                               .'<pre>'.print_r($access,1)."</pre>"
+                               .'Transaction:<br>'
+                               .'<pre>'.print_r($trans,1)."</pre>";
+               }
+
+
+       // Otherwise, we need to create an access object
+       } else {
+
+               // Build request information
+               $url = $this->apiURLs->access;
+               $headers = array(
+                               "Accept: application/json",
+                               "Accept-Language: en_US",
+                               "Content-type: application/x-www-form-urlencoded"
+               );
+               $request = 'grant_type=client_credentials';
+
+               if (defined('PAYPAL_DEBUG') && PAYPAL_DEBUG) {
+                       echo
+                               '<b>__construct() - New Instance</b><p>'
+                               .'Account Data:<br>'
+                               .'<pre>'.print_r($account,1).'</pre>'
+                               .'Headers:<br>'
+                               .'<pre>'.print_r($headers,1)."</pre>"
+                               .'Request:<br>'
+                               .'<pre>'.print_r($request,1)."</pre>";
+               }
+
+                       // Send request
+               $response = $this->sendRequest($url, $headers, $request);
+
+               // If bad response
+               if (!$response) {
+                       $this->access = false;
+                       $this->status = false;
+                       return;
+               }
+
+               // Store our access data
+               $this->access = $response;
+               $this->status = true;
+
+       }
+
+       return $this->status;
+    }
+
+    /**
+     * Process a Payment
+     *
+     * NOTE: For PayPal, this method only requests the payment.
+     * The user must follow the approval_url supplied by this
+     * method and confirm the payment. When that is done, PayPal
+     * will send the user to the approval_url along with a
+     * PayerID. The executePayment() method must then be called
+     * to actually execute the payment.
+     *
+     * @param array $payment Array payment information
+     * @param array $contact Array contact information
+     *
+     * @access public
+     * @return array
+     *
+     * Information provided
+     *
+     * $payment array
+     *         name                            Name of vendor - required
+     *         charge                          Total to be charged - required
+     *         cctype                          Card type - not used
+     *         ccname                          Name on card - not used
+     *         ccnumb                          Card number - not used
+     *         ccexp                           Expiration date (m/y) - not used
+     *         cccode                          Security code on back of card - not used
+     *         invoice                         Invoice # is session ID (or some part thereof) - not used
+     *         description                     Description of transaction - not used
+     *         items                           Array of items being purchased - required
+     *                                                 Each item has following
+     *
+     *                 quantity                        A number - Required
+     *                 name                            Name of the item - Required
+     *                 price                           Price of the item (numeric float) - Required
+     *                 sku                                     SKU string - Optional
+     *
+     *
+     * $contact array
+     *         fname                           Customer first name
+     *         lname                           Customer last name
+     *         addr1                           Address Line 1
+     *         addr2                           Address Line 2
+     *         city                            City
+     *         state                           State
+     *         country                         Country
+     *         zip                                     ZIP/Postal code
+     *         phone                           Customer phone number
+     *         email                           Customer E-Mail address
+     *
+     * return array
+     *                 status                          Numeric return status code
+     *                                                                 1               Approved
+     *                                                                 2               Bad data supplied
+     *                                                                 3               Communications failure
+     *                                                                 4               Bad response
+     *                                                                 5               Transaction not valid
+     *                                                                 6               Merchant account problem
+     *                                                                 7               Card declined
+     *         statusText                      Short name of status
+     *         authCode                        Authorization code - blank if card not accepted
+     *         description                     Longer description of result
+     *
+     *
+     */
+    public function processPayment($payment = false, $contact = false)
+    {
+
+       // Check for local tests that don't require communication with PayPal
+       switch ($this->account['test']) {
+
+               // Local Test
+               case 1:
+                       // invalid type for PayPal class - default to sandbox
+               case 2:
+                       // invalid type for PayPal class - default to sandbox
+               case 3:
+                       $this->sandbox = true;
+                       break;
+
+                       // Production Mode
+               case 0:
+                       break;
+       }
+
+       // Build request information
+       $url = $this->apiURLs->process;
+       $headers = array(
+                       "Content-type:application/json",
+                       'Authorization:'.$this->access->token_type.' '.$this->access->access_token
+       );
+
+       // Build payment request
+       $charge =  number_format($payment['charge'], 2, '.', '');
+       $requestArray = array(
+               'intent' => 'sale',
+               'redirect_urls' => array(
+                       'return_url' => $this->account['returnURL'],
+                       'cancel_url' => $this->account['cancelURL']
+               ),
+               'payer' => array(
+                       'payment_method' => 'paypal'
+               ),
+               'transactions' => array(
+                       0 => array(
+                               'amount' => array(
+                               'total' => $charge,
+                               'currency' => 'USD'
+                               ),
+                               'item_list' => array(
+                                       'items' => array(
+                                       )
+                               )
+                       )
+               )
+       );
+
+       // Add item list
+       if (isset($payment['items']) && count($payment['items']) > 0) {
+
+               foreach ($payment['items'] as $item) {
+
+                       $item['name'] = trim($item['name']);
+                       $item['currency'] = 'USD';
+                       $item['price'] = number_format($item['price'], 2, '.', '');
+
+                       // Check required items
+                       if (
+                               ($item['quantity']-0) <= 0 ||
+                               $item['name'] == '' ||
+                               ($item['price']-0) <= 0
+                       ) {
+
+                               if (defined('PAYPAL_DEBUG') && PAYPAL_DEBUG) {
+                                       echo "<P>ERROR: payment item incomplete<br><pre>".print_r($item,1)."</pre>";
+                               }
+
+                               // Can't proceed, bad data supplied - May need to warn someone of this problem here
+                               $this->trans = false;
+                               $this->status = false;
+                               return;
+
+                       }
+
+                       // Add this item to the list
+                       $requestArray['transactions'][0]['item_list']['items'][] = $item;
+
+               }
+
+       // If not, then we can't proceed - While not required by PayPal, we are requiring it
+       } else {
+
+               echo "ERROR: PayPal integration requires an item list but none was provided along with "
+                               ."the payment information to the processPayment() method.";
+               exit;
+
+       }
+
+       // Convert request to a JSON
+       $request = json_encode($requestArray, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
+
+       if (defined('PAYPAL_DEBUG') && PAYPAL_DEBUG) {
+               echo '<b>processPayment()</b><P>'
+                       .'Headers:<br>'
+                       .'<pre>'.print_r($headers,1)."</pre>"
+                       .'Request: <br>'
+                       .'<pre>'.$request.'</pre>';
+       }
+
+       // Send request
+       $response = $this->sendRequest($url, $headers, $request);
+
+       // If bad response
+       if (!$response) {
+               $this->trans = false;
+               $this->status = false;
+               return;
+       }
+
+       // Store URLs in a way they can be easily accessed
+       $response->urls = new stdClass();
+       foreach ($response->links as $link) {
+                       $response->urls->{$link->rel} = $link;
+       }
+
+               // Store our access data
+       $this->trans = $response;
+               $this->status = true;
+
+
+               return $this->status;
+
+
+    }
+
+    /**
+     * Execute the Payment
+     *
+     * This is the final step in PayPal payment approval.
+     * This method should be called with the PayerID provided
+     * when the user is sent back to us on a return URL.
+     *
+     * Note for this to work, the constructor must have been
+     * suppled the access and transaction data.
+     *
+     * Since the transaction ID is passed to PayPal in the URL
+     * we're assuming that the response we get back is for the
+     * correct transaction, so we don't check that.
+     *
+     * @param string $payerID  PayerID returned by PayPal on the return link
+     *
+     * @access public
+     * @return array
+     *
+     *
+     */
+    public function executePayment($payerID)
+    {
+
+       // Build request information
+       $url = str_replace('{transID}', $this->trans->id, $this->apiURLs->execute);
+
+       $headers = array(
+                       "Content-type:application/json",
+                       'Authorization:'.$this->access->token_type.' '.$this->access->access_token
+       );
+
+       // Build payment request
+       $charge =  number_format($payment['charge'], 2, '.', '');
+       $request = '{"payer_id" : "'.$payerID.'" }';
+
+       if (defined('PAYPAL_DEBUG') && PAYPAL_DEBUG) {
+               echo '<b>executePayment()</b><P>'
+                       .'Headers:<br>'
+                       .'<pre>'.print_r($headers,1)."</pre>"
+                       .'Request: <br>'
+                       .'<pre>'.$request.'</pre>';
+       }
+
+       // Send request
+       $response = $this->sendRequest($url, $headers, $request);
+
+       // If bad response
+       if (!$response) {
+               $this->confirmation = false;
+               $this->status = false;
+               return false;
+       }
+
+       // Save results
+       $this->confirmation = $response;
+
+               // Check if payment not approved
+               if ($response->state != 'approved') {
+                       $this->status = false;
+                       return false;
+               }
+
+               $r = array(
+                       'status' => 1,
+                       'statusText' => 'Approved',
+                       'authCode' => '',
+                       'description' => 'PayPal approval: '
+                               .$this->response->payer->payer_info->first_name.' '
+                               .$this->response->payer->payer_info->last_name.' '
+                               .$this->response->update_time,
+                       'payerName' => $this->response->payer->payer_info->first_name.' '
+                               .$this->response->payer->payer_info->last_name.' '
+
+               );
+
+       return $r;
+    }
+
+    /**
+     * Make Curl call to place request
+     *
+     * @param array $headers  Array of headers to include
+     * @param mixed $request  Fields to supply as POST data, either string, array, or json
+     *
+     * @access public
+     * @return array
+     *
+     */
+    private function sendRequest($url, $headers, $request)
+    {
+
+       if (defined('PAYPAL_DEBUG') && PAYPAL_DEBUG) {
+               echo '<p><b>sendRequest():</b><br>URL = '.$url.'<br>Headers:<br><pre>'
+                       .print_r($headers,1).'</pre>Request:<br><pre>'.print_r($request,1).'</pre>';
+       }
+
+       // Init Curl
+       $this->curl = curl_init();
+
+       // Curl Parameters
+       $id_pw = $this->account['clientID'].':'.$this->account['secret'];
+       $agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
+
+       // Set curl options
+       curl_setopt($this->curl, CURLOPT_URL, $url);
+       curl_setopt($this->curl, CURLOPT_SSLVERSION,4);
+       curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, FALSE);
+       curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, 2);
+       curl_setopt($this->curl, CURLOPT_HEADER, false);
+       curl_setopt($this->curl, CURLOPT_HTTPHEADER, $headers);
+       curl_setopt($this->curl, CURLOPT_POST, true);
+       curl_setopt($this->curl, CURLOPT_POSTFIELDS, $request);
+       curl_setopt($this->curl, CURLOPT_USERPWD, $id_pw);
+       curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
+       curl_setopt($this->curl, CURLOPT_USERAGENT, $agent);
+
+       // Place Curl call to get access token
+       $raw = curl_exec($this->curl);
+
+       // If we received a good response
+       if (!curl_errno($this->curl)) {
+
+               // Save access data
+               $response = json_decode($raw);
+
+               if (defined('PAYPAL_DEBUG') && PAYPAL_DEBUG) {
+                       echo 'Response:<br>'
+                               .'<pre>'.print_r($response,1).'</pre>';
+               }
+
+       // Otherwise
+       } else {
+
+               // Save our error message
+               $this->error = curl_error($this->curl);
+                       $response = false;
+
+                       if (defined('PAYPAL_DEBUG') && PAYPAL_DEBUG) {
+                               echo "Curl Error: ".$this->error."<P>";
+                       }
+
+       }
+
+       // Close our curl object
+       curl_close($this->curl);
+
+       return $response;
+
+    }
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/.coveralls.yml b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/.coveralls.yml
new file mode 100644 (file)
index 0000000..90f55b5
--- /dev/null
@@ -0,0 +1,6 @@
+# .coveralls.yml configuration
+
+# for php-coveralls
+src_dir: lib
+coverage_clover: build/coverage/clover.xml
+json_path: build/coverage/coveralls-upload.json
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/.gitignore b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/.gitignore
new file mode 100644 (file)
index 0000000..e9c37ab
--- /dev/null
@@ -0,0 +1,14 @@
+
+build
+.DS_Store
+*.log
+
+# IDE
+.project
+.settings
+.buildpath
+*.bak
+
+# Composer
+vendor
+composer.lock
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/.travis.yml b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/.travis.yml
new file mode 100644 (file)
index 0000000..91cb229
--- /dev/null
@@ -0,0 +1,15 @@
+language: php
+php:
+  - 5.4
+  - 5.3
+before_script:
+  - composer install --dev
+  - composer update satooshi/php-coveralls --dev
+script:
+    - ant coverage
+after_script:
+    - php vendor/bin/coveralls -v -c .coveralls.yml
+notifications:
+  recipients:
+    - DL-PP-Platform-PHP-SDK@ebay.com
+  on_success: change
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/CHANGELOG.md b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/CHANGELOG.md
new file mode 100644 (file)
index 0000000..83c6852
--- /dev/null
@@ -0,0 +1,24 @@
+CHANGELOG
+========= 
+
+V0.7.1 (July 31, 2013)
+-----------------------
+   * Added support for Reauthorization
+
+V0.7.0 (May 30, 2013)
+-----------------------
+
+   * Added support for Auth and Capture APIs
+   * Types modified to match the API Spec
+   * Updated SDK to use namespace supported core library 
+
+V0.6.0 (April 26, 2013)
+-----------------------
+
+   * Adding support for dynamic configuration of SDK (Upgrading sdk-core-php dependency to V1.4.0)
+   * Deprecating the setCredential method and changing resource class methods to take an ApiContext argument instead of a OauthTokenCredential argument.
+
+V0.5.0 (March 07, 2013)
+-----------------------
+
+   * Initial Release
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/LICENSE.txt b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/LICENSE.txt
new file mode 100644 (file)
index 0000000..ad030e5
--- /dev/null
@@ -0,0 +1,41 @@
+PAYPAL, INC.
+
+SDK LICENSE
+
+NOTICE TO USER:  PayPal, Inc. is providing the Software and Documentation for use under the terms of this Agreement.  Any use, reproduction, modification or distribution of the Software or Documentation, or any derivatives or portions hereof, constitutes your acceptance of this Agreement.
+
+As used in this Agreement, "PayPal" means PayPal, Inc.  "Software" means the software code accompanying this agreement.   "Documentation" means the documents, specifications and all other items accompanying this Agreement other than the Software.   
+
+1.  LICENSE GRANT Subject to the terms of this Agreement, PayPal hereby grants you a non-exclusive, worldwide, royalty free license to use, reproduce, prepare derivative works from, publicly display, publicly perform, distribute and sublicense the Software for any purpose, provided the copyright notice below appears in a conspicuous location within the source code of the distributed Software and this license is distributed in the supporting documentation of the Software you distribute. Furthermore, you must comply with all third party licenses in order to use the third party software contained in the Software.
+
+Subject to the terms of this Agreement, PayPal hereby grants you a non-exclusive, worldwide, royalty free license to use, reproduce, publicly display, publicly perform, distribute and sublicense the Documentation for any purpose.  You may not modify the Documentation.
+
+No title to the intellectual property in the Software or Documentation is transferred to you under the terms of this Agreement.  You do not acquire any rights to the Software or the Documentation except as expressly set forth in this Agreement.
+
+If you choose to distribute the Software in a commercial product, you do so with the understanding that you agree to defend, indemnify and hold harmless PayPal and its suppliers against any losses, damages and costs arising from the claims, lawsuits or other legal actions arising out of such distribution.  You may distribute the Software in object code form under your own license, provided that your license agreement:
+
+(a)    complies with the terms and conditions of this license agreement; 
+
+(b)    effectively disclaims all warranties and conditions, express or implied, on behalf of PayPal;
+
+(c)    effectively excludes all liability for damages on behalf of PayPal;
+
+(d)    states that any provisions that differ from this Agreement are offered by you alone and not PayPal; and
+
+(e)    states that the Software is available from you or PayPal and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.  
+
+2.  DISCLAIMER OF WARRANTY
+PAYPAL LICENSES THE SOFTWARE AND DOCUMENTATION TO YOU ONLY ON AN "AS IS" BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  PAYPAL MAKES NO WARRANTY THAT THE SOFTWARE OR DOCUMENTATION WILL BE ERROR-FREE.  Each user of the Software or Documentation is solely responsible for determining the appropriateness of using and distributing the Software and Documentation and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs, or equipment, and unavailability or interruption of operations.  Use of the Software and Documentation is made with the understanding that PayPal will not provide you with any technical or customer support or maintenance.  Some states or jurisdictions do not allow the exclusion of implied warranties or limitations on how long an implied warranty may last, so the above limitations may not apply to you.  To the extent permissible, any implied warranties are limited to ninety (90) days.
+
+
+3.  LIMITATION OF LIABILITY
+PAYPAL AND ITS SUPPLIERS SHALL NOT BE LIABLE FOR LOSS OR DAMAGE ARISING OUT OF THIS AGREEMENT OR FROM THE USE OF THE SOFTWARE OR DOCUMENTATION.  IN NO EVENT WILL PAYPAL OR ITS SUPPLIERS BE LIABLE TO YOU OR ANY THIRD PARTY FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, INCIDENTAL, OR SPECIAL DAMAGES INCLUDING LOST PROFITS, LOST SAVINGS, COSTS, FEES, OR EXPENSES OF ANY KIND ARISING OUT OF ANY PROVISION OF THIS AGREEMENT OR THE USE OR THE INABILITY TO USE THE SOFTWARE OR DOCUMENTATION, HOWEVER CAUSED AND UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.  PAYPAL'S AGGREGATE LIABILITY AND THAT OF ITS SUPPLIERS UNDER OR IN CONNECTION WITH THIS AGREEMENT SHALL BE LIMITED TO THE AMOUNT PAID BY YOU FOR THE SOFTWARE AND DOCUMENTATION. 
+
+4.  TRADEMARK USAGE
+PayPal is a trademark PayPal, Inc. in the United States and other countries.  Such trademarks may not be used to endorse or promote any product unless expressly permitted under separate agreement with PayPal.  
+
+5.  TERM
+Your rights under this Agreement shall terminate if you fail to comply with any of the material  terms or conditions of this Agreement and do not cure such failure in a reasonable period of time after becoming aware of such noncompliance.  If all your rights under this Agreement terminate, you agree to cease use and distribution of the Software and Documentation as soon as reasonably practicable. 
+
+6. GOVERNING LAW AND JURISDICTION. This Agreement is governed by the statutes and laws of the State of California, without regard to the conflicts of law principles thereof.  If any part of this Agreement is found void and unenforceable, it will not affect the validity of the balance of the Agreement, which shall remain valid and enforceable according to its terms.  Any dispute arising out of or related to this Agreement shall be brought in the courts of Santa Clara County, California, USA. 
+
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/README.md b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/README.md
new file mode 100644 (file)
index 0000000..2dcdc6d
--- /dev/null
@@ -0,0 +1,68 @@
+REST API SDK for PHP
+====================
+[![Build Status](https://travis-ci.org/paypal/rest-api-sdk-php.png?branch=master)](https://travis-ci.org/paypal/rest-api-sdk-php) [![Coverage Status](https://coveralls.io/repos/paypal/rest-api-sdk-php/badge.png?branch=master)](https://coveralls.io/r/paypal/rest-api-sdk-php?branch=master) [![Latest Stable Version](https://poser.pugx.org/paypal/rest-api-sdk-php/v/stable.png)](https://packagist.org/packages/paypal/rest-api-sdk-php) [![Total Downloads](https://poser.pugx.org/paypal/rest-api-sdk-php/downloads.png)](https://packagist.org/packages/paypal/rest-api-sdk-php)
+
+This repository contains PayPal's PHP SDK and samples for REST API.
+
+
+Prerequisites
+-------------
+
+   * PHP 5.3 or above
+   * curl, json & openssl extensions must be enabled
+   * composer for running the sample out of the box (See http://getcomposer.org)
+
+
+Running the sample
+------------------
+
+   * Ensure that you have composer installed on your machine.
+   * Navigate to the samples folder and run 'composer update'.
+   * Optionally, update the bootstrap.php file with your own client Id and client secret.
+   * Run any of the samples in the 'samples' folder to see what the APIs can do.
+    
+    
+Usage
+-----
+
+To write an app that uses the SDK 
+
+   * Copy the composer.json file from the sample folder over to your project and run 'composer update' to fetch all 
+dependencies
+   * Copy the sample configuration file sdk_config.ini to a location of your choice and let the SDK know your config path using the following define directive
+    
+```php
+    define('PP_CONFIG_PATH', /path/to/your/sdk_config.ini);
+```
+    
+   * Obtain your clientId and client secret from the developer portal. You will use them to create a `OAuthTokenCredential` object.
+   * Now you are all set to make your first API call. Create a resource object as per your need and call the relevant operation or invoke one of the static methods on your resource class.
+    
+```php
+
+    $apiContext = new ApiContext(new OAuthTokenCredential('<clientId>', '<clientSecret'));
+               
+    $payment = new Payment();
+
+    $payment->setIntent("Sale");
+
+    ...
+
+    $payment->create($apiContext);
+
+      *OR*
+
+    $payment = Payment::get('payment_id', $apiContext);
+```
+
+These examples pick the SDK configuration from the sdk_config.ini file. If you do not want to use an ini file or want to pick your configuration dynamically, you can use the `$apiContext->setConfig()` method to pass in the configuration.
+       
+
+Contributing
+------------
+
+More help
+---------
+
+   * [API Reference](https://developer.paypal.com/webapps/developer/docs/api/)
+   * [Reporting issues / feature requests] (https://github.com/paypal/rest-api-sdk-php/issues)
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/build.xml b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/build.xml
new file mode 100644 (file)
index 0000000..d4e2ad4
--- /dev/null
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="paypal-rest-sdk-php" basedir="." default="all">
+
+       <property name="basedir" value="." />
+       <property name="release.dir" value="${basedir}/release" />
+       <property name="output.dir" value="${basedir}/build" />
+       <property name="phplint.out" value="${output.dir}/phplint.txt" />
+       <property name="phploc.out" value="${output.dir}/phploc.xml" />
+       <property name="coverage.dir" value="${output.dir}/coverage" />
+       <property name="coverage.out" value="${coverage.dir}/junit.xml" />
+       <property name="clover.out" value="${coverage.dir}/clover.xml" />
+       <property name="test.dir" value="${output.dir}/test" />
+       
+       <fileset id="src.files" dir="${basedir}/lib" includes="**/*.php" />
+               
+       <target name="composer-init" description="Downloads composer.phar if not available locally">
+               <if>
+                       <available file="composer.phar" />
+                       <then>
+                               <echo>Composer is installed</echo>
+                       </then>
+                       <else>
+                               <echo message="Installing composer" />
+                               <exec command="curl -s http://getcomposer.org/installer | php"  />
+                               <exec command="php composer.phar install --dev"  />
+                       </else>
+               </if>
+       </target>
+
+       <target name="phplint">         
+               <delete file="${phplint.out}"/>
+               <apply executable="php" failonerror="true" output="${phplint.out}" append="true">
+                       <arg value="-l" />
+                       <fileset refid="src.files" />
+               </apply>
+       </target>
+
+       <target name="phploc">
+               <exec command="phploc --log-xml ${phploc.out} ." dir="${basedir}/lib"  />
+       </target>
+
+       <target name="coverage">
+               <mkdir dir="${output.dir}/coverage"/>
+               <exec command="phpunit --coverage-html=${coverage.dir} --coverage-clover=${clover.out} --log-junit=${coverage.out} --exclude-group=PayPal\\Api\\*" />
+       </target>
+
+       <target name="clean" description="Deletes build artifacts">
+               <delete dir="${output.dir}"/>
+               <mkdir dir="${output.dir}"/>
+       </target>
+       
+       <target name="test" description="Runs test cases">
+               <exec command="phpunit --testdox-html=${test.dir}/testdox.html --log-junit=${test.dir}/junit.xml"/>
+       </target>
+
+       <!-- Requires phing --> 
+       <target name="convert-test-report" >
+               <mkdir dir="build/test/report"/>
+               <phpunitreport infile="${coverage.out}" 
+                       format="frames" 
+                       todir="build/test/report" />
+       </target>
+       
+       <target name="build" depends="test" description="Builds SDK" />
+       <target name="report" depends="phplint, coverage, phploc" description="Runs code checks and coverage reports" />
+       <target name="all" depends="clean, test, build, report" description="Do everything" />
+</project>
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/composer.json b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/composer.json
new file mode 100644 (file)
index 0000000..bed31d1
--- /dev/null
@@ -0,0 +1,29 @@
+{
+    "name": "paypal/rest-api-sdk-php",
+    "description": "PayPal's PHP SDK for REST APIs",
+    "keywords": ["paypal", "payments", "rest", "sdk"],
+    "type": "library",
+    "license": "Apache2",
+    "homepage": "https://github.com/paypal/rest-api-sdk-php",
+    "authors": [
+        {
+            "name": "PayPal",
+            "homepage": "https://github.com/paypal/rest-api-sdk-php/contributors"
+        }
+    ],
+    "require": {
+        "php": ">=5.3.0",
+        "ext-curl": "*",
+        "ext-json": "*",
+        "paypal/sdk-core-php": "2.4.*"
+    },
+    "require-dev": {
+        "phpunit/phpunit": "3.7.*",
+        "satooshi/php-coveralls": "dev-master"
+    },
+    "autoload": {
+        "psr-0": {
+            "PayPal": "lib/"
+        }
+    }    
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Address.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Address.php
new file mode 100644 (file)
index 0000000..fa9300e
--- /dev/null
@@ -0,0 +1,167 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+
+class Address extends PPModel {
+       /**
+        * Line 1 of the Address (eg. number, street, etc).
+        * @param string $line1
+        */
+       public function setLine1($line1) {
+               $this->line1 = $line1;
+               return $this;
+       }
+
+       /**
+        * Line 1 of the Address (eg. number, street, etc).
+        * @return string
+        */
+       public function getLine1() {
+               return $this->line1;
+       }
+
+
+       /**
+        * Optional line 2 of the Address (eg. suite, apt #, etc.).
+        * @param string $line2
+        */
+       public function setLine2($line2) {
+               $this->line2 = $line2;
+               return $this;
+       }
+
+       /**
+        * Optional line 2 of the Address (eg. suite, apt #, etc.).
+        * @return string
+        */
+       public function getLine2() {
+               return $this->line2;
+       }
+
+
+       /**
+        * City name.
+        * @param string $city
+        */
+       public function setCity($city) {
+               $this->city = $city;
+               return $this;
+       }
+
+       /**
+        * City name.
+        * @return string
+        */
+       public function getCity() {
+               return $this->city;
+       }
+
+
+       /**
+        * 2 letter country code.
+        * @param string $country_code
+        */
+       public function setCountryCode($country_code) {
+               $this->country_code = $country_code;
+               return $this;
+       }
+
+       /**
+        * 2 letter country code.
+        * @return string
+        */
+       public function getCountryCode() {
+               return $this->country_code;
+       }
+
+       /**
+        * 2 letter country code.
+        * @param string $country_code
+        * @deprecated. Instead use setCountryCode
+        */
+       public function setCountry_code($country_code) {
+               $this->country_code = $country_code;
+               return $this;
+       }
+       /**
+        * 2 letter country code.
+        * @return string
+        * @deprecated. Instead use getCountryCode
+        */
+       public function getCountry_code() {
+               return $this->country_code;
+       }
+
+       /**
+        * Zip code or equivalent is usually required for countries that have them. For list of countries that do not have postal codes please refer to http://en.wikipedia.org/wiki/Postal_code.
+        * @param string $postal_code
+        */
+       public function setPostalCode($postal_code) {
+               $this->postal_code = $postal_code;
+               return $this;
+       }
+
+       /**
+        * Zip code or equivalent is usually required for countries that have them. For list of countries that do not have postal codes please refer to http://en.wikipedia.org/wiki/Postal_code.
+        * @return string
+        */
+       public function getPostalCode() {
+               return $this->postal_code;
+       }
+
+       /**
+        * Zip code or equivalent is usually required for countries that have them. For list of countries that do not have postal codes please refer to http://en.wikipedia.org/wiki/Postal_code.
+        * @param string $postal_code
+        * @deprecated. Instead use setPostalCode
+        */
+       public function setPostal_code($postal_code) {
+               $this->postal_code = $postal_code;
+               return $this;
+       }
+       /**
+        * Zip code or equivalent is usually required for countries that have them. For list of countries that do not have postal codes please refer to http://en.wikipedia.org/wiki/Postal_code.
+        * @return string
+        * @deprecated. Instead use getPostalCode
+        */
+       public function getPostal_code() {
+               return $this->postal_code;
+       }
+
+       /**
+        * 2 letter code for US states, and the equivalent for other countries.
+        * @param string $state
+        */
+       public function setState($state) {
+               $this->state = $state;
+               return $this;
+       }
+
+       /**
+        * 2 letter code for US states, and the equivalent for other countries.
+        * @return string
+        */
+       public function getState() {
+               return $this->state;
+       }
+
+
+       /**
+        * Phone number in E.123 format.
+        * @param string $phone
+        */
+       public function setPhone($phone) {
+               $this->phone = $phone;
+               return $this;
+       }
+
+       /**
+        * Phone number in E.123 format.
+        * @return string
+        */
+       public function getPhone() {
+               return $this->phone;
+       }
+
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Amount.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Amount.php
new file mode 100644 (file)
index 0000000..8c7cfe2
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+
+class Amount extends PPModel {
+       /**
+        * 3 letter currency code
+        * @param string $currency
+        */
+       public function setCurrency($currency) {
+               $this->currency = $currency;
+               return $this;
+       }
+
+       /**
+        * 3 letter currency code
+        * @return string
+        */
+       public function getCurrency() {
+               return $this->currency;
+       }
+
+
+       /**
+        * Total amount charged from the Payer account (or card) to Payee. In case of a refund, this is the refunded amount to the original Payer from Payee account.
+        * @param string $total
+        */
+       public function setTotal($total) {
+               $this->total = $total;
+               return $this;
+       }
+
+       /**
+        * Total amount charged from the Payer account (or card) to Payee. In case of a refund, this is the refunded amount to the original Payer from Payee account.
+        * @return string
+        */
+       public function getTotal() {
+               return $this->total;
+       }
+
+
+       /**
+        * Additional details of the payment amount.
+        * @param PayPal\Api\Details $details
+        */
+       public function setDetails($details) {
+               $this->details = $details;
+               return $this;
+       }
+
+       /**
+        * Additional details of the payment amount.
+        * @return PayPal\Api\Details
+        */
+       public function getDetails() {
+               return $this->details;
+       }
+
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Authorization.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Authorization.php
new file mode 100644 (file)
index 0000000..9fc4b6d
--- /dev/null
@@ -0,0 +1,299 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+use PayPal\Rest\IResource;
+use PayPal\Rest\Call;
+use PayPal\Rest\ApiContext;
+use PayPal\Api\Authorization;
+use PayPal\Api\Capture;
+use PayPal\Transport\PPRestCall;
+
+class Authorization extends PPModel implements IResource {
+
+       private static $credential;
+
+       /**
+        *
+        * @deprecated. Pass ApiContext to create/get methods instead
+        */
+       public static function setCredential($credential) {
+               self::$credential = $credential;
+       }
+
+       /**
+        * Identifier of the authorization transaction.
+        * @param string $id
+        */
+       public function setId($id) {
+               $this->id = $id;
+               return $this;
+       }
+
+       /**
+        * Identifier of the authorization transaction.
+        * @return string
+        */
+       public function getId() {
+               return $this->id;
+       }
+
+
+       /**
+        * Time the resource was created.
+        * @param string $create_time
+        */
+       public function setCreateTime($create_time) {
+               $this->create_time = $create_time;
+               return $this;
+       }
+
+       /**
+        * Time the resource was created.
+        * @return string
+        */
+       public function getCreateTime() {
+               return $this->create_time;
+       }
+
+       /**
+        * Time the resource was created.
+        * @param string $create_time
+        * @deprecated. Instead use setCreateTime
+        */
+       public function setCreate_time($create_time) {
+               $this->create_time = $create_time;
+               return $this;
+       }
+       /**
+        * Time the resource was created.
+        * @return string
+        * @deprecated. Instead use getCreateTime
+        */
+       public function getCreate_time() {
+               return $this->create_time;
+       }
+
+       /**
+        * Time the resource was last updated.
+        * @param string $update_time
+        */
+       public function setUpdateTime($update_time) {
+               $this->update_time = $update_time;
+               return $this;
+       }
+
+       /**
+        * Time the resource was last updated.
+        * @return string
+        */
+       public function getUpdateTime() {
+               return $this->update_time;
+       }
+
+       /**
+        * Time the resource was last updated.
+        * @param string $update_time
+        * @deprecated. Instead use setUpdateTime
+        */
+       public function setUpdate_time($update_time) {
+               $this->update_time = $update_time;
+               return $this;
+       }
+       /**
+        * Time the resource was last updated.
+        * @return string
+        * @deprecated. Instead use getUpdateTime
+        */
+       public function getUpdate_time() {
+               return $this->update_time;
+       }
+
+       /**
+        * Amount being authorized for.
+        * @param PayPal\Api\Amount $amount
+        */
+       public function setAmount($amount) {
+               $this->amount = $amount;
+               return $this;
+       }
+
+       /**
+        * Amount being authorized for.
+        * @return PayPal\Api\Amount
+        */
+       public function getAmount() {
+               return $this->amount;
+       }
+
+
+       /**
+        * State of the authorization transaction.
+        * @param string $state
+        */
+       public function setState($state) {
+               $this->state = $state;
+               return $this;
+       }
+
+       /**
+        * State of the authorization transaction.
+        * @return string
+        */
+       public function getState() {
+               return $this->state;
+       }
+
+
+       /**
+        * ID of the Payment resource that this transaction is based on.
+        * @param string $parent_payment
+        */
+       public function setParentPayment($parent_payment) {
+               $this->parent_payment = $parent_payment;
+               return $this;
+       }
+
+       /**
+        * ID of the Payment resource that this transaction is based on.
+        * @return string
+        */
+       public function getParentPayment() {
+               return $this->parent_payment;
+       }
+
+       /**
+        * ID of the Payment resource that this transaction is based on.
+        * @param string $parent_payment
+        * @deprecated. Instead use setParentPayment
+        */
+       public function setParent_payment($parent_payment) {
+               $this->parent_payment = $parent_payment;
+               return $this;
+       }
+       /**
+        * ID of the Payment resource that this transaction is based on.
+        * @return string
+        * @deprecated. Instead use getParentPayment
+        */
+       public function getParent_payment() {
+               return $this->parent_payment;
+       }
+
+       /**
+        * Date/Time until which funds may be captured against this resource.
+        * @param string $valid_until
+        */
+       public function setValidUntil($valid_until) {
+               $this->valid_until = $valid_until;
+               return $this;
+       }
+
+       /**
+        * Date/Time until which funds may be captured against this resource.
+        * @return string
+        */
+       public function getValidUntil() {
+               return $this->valid_until;
+       }
+
+       /**
+        * Date/Time until which funds may be captured against this resource.
+        * @param string $valid_until
+        * @deprecated. Instead use setValidUntil
+        */
+       public function setValid_until($valid_until) {
+               $this->valid_until = $valid_until;
+               return $this;
+       }
+       /**
+        * Date/Time until which funds may be captured against this resource.
+        * @return string
+        * @deprecated. Instead use getValidUntil
+        */
+       public function getValid_until() {
+               return $this->valid_until;
+       }
+
+       /**
+        * 
+        * @array
+        * @param PayPal\Api\Links $links
+        */
+       public function setLinks($links) {
+               $this->links = $links;
+               return $this;
+       }
+
+       /**
+        * 
+        * @return PayPal\Api\Links
+        */
+       public function getLinks() {
+               return $this->links;
+       }
+
+
+
+       public static function get($authorizationId, $apiContext = null) {
+               if (($authorizationId == null) || (strlen($authorizationId) <= 0)) {
+                       throw new \InvalidArgumentException("authorizationId cannot be null or empty");
+               }
+               $payLoad = "";
+               if ($apiContext == null) {
+                       $apiContext = new ApiContext(self::$credential);
+               }
+               $call = new PPRestCall($apiContext);
+               $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/authorization/$authorizationId", "GET", $payLoad);
+               $ret = new Authorization();
+               $ret->fromJson($json);
+               return $ret;
+       }
+
+       public function capture($capture, $apiContext = null) {
+               if ($this->getId() == null) {
+                       throw new \InvalidArgumentException("Id cannot be null");
+               }
+               if (($capture == null)) {
+                       throw new \InvalidArgumentException("capture cannot be null or empty");
+               }
+               $payLoad = $capture->toJSON();
+               if ($apiContext == null) {
+                       $apiContext = new ApiContext(self::$credential);
+               }
+               $call = new PPRestCall($apiContext);
+               $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/authorization/{$this->getId()}/capture", "POST", $payLoad);
+               $ret = new Capture();
+               $ret->fromJson($json);
+               return $ret;
+       }
+
+       public function void($apiContext = null) {
+               if ($this->getId() == null) {
+                       throw new \InvalidArgumentException("Id cannot be null");
+               }
+               $payLoad = "";
+               if ($apiContext == null) {
+                       $apiContext = new ApiContext(self::$credential);
+               }
+               $call = new PPRestCall($apiContext);
+               $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/authorization/{$this->getId()}/void", "POST", $payLoad);
+               $ret = new Authorization();
+               $ret->fromJson($json);
+               return $ret;
+       }
+
+       public function reauthorize($apiContext = null) {
+               if ($this->getId() == null) {
+                       throw new \InvalidArgumentException("Id cannot be null");
+               }
+               $payLoad = $this->toJSON();
+               if ($apiContext == null) {
+                       $apiContext = new ApiContext(self::$credential);
+               }
+               $call = new PPRestCall($apiContext);
+               $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/authorization/{$this->getId()}/reauthorize", "POST", $payLoad);
+               $this->fromJson($json);
+               return $this;
+       }
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Capture.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Capture.php
new file mode 100644 (file)
index 0000000..773f952
--- /dev/null
@@ -0,0 +1,270 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+use PayPal\Rest\IResource;
+use PayPal\Rest\Call;
+use PayPal\Rest\ApiContext;
+use PayPal\Api\Capture;
+use PayPal\Api\Refund;
+use PayPal\Transport\PPRestCall;
+
+class Capture extends PPModel implements IResource {
+
+       private static $credential;
+
+       /**
+        *
+        * @deprecated. Pass ApiContext to create/get methods instead
+        */
+       public static function setCredential($credential) {
+               self::$credential = $credential;
+       }
+
+       /**
+        * Identifier of the Capture transaction.
+        * @param string $id
+        */
+       public function setId($id) {
+               $this->id = $id;
+               return $this;
+       }
+
+       /**
+        * Identifier of the Capture transaction.
+        * @return string
+        */
+       public function getId() {
+               return $this->id;
+       }
+
+
+       /**
+        * Time the resource was created.
+        * @param string $create_time
+        */
+       public function setCreateTime($create_time) {
+               $this->create_time = $create_time;
+               return $this;
+       }
+
+       /**
+        * Time the resource was created.
+        * @return string
+        */
+       public function getCreateTime() {
+               return $this->create_time;
+       }
+
+       /**
+        * Time the resource was created.
+        * @param string $create_time
+        * @deprecated. Instead use setCreateTime
+        */
+       public function setCreate_time($create_time) {
+               $this->create_time = $create_time;
+               return $this;
+       }
+       /**
+        * Time the resource was created.
+        * @return string
+        * @deprecated. Instead use getCreateTime
+        */
+       public function getCreate_time() {
+               return $this->create_time;
+       }
+
+       /**
+        * Time the resource was last updated.
+        * @param string $update_time
+        */
+       public function setUpdateTime($update_time) {
+               $this->update_time = $update_time;
+               return $this;
+       }
+
+       /**
+        * Time the resource was last updated.
+        * @return string
+        */
+       public function getUpdateTime() {
+               return $this->update_time;
+       }
+
+       /**
+        * Time the resource was last updated.
+        * @param string $update_time
+        * @deprecated. Instead use setUpdateTime
+        */
+       public function setUpdate_time($update_time) {
+               $this->update_time = $update_time;
+               return $this;
+       }
+       /**
+        * Time the resource was last updated.
+        * @return string
+        * @deprecated. Instead use getUpdateTime
+        */
+       public function getUpdate_time() {
+               return $this->update_time;
+       }
+
+       /**
+        * Amount being captured. If no amount is specified, amount is used from the authorization being captured. If amount is same as the amount that's authorized for, the state of the authorization changes to captured. If not, the state of the authorization changes to partially_captured. Alternatively, you could indicate a final capture by seting the is_final_capture flag to true.
+        * @param PayPal\Api\Amount $amount
+        */
+       public function setAmount($amount) {
+               $this->amount = $amount;
+               return $this;
+       }
+
+       /**
+        * Amount being captured. If no amount is specified, amount is used from the authorization being captured. If amount is same as the amount that's authorized for, the state of the authorization changes to captured. If not, the state of the authorization changes to partially_captured. Alternatively, you could indicate a final capture by seting the is_final_capture flag to true.
+        * @return PayPal\Api\Amount
+        */
+       public function getAmount() {
+               return $this->amount;
+       }
+
+
+       /**
+        * whether this is a final capture for the given authorization or not. If it's final, all the remaining funds held by the authorization, will be released in the funding instrument.
+        * @param boolean $is_final_capture
+        */
+       public function setIsFinalCapture($is_final_capture) {
+               $this->is_final_capture = $is_final_capture;
+               return $this;
+       }
+
+       /**
+        * whether this is a final capture for the given authorization or not. If it's final, all the remaining funds held by the authorization, will be released in the funding instrument.
+        * @return boolean
+        */
+       public function getIsFinalCapture() {
+               return $this->is_final_capture;
+       }
+
+       /**
+        * whether this is a final capture for the given authorization or not. If it's final, all the remaining funds held by the authorization, will be released in the funding instrument.
+        * @param boolean $is_final_capture
+        * @deprecated. Instead use setIsFinalCapture
+        */
+       public function setIs_final_capture($is_final_capture) {
+               $this->is_final_capture = $is_final_capture;
+               return $this;
+       }
+       /**
+        * whether this is a final capture for the given authorization or not. If it's final, all the remaining funds held by the authorization, will be released in the funding instrument.
+        * @return boolean
+        * @deprecated. Instead use getIsFinalCapture
+        */
+       public function getIs_final_capture() {
+               return $this->is_final_capture;
+       }
+
+       /**
+        * State of the capture transaction.
+        * @param string $state
+        */
+       public function setState($state) {
+               $this->state = $state;
+               return $this;
+       }
+
+       /**
+        * State of the capture transaction.
+        * @return string
+        */
+       public function getState() {
+               return $this->state;
+       }
+
+
+       /**
+        * ID of the Payment resource that this transaction is based on.
+        * @param string $parent_payment
+        */
+       public function setParentPayment($parent_payment) {
+               $this->parent_payment = $parent_payment;
+               return $this;
+       }
+
+       /**
+        * ID of the Payment resource that this transaction is based on.
+        * @return string
+        */
+       public function getParentPayment() {
+               return $this->parent_payment;
+       }
+
+       /**
+        * ID of the Payment resource that this transaction is based on.
+        * @param string $parent_payment
+        * @deprecated. Instead use setParentPayment
+        */
+       public function setParent_payment($parent_payment) {
+               $this->parent_payment = $parent_payment;
+               return $this;
+       }
+       /**
+        * ID of the Payment resource that this transaction is based on.
+        * @return string
+        * @deprecated. Instead use getParentPayment
+        */
+       public function getParent_payment() {
+               return $this->parent_payment;
+       }
+
+       /**
+        * 
+        * @array
+        * @param PayPal\Api\Links $links
+        */
+       public function setLinks($links) {
+               $this->links = $links;
+               return $this;
+       }
+
+       /**
+        * 
+        * @return PayPal\Api\Links
+        */
+       public function getLinks() {
+               return $this->links;
+       }
+
+
+
+       public static function get($captureId, $apiContext = null) {
+               if (($captureId == null) || (strlen($captureId) <= 0)) {
+                       throw new \InvalidArgumentException("captureId cannot be null or empty");
+               }
+               $payLoad = "";
+               if ($apiContext == null) {
+                       $apiContext = new ApiContext(self::$credential);
+               }
+               $call = new PPRestCall($apiContext);
+               $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/capture/$captureId", "GET", $payLoad);
+               $ret = new Capture();
+               $ret->fromJson($json);
+               return $ret;
+       }
+
+       public function refund($refund, $apiContext = null) {
+               if ($this->getId() == null) {
+                       throw new \InvalidArgumentException("Id cannot be null");
+               }
+               if (($refund == null)) {
+                       throw new \InvalidArgumentException("refund cannot be null or empty");
+               }
+               $payLoad = $refund->toJSON();
+               if ($apiContext == null) {
+                       $apiContext = new ApiContext(self::$credential);
+               }
+               $call = new PPRestCall($apiContext);
+               $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/capture/{$this->getId()}/refund", "POST", $payLoad);
+               $ret = new Refund();
+               $ret->fromJson($json);
+               return $ret;
+       }
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/CreditCard.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/CreditCard.php
new file mode 100644 (file)
index 0000000..cd0ee91
--- /dev/null
@@ -0,0 +1,416 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+use PayPal\Rest\IResource;
+use PayPal\Rest\Call;
+use PayPal\Rest\ApiContext;
+use PayPal\Api\CreditCard;
+use PayPal\Transport\PPRestCall;
+
+class CreditCard extends PPModel implements IResource {
+
+       private static $credential;
+
+       /**
+        *
+        * @deprecated. Pass ApiContext to create/get methods instead
+        */
+       public static function setCredential($credential) {
+               self::$credential = $credential;
+       }
+
+       /**
+        * ID of the credit card being saved for later use.
+        * @param string $id
+        */
+       public function setId($id) {
+               $this->id = $id;
+               return $this;
+       }
+
+       /**
+        * ID of the credit card being saved for later use.
+        * @return string
+        */
+       public function getId() {
+               return $this->id;
+       }
+
+
+       /**
+        * Card number.
+        * @param string $number
+        */
+       public function setNumber($number) {
+               $this->number = $number;
+               return $this;
+       }
+
+       /**
+        * Card number.
+        * @return string
+        */
+       public function getNumber() {
+               return $this->number;
+       }
+
+
+       /**
+        * Type of the Card (eg. Visa, Mastercard, etc.).
+        * @param string $type
+        */
+       public function setType($type) {
+               $this->type = $type;
+               return $this;
+       }
+
+       /**
+        * Type of the Card (eg. Visa, Mastercard, etc.).
+        * @return string
+        */
+       public function getType() {
+               return $this->type;
+       }
+
+
+       /**
+        * card expiry month with value 1 - 12.
+        * @param integer $expire_month
+        */
+       public function setExpireMonth($expire_month) {
+               $this->expire_month = $expire_month;
+               return $this;
+       }
+
+       /**
+        * card expiry month with value 1 - 12.
+        * @return integer
+        */
+       public function getExpireMonth() {
+               return $this->expire_month;
+       }
+
+       /**
+        * card expiry month with value 1 - 12.
+        * @param integer $expire_month
+        * @deprecated. Instead use setExpireMonth
+        */
+       public function setExpire_month($expire_month) {
+               $this->expire_month = $expire_month;
+               return $this;
+       }
+       /**
+        * card expiry month with value 1 - 12.
+        * @return integer
+        * @deprecated. Instead use getExpireMonth
+        */
+       public function getExpire_month() {
+               return $this->expire_month;
+       }
+
+       /**
+        * 4 digit card expiry year
+        * @param integer $expire_year
+        */
+       public function setExpireYear($expire_year) {
+               $this->expire_year = $expire_year;
+               return $this;
+       }
+
+       /**
+        * 4 digit card expiry year
+        * @return integer
+        */
+       public function getExpireYear() {
+               return $this->expire_year;
+       }
+
+       /**
+        * 4 digit card expiry year
+        * @param integer $expire_year
+        * @deprecated. Instead use setExpireYear
+        */
+       public function setExpire_year($expire_year) {
+               $this->expire_year = $expire_year;
+               return $this;
+       }
+       /**
+        * 4 digit card expiry year
+        * @return integer
+        * @deprecated. Instead use getExpireYear
+        */
+       public function getExpire_year() {
+               return $this->expire_year;
+       }
+
+       /**
+        * Card validation code. Only supported when making a Payment but not when saving a credit card for future use.
+        * @param string $cvv2
+        */
+       public function setCvv2($cvv2) {
+               $this->cvv2 = $cvv2;
+               return $this;
+       }
+
+       /**
+        * Card validation code. Only supported when making a Payment but not when saving a credit card for future use.
+        * @return string
+        */
+       public function getCvv2() {
+               return $this->cvv2;
+       }
+
+
+       /**
+        * Card holder's first name.
+        * @param string $first_name
+        */
+       public function setFirstName($first_name) {
+               $this->first_name = $first_name;
+               return $this;
+       }
+
+       /**
+        * Card holder's first name.
+        * @return string
+        */
+       public function getFirstName() {
+               return $this->first_name;
+       }
+
+       /**
+        * Card holder's first name.
+        * @param string $first_name
+        * @deprecated. Instead use setFirstName
+        */
+       public function setFirst_name($first_name) {
+               $this->first_name = $first_name;
+               return $this;
+       }
+       /**
+        * Card holder's first name.
+        * @return string
+        * @deprecated. Instead use getFirstName
+        */
+       public function getFirst_name() {
+               return $this->first_name;
+       }
+
+       /**
+        * Card holder's last name.
+        * @param string $last_name
+        */
+       public function setLastName($last_name) {
+               $this->last_name = $last_name;
+               return $this;
+       }
+
+       /**
+        * Card holder's last name.
+        * @return string
+        */
+       public function getLastName() {
+               return $this->last_name;
+       }
+
+       /**
+        * Card holder's last name.
+        * @param string $last_name
+        * @deprecated. Instead use setLastName
+        */
+       public function setLast_name($last_name) {
+               $this->last_name = $last_name;
+               return $this;
+       }
+       /**
+        * Card holder's last name.
+        * @return string
+        * @deprecated. Instead use getLastName
+        */
+       public function getLast_name() {
+               return $this->last_name;
+       }
+
+       /**
+        * Billing Address associated with this card.
+        * @param PayPal\Api\Address $billing_address
+        */
+       public function setBillingAddress($billing_address) {
+               $this->billing_address = $billing_address;
+               return $this;
+       }
+
+       /**
+        * Billing Address associated with this card.
+        * @return PayPal\Api\Address
+        */
+       public function getBillingAddress() {
+               return $this->billing_address;
+       }
+
+       /**
+        * Billing Address associated with this card.
+        * @param PayPal\Api\Address $billing_address
+        * @deprecated. Instead use setBillingAddress
+        */
+       public function setBilling_address($billing_address) {
+               $this->billing_address = $billing_address;
+               return $this;
+       }
+       /**
+        * Billing Address associated with this card.
+        * @return PayPal\Api\Address
+        * @deprecated. Instead use getBillingAddress
+        */
+       public function getBilling_address() {
+               return $this->billing_address;
+       }
+
+       /**
+        * A unique identifier of the payer generated and provided by the facilitator. This is required when creating or using a tokenized funding instrument.
+        * @param string $payer_id
+        */
+       public function setPayerId($payer_id) {
+               $this->payer_id = $payer_id;
+               return $this;
+       }
+
+       /**
+        * A unique identifier of the payer generated and provided by the facilitator. This is required when creating or using a tokenized funding instrument.
+        * @return string
+        */
+       public function getPayerId() {
+               return $this->payer_id;
+       }
+
+       /**
+        * A unique identifier of the payer generated and provided by the facilitator. This is required when creating or using a tokenized funding instrument.
+        * @param string $payer_id
+        * @deprecated. Instead use setPayerId
+        */
+       public function setPayer_id($payer_id) {
+               $this->payer_id = $payer_id;
+               return $this;
+       }
+       /**
+        * A unique identifier of the payer generated and provided by the facilitator. This is required when creating or using a tokenized funding instrument.
+        * @return string
+        * @deprecated. Instead use getPayerId
+        */
+       public function getPayer_id() {
+               return $this->payer_id;
+       }
+
+       /**
+        * State of the funding instrument.
+        * @param string $state
+        */
+       public function setState($state) {
+               $this->state = $state;
+               return $this;
+       }
+
+       /**
+        * State of the funding instrument.
+        * @return string
+        */
+       public function getState() {
+               return $this->state;
+       }
+
+
+       /**
+        * Date/Time until this resource can be used fund a payment.
+        * @param string $valid_until
+        */
+       public function setValidUntil($valid_until) {
+               $this->valid_until = $valid_until;
+               return $this;
+       }
+
+       /**
+        * Date/Time until this resource can be used fund a payment.
+        * @return string
+        */
+       public function getValidUntil() {
+               return $this->valid_until;
+       }
+
+       /**
+        * Date/Time until this resource can be used fund a payment.
+        * @param string $valid_until
+        * @deprecated. Instead use setValidUntil
+        */
+       public function setValid_until($valid_until) {
+               $this->valid_until = $valid_until;
+               return $this;
+       }
+       /**
+        * Date/Time until this resource can be used fund a payment.
+        * @return string
+        * @deprecated. Instead use getValidUntil
+        */
+       public function getValid_until() {
+               return $this->valid_until;
+       }
+
+       /**
+        * 
+        * @array
+        * @param PayPal\Api\Links $links
+        */
+       public function setLinks($links) {
+               $this->links = $links;
+               return $this;
+       }
+
+       /**
+        * 
+        * @return PayPal\Api\Links
+        */
+       public function getLinks() {
+               return $this->links;
+       }
+
+
+
+       public function create($apiContext = null) {
+               $payLoad = $this->toJSON();
+               if ($apiContext == null) {
+                       $apiContext = new ApiContext(self::$credential);
+               }
+               $call = new PPRestCall($apiContext);
+               $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/vault/credit-card", "POST", $payLoad);
+               $this->fromJson($json);
+               return $this;
+       }
+
+       public static function get($creditCardId, $apiContext = null) {
+               if (($creditCardId == null) || (strlen($creditCardId) <= 0)) {
+                       throw new \InvalidArgumentException("creditCardId cannot be null or empty");
+               }
+               $payLoad = "";
+               if ($apiContext == null) {
+                       $apiContext = new ApiContext(self::$credential);
+               }
+               $call = new PPRestCall($apiContext);
+               $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/vault/credit-card/$creditCardId", "GET", $payLoad);
+               $ret = new CreditCard();
+               $ret->fromJson($json);
+               return $ret;
+       }
+
+       public function delete($apiContext = null) {
+               if ($this->getId() == null) {
+                       throw new \InvalidArgumentException("Id cannot be null");
+               }
+               $payLoad = "";
+               if ($apiContext == null) {
+                       $apiContext = new ApiContext(self::$credential);
+               }
+               $call = new PPRestCall($apiContext);
+               $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/vault/credit-card/{$this->getId()}", "DELETE", $payLoad);
+    return true;
+       }
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/CreditCardHistory.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/CreditCardHistory.php
new file mode 100644 (file)
index 0000000..4251e62
--- /dev/null
@@ -0,0 +1,97 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+
+class CreditCardHistory extends PPModel {
+       /**
+        * A list of credit card resources
+        * @array
+        * @param PayPal\Api\CreditCard $credit-cards
+        */
+       public function setCreditCards($credit_cards) {
+               $this->{"credit-cards"} = $credit_cards;
+               return $this;
+       }
+
+       /**
+        * A list of credit card resources
+        * @return PayPal\Api\CreditCard
+        */
+       public function getCreditCards() {
+               return $this->{"credit-cards"};
+       }
+
+       /**
+        * A list of credit card resources
+        * @array
+        * @param PayPal\Api\CreditCard $credit-cards
+        * @deprecated. Instead use setCreditCards
+        */
+       public function setCredit_cards($credit_cards) {
+               $this->{"credit-cards"} = $credit_cards;
+               return $this;
+       }
+       /**
+        * A list of credit card resources
+        * @return PayPal\Api\CreditCard
+        * @deprecated. Instead use getCreditCards
+        */
+       public function getCredit_cards() {
+               return $this->{"credit-cards"};
+       }
+
+       /**
+        * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items.
+        * @param integer $count
+        */
+       public function setCount($count) {
+               $this->count = $count;
+               return $this;
+       }
+
+       /**
+        * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items.
+        * @return integer
+        */
+       public function getCount() {
+               return $this->count;
+       }
+
+
+       /**
+        * Identifier of the next element to get the next range of results.
+        * @param string $next_id
+        */
+       public function setNextId($next_id) {
+               $this->next_id = $next_id;
+               return $this;
+       }
+
+       /**
+        * Identifier of the next element to get the next range of results.
+        * @return string
+        */
+       public function getNextId() {
+               return $this->next_id;
+       }
+
+       /**
+        * Identifier of the next element to get the next range of results.
+        * @param string $next_id
+        * @deprecated. Instead use setNextId
+        */
+       public function setNext_id($next_id) {
+               $this->next_id = $next_id;
+               return $this;
+       }
+       /**
+        * Identifier of the next element to get the next range of results.
+        * @return string
+        * @deprecated. Instead use getNextId
+        */
+       public function getNext_id() {
+               return $this->next_id;
+       }
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/CreditCardToken.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/CreditCardToken.php
new file mode 100644 (file)
index 0000000..13430dd
--- /dev/null
@@ -0,0 +1,183 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+
+class CreditCardToken extends PPModel {
+       /**
+        * ID of a previously saved Credit Card resource using /vault/credit-card API.
+        * @param string $credit_card_id
+        */
+       public function setCreditCardId($credit_card_id) {
+               $this->credit_card_id = $credit_card_id;
+               return $this;
+       }
+
+       /**
+        * ID of a previously saved Credit Card resource using /vault/credit-card API.
+        * @return string
+        */
+       public function getCreditCardId() {
+               return $this->credit_card_id;
+       }
+
+       /**
+        * ID of a previously saved Credit Card resource using /vault/credit-card API.
+        * @param string $credit_card_id
+        * @deprecated. Instead use setCreditCardId
+        */
+       public function setCredit_card_id($credit_card_id) {
+               $this->credit_card_id = $credit_card_id;
+               return $this;
+       }
+       /**
+        * ID of a previously saved Credit Card resource using /vault/credit-card API.
+        * @return string
+        * @deprecated. Instead use getCreditCardId
+        */
+       public function getCredit_card_id() {
+               return $this->credit_card_id;
+       }
+
+       /**
+        * The unique identifier of the payer used when saving this credit card using /vault/credit-card API.
+        * @param string $payer_id
+        */
+       public function setPayerId($payer_id) {
+               $this->payer_id = $payer_id;
+               return $this;
+       }
+
+       /**
+        * The unique identifier of the payer used when saving this credit card using /vault/credit-card API.
+        * @return string
+        */
+       public function getPayerId() {
+               return $this->payer_id;
+       }
+
+       /**
+        * The unique identifier of the payer used when saving this credit card using /vault/credit-card API.
+        * @param string $payer_id
+        * @deprecated. Instead use setPayerId
+        */
+       public function setPayer_id($payer_id) {
+               $this->payer_id = $payer_id;
+               return $this;
+       }
+       /**
+        * The unique identifier of the payer used when saving this credit card using /vault/credit-card API.
+        * @return string
+        * @deprecated. Instead use getPayerId
+        */
+       public function getPayer_id() {
+               return $this->payer_id;
+       }
+
+       /**
+        * Last 4 digits of the card number from the saved card.
+        * @param string $last4
+        */
+       public function setLast4($last4) {
+               $this->last4 = $last4;
+               return $this;
+       }
+
+       /**
+        * Last 4 digits of the card number from the saved card.
+        * @return string
+        */
+       public function getLast4() {
+               return $this->last4;
+       }
+
+
+       /**
+        * Type of the Card (eg. visa, mastercard, etc.) from the saved card. Please note that the values are always in lowercase and not meant to be used directly for display.
+        * @param string $type
+        */
+       public function setType($type) {
+               $this->type = $type;
+               return $this;
+       }
+
+       /**
+        * Type of the Card (eg. visa, mastercard, etc.) from the saved card. Please note that the values are always in lowercase and not meant to be used directly for display.
+        * @return string
+        */
+       public function getType() {
+               return $this->type;
+       }
+
+
+       /**
+        * card expiry month from the saved card with value 1 - 12
+        * @param integer $expire_month
+        */
+       public function setExpireMonth($expire_month) {
+               $this->expire_month = $expire_month;
+               return $this;
+       }
+
+       /**
+        * card expiry month from the saved card with value 1 - 12
+        * @return integer
+        */
+       public function getExpireMonth() {
+               return $this->expire_month;
+       }
+
+       /**
+        * card expiry month from the saved card with value 1 - 12
+        * @param integer $expire_month
+        * @deprecated. Instead use setExpireMonth
+        */
+       public function setExpire_month($expire_month) {
+               $this->expire_month = $expire_month;
+               return $this;
+       }
+       /**
+        * card expiry month from the saved card with value 1 - 12
+        * @return integer
+        * @deprecated. Instead use getExpireMonth
+        */
+       public function getExpire_month() {
+               return $this->expire_month;
+       }
+
+       /**
+        * 4 digit card expiry year from the saved card
+        * @param integer $expire_year
+        */
+       public function setExpireYear($expire_year) {
+               $this->expire_year = $expire_year;
+               return $this;
+       }
+
+       /**
+        * 4 digit card expiry year from the saved card
+        * @return integer
+        */
+       public function getExpireYear() {
+               return $this->expire_year;
+       }
+
+       /**
+        * 4 digit card expiry year from the saved card
+        * @param integer $expire_year
+        * @deprecated. Instead use setExpireYear
+        */
+       public function setExpire_year($expire_year) {
+               $this->expire_year = $expire_year;
+               return $this;
+       }
+       /**
+        * 4 digit card expiry year from the saved card
+        * @return integer
+        * @deprecated. Instead use getExpireYear
+        */
+       public function getExpire_year() {
+               return $this->expire_year;
+       }
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Details.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Details.php
new file mode 100644 (file)
index 0000000..ab38367
--- /dev/null
@@ -0,0 +1,79 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+
+class Details extends PPModel {
+       /**
+        * Amount being charged for shipping.
+        * @param string $shipping
+        */
+       public function setShipping($shipping) {
+               $this->shipping = $shipping;
+               return $this;
+       }
+
+       /**
+        * Amount being charged for shipping.
+        * @return string
+        */
+       public function getShipping() {
+               return $this->shipping;
+       }
+
+
+       /**
+        * Sub-total (amount) of items being paid for.
+        * @param string $subtotal
+        */
+       public function setSubtotal($subtotal) {
+               $this->subtotal = $subtotal;
+               return $this;
+       }
+
+       /**
+        * Sub-total (amount) of items being paid for.
+        * @return string
+        */
+       public function getSubtotal() {
+               return $this->subtotal;
+       }
+
+
+       /**
+        * Amount being charged as tax.
+        * @param string $tax
+        */
+       public function setTax($tax) {
+               $this->tax = $tax;
+               return $this;
+       }
+
+       /**
+        * Amount being charged as tax.
+        * @return string
+        */
+       public function getTax() {
+               return $this->tax;
+       }
+
+
+       /**
+        * Fee charged by PayPal. In case of a refund, this is the fee amount refunded to the original receipient of the payment.
+        * @param string $fee
+        */
+       public function setFee($fee) {
+               $this->fee = $fee;
+               return $this;
+       }
+
+       /**
+        * Fee charged by PayPal. In case of a refund, this is the fee amount refunded to the original receipient of the payment.
+        * @return string
+        */
+       public function getFee() {
+               return $this->fee;
+       }
+
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/FundingInstrument.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/FundingInstrument.php
new file mode 100644 (file)
index 0000000..6800675
--- /dev/null
@@ -0,0 +1,77 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+
+class FundingInstrument extends PPModel {
+       /**
+        * Credit Card information.
+        * @param PayPal\Api\CreditCard $credit_card
+        */
+       public function setCreditCard($credit_card) {
+               $this->credit_card = $credit_card;
+               return $this;
+       }
+
+       /**
+        * Credit Card information.
+        * @return PayPal\Api\CreditCard
+        */
+       public function getCreditCard() {
+               return $this->credit_card;
+       }
+
+       /**
+        * Credit Card information.
+        * @param PayPal\Api\CreditCard $credit_card
+        * @deprecated. Instead use setCreditCard
+        */
+       public function setCredit_card($credit_card) {
+               $this->credit_card = $credit_card;
+               return $this;
+       }
+       /**
+        * Credit Card information.
+        * @return PayPal\Api\CreditCard
+        * @deprecated. Instead use getCreditCard
+        */
+       public function getCredit_card() {
+               return $this->credit_card;
+       }
+
+       /**
+        * Credit Card information.
+        * @param PayPal\Api\CreditCardToken $credit_card_token
+        */
+       public function setCreditCardToken($credit_card_token) {
+               $this->credit_card_token = $credit_card_token;
+               return $this;
+       }
+
+       /**
+        * Credit Card information.
+        * @return PayPal\Api\CreditCardToken
+        */
+       public function getCreditCardToken() {
+               return $this->credit_card_token;
+       }
+
+       /**
+        * Credit Card information.
+        * @param PayPal\Api\CreditCardToken $credit_card_token
+        * @deprecated. Instead use setCreditCardToken
+        */
+       public function setCredit_card_token($credit_card_token) {
+               $this->credit_card_token = $credit_card_token;
+               return $this;
+       }
+       /**
+        * Credit Card information.
+        * @return PayPal\Api\CreditCardToken
+        * @deprecated. Instead use getCreditCardToken
+        */
+       public function getCredit_card_token() {
+               return $this->credit_card_token;
+       }
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/HyperSchema.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/HyperSchema.php
new file mode 100644 (file)
index 0000000..a09ee92
--- /dev/null
@@ -0,0 +1,116 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+
+class HyperSchema extends PPModel {
+       /**
+        * 
+        * @array
+        * @param PayPal\Api\Links $links
+        */
+       public function setLinks($links) {
+               $this->links = $links;
+               return $this;
+       }
+
+       /**
+        * 
+        * @return PayPal\Api\Links
+        */
+       public function getLinks() {
+               return $this->links;
+       }
+
+
+       /**
+        * 
+        * @param string $fragmentResolution
+        */
+       public function setFragmentResolution($fragmentResolution) {
+               $this->fragmentResolution = $fragmentResolution;
+               return $this;
+       }
+
+       /**
+        * 
+        * @return string
+        */
+       public function getFragmentResolution() {
+               return $this->fragmentResolution;
+       }
+
+
+       /**
+        * 
+        * @param boolean $readonly
+        */
+       public function setReadonly($readonly) {
+               $this->readonly = $readonly;
+               return $this;
+       }
+
+       /**
+        * 
+        * @return boolean
+        */
+       public function getReadonly() {
+               return $this->readonly;
+       }
+
+
+       /**
+        * 
+        * @param string $contentEncoding
+        */
+       public function setContentEncoding($contentEncoding) {
+               $this->contentEncoding = $contentEncoding;
+               return $this;
+       }
+
+       /**
+        * 
+        * @return string
+        */
+       public function getContentEncoding() {
+               return $this->contentEncoding;
+       }
+
+
+       /**
+        * 
+        * @param string $pathStart
+        */
+       public function setPathStart($pathStart) {
+               $this->pathStart = $pathStart;
+               return $this;
+       }
+
+       /**
+        * 
+        * @return string
+        */
+       public function getPathStart() {
+               return $this->pathStart;
+       }
+
+
+       /**
+        * 
+        * @param string $mediaType
+        */
+       public function setMediaType($mediaType) {
+               $this->mediaType = $mediaType;
+               return $this;
+       }
+
+       /**
+        * 
+        * @return string
+        */
+       public function getMediaType() {
+               return $this->mediaType;
+       }
+
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Item.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Item.php
new file mode 100644 (file)
index 0000000..4a40632
--- /dev/null
@@ -0,0 +1,97 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+
+class Item extends PPModel {
+       /**
+        * Number of items.
+        * @param string $quantity
+        */
+       public function setQuantity($quantity) {
+               $this->quantity = $quantity;
+               return $this;
+       }
+
+       /**
+        * Number of items.
+        * @return string
+        */
+       public function getQuantity() {
+               return $this->quantity;
+       }
+
+
+       /**
+        * Name of the item.
+        * @param string $name
+        */
+       public function setName($name) {
+               $this->name = $name;
+               return $this;
+       }
+
+       /**
+        * Name of the item.
+        * @return string
+        */
+       public function getName() {
+               return $this->name;
+       }
+
+
+       /**
+        * Cost of the item.
+        * @param string $price
+        */
+       public function setPrice($price) {
+               $this->price = $price;
+               return $this;
+       }
+
+       /**
+        * Cost of the item.
+        * @return string
+        */
+       public function getPrice() {
+               return $this->price;
+       }
+
+
+       /**
+        * 3-letter Currency Code
+        * @param string $currency
+        */
+       public function setCurrency($currency) {
+               $this->currency = $currency;
+               return $this;
+       }
+
+       /**
+        * 3-letter Currency Code
+        * @return string
+        */
+       public function getCurrency() {
+               return $this->currency;
+       }
+
+
+       /**
+        * Number or code to identify the item in your catalog/records.
+        * @param string $sku
+        */
+       public function setSku($sku) {
+               $this->sku = $sku;
+               return $this;
+       }
+
+       /**
+        * Number or code to identify the item in your catalog/records.
+        * @return string
+        */
+       public function getSku() {
+               return $this->sku;
+       }
+
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/ItemList.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/ItemList.php
new file mode 100644 (file)
index 0000000..ea38da6
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+
+class ItemList extends PPModel {
+       /**
+        * List of items.
+        * @array
+        * @param PayPal\Api\Item $items
+        */
+       public function setItems($items) {
+               $this->items = $items;
+               return $this;
+       }
+
+       /**
+        * List of items.
+        * @return PayPal\Api\Item
+        */
+       public function getItems() {
+               return $this->items;
+       }
+
+
+       /**
+        * Shipping address.
+        * @param PayPal\Api\ShippingAddress $shipping_address
+        */
+       public function setShippingAddress($shipping_address) {
+               $this->shipping_address = $shipping_address;
+               return $this;
+       }
+
+       /**
+        * Shipping address.
+        * @return PayPal\Api\ShippingAddress
+        */
+       public function getShippingAddress() {
+               return $this->shipping_address;
+       }
+
+       /**
+        * Shipping address.
+        * @param PayPal\Api\ShippingAddress $shipping_address
+        * @deprecated. Instead use setShippingAddress
+        */
+       public function setShipping_address($shipping_address) {
+               $this->shipping_address = $shipping_address;
+               return $this;
+       }
+       /**
+        * Shipping address.
+        * @return PayPal\Api\ShippingAddress
+        * @deprecated. Instead use getShippingAddress
+        */
+       public function getShipping_address() {
+               return $this->shipping_address;
+       }
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Links.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Links.php
new file mode 100644 (file)
index 0000000..9cbd85e
--- /dev/null
@@ -0,0 +1,115 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+
+class Links extends PPModel {
+       /**
+        * 
+        * @param string $href
+        */
+       public function setHref($href) {
+               $this->href = $href;
+               return $this;
+       }
+
+       /**
+        * 
+        * @return string
+        */
+       public function getHref() {
+               return $this->href;
+       }
+
+
+       /**
+        * 
+        * @param string $rel
+        */
+       public function setRel($rel) {
+               $this->rel = $rel;
+               return $this;
+       }
+
+       /**
+        * 
+        * @return string
+        */
+       public function getRel() {
+               return $this->rel;
+       }
+
+
+       /**
+        * 
+        * @param PayPal\Api\HyperSchema $targetSchema
+        */
+       public function setTargetSchema($targetSchema) {
+               $this->targetSchema = $targetSchema;
+               return $this;
+       }
+
+       /**
+        * 
+        * @return PayPal\Api\HyperSchema
+        */
+       public function getTargetSchema() {
+               return $this->targetSchema;
+       }
+
+
+       /**
+        * 
+        * @param string $method
+        */
+       public function setMethod($method) {
+               $this->method = $method;
+               return $this;
+       }
+
+       /**
+        * 
+        * @return string
+        */
+       public function getMethod() {
+               return $this->method;
+       }
+
+
+       /**
+        * 
+        * @param string $enctype
+        */
+       public function setEnctype($enctype) {
+               $this->enctype = $enctype;
+               return $this;
+       }
+
+       /**
+        * 
+        * @return string
+        */
+       public function getEnctype() {
+               return $this->enctype;
+       }
+
+
+       /**
+        * 
+        * @param PayPal\Api\HyperSchema $schema
+        */
+       public function setSchema($schema) {
+               $this->schema = $schema;
+               return $this;
+       }
+
+       /**
+        * 
+        * @return PayPal\Api\HyperSchema
+        */
+       public function getSchema() {
+               return $this->schema;
+       }
+
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Payee.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Payee.php
new file mode 100644 (file)
index 0000000..d0ccea3
--- /dev/null
@@ -0,0 +1,78 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+
+class Payee extends PPModel {
+       /**
+        * Email Address associated with the Payee's PayPal Account. If the provided email address is not associated with any PayPal Account, the payee can only receiver PayPal Wallet Payments. Direct Credit Card Payments will be denied due to card compliance requirements.
+        * @param string $email
+        */
+       public function setEmail($email) {
+               $this->email = $email;
+               return $this;
+       }
+
+       /**
+        * Email Address associated with the Payee's PayPal Account. If the provided email address is not associated with any PayPal Account, the payee can only receiver PayPal Wallet Payments. Direct Credit Card Payments will be denied due to card compliance requirements.
+        * @return string
+        */
+       public function getEmail() {
+               return $this->email;
+       }
+
+
+       /**
+        * Encrypted PayPal Account identifier for the Payee.
+        * @param string $merchant_id
+        */
+       public function setMerchantId($merchant_id) {
+               $this->merchant_id = $merchant_id;
+               return $this;
+       }
+
+       /**
+        * Encrypted PayPal Account identifier for the Payee.
+        * @return string
+        */
+       public function getMerchantId() {
+               return $this->merchant_id;
+       }
+
+       /**
+        * Encrypted PayPal Account identifier for the Payee.
+        * @param string $merchant_id
+        * @deprecated. Instead use setMerchantId
+        */
+       public function setMerchant_id($merchant_id) {
+               $this->merchant_id = $merchant_id;
+               return $this;
+       }
+       /**
+        * Encrypted PayPal Account identifier for the Payee.
+        * @return string
+        * @deprecated. Instead use getMerchantId
+        */
+       public function getMerchant_id() {
+               return $this->merchant_id;
+       }
+
+       /**
+        * Phone number (in E.123 format) associated with the Payee's PayPal Account. If the provided phont number is not associated with any PayPal Account, the payee can only receiver PayPal Wallet Payments. Direct Credit Card Payments will be denied due to card compliance requirements.
+        * @param string $phone
+        */
+       public function setPhone($phone) {
+               $this->phone = $phone;
+               return $this;
+       }
+
+       /**
+        * Phone number (in E.123 format) associated with the Payee's PayPal Account. If the provided phont number is not associated with any PayPal Account, the payee can only receiver PayPal Wallet Payments. Direct Credit Card Payments will be denied due to card compliance requirements.
+        * @return string
+        */
+       public function getPhone() {
+               return $this->phone;
+       }
+
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Payer.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Payer.php
new file mode 100644 (file)
index 0000000..d21d238
--- /dev/null
@@ -0,0 +1,114 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+
+class Payer extends PPModel {
+       /**
+        * Payment method being used - PayPal Wallet payment or Direct Credit card.
+        * @param string $payment_method
+        */
+       public function setPaymentMethod($payment_method) {
+               $this->payment_method = $payment_method;
+               return $this;
+       }
+
+       /**
+        * Payment method being used - PayPal Wallet payment or Direct Credit card.
+        * @return string
+        */
+       public function getPaymentMethod() {
+               return $this->payment_method;
+       }
+
+       /**
+        * Payment method being used - PayPal Wallet payment or Direct Credit card.
+        * @param string $payment_method
+        * @deprecated. Instead use setPaymentMethod
+        */
+       public function setPayment_method($payment_method) {
+               $this->payment_method = $payment_method;
+               return $this;
+       }
+       /**
+        * Payment method being used - PayPal Wallet payment or Direct Credit card.
+        * @return string
+        * @deprecated. Instead use getPaymentMethod
+        */
+       public function getPayment_method() {
+               return $this->payment_method;
+       }
+
+       /**
+        * List of funding instruments from where the funds of the current payment come from. Typically a credit card.
+        * @array
+        * @param PayPal\Api\FundingInstrument $funding_instruments
+        */
+       public function setFundingInstruments($funding_instruments) {
+               $this->funding_instruments = $funding_instruments;
+               return $this;
+       }
+
+       /**
+        * List of funding instruments from where the funds of the current payment come from. Typically a credit card.
+        * @return PayPal\Api\FundingInstrument
+        */
+       public function getFundingInstruments() {
+               return $this->funding_instruments;
+       }
+
+       /**
+        * List of funding instruments from where the funds of the current payment come from. Typically a credit card.
+        * @array
+        * @param PayPal\Api\FundingInstrument $funding_instruments
+        * @deprecated. Instead use setFundingInstruments
+        */
+       public function setFunding_instruments($funding_instruments) {
+               $this->funding_instruments = $funding_instruments;
+               return $this;
+       }
+       /**
+        * List of funding instruments from where the funds of the current payment come from. Typically a credit card.
+        * @return PayPal\Api\FundingInstrument
+        * @deprecated. Instead use getFundingInstruments
+        */
+       public function getFunding_instruments() {
+               return $this->funding_instruments;
+       }
+
+       /**
+        * Information related to the Payer. In case of PayPal Wallet payment, this information will be filled in by PayPal after the user approves the payment using their PayPal Wallet. 
+        * @param PayPal\Api\PayerInfo $payer_info
+        */
+       public function setPayerInfo($payer_info) {
+               $this->payer_info = $payer_info;
+               return $this;
+       }
+
+       /**
+        * Information related to the Payer. In case of PayPal Wallet payment, this information will be filled in by PayPal after the user approves the payment using their PayPal Wallet. 
+        * @return PayPal\Api\PayerInfo
+        */
+       public function getPayerInfo() {
+               return $this->payer_info;
+       }
+
+       /**
+        * Information related to the Payer. In case of PayPal Wallet payment, this information will be filled in by PayPal after the user approves the payment using their PayPal Wallet. 
+        * @param PayPal\Api\PayerInfo $payer_info
+        * @deprecated. Instead use setPayerInfo
+        */
+       public function setPayer_info($payer_info) {
+               $this->payer_info = $payer_info;
+               return $this;
+       }
+       /**
+        * Information related to the Payer. In case of PayPal Wallet payment, this information will be filled in by PayPal after the user approves the payment using their PayPal Wallet. 
+        * @return PayPal\Api\PayerInfo
+        * @deprecated. Instead use getPayerInfo
+        */
+       public function getPayer_info() {
+               return $this->payer_info;
+       }
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/PayerInfo.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/PayerInfo.php
new file mode 100644 (file)
index 0000000..a9ff596
--- /dev/null
@@ -0,0 +1,183 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+
+class PayerInfo extends PPModel {
+       /**
+        * Email address representing the Payer.
+        * @param string $email
+        */
+       public function setEmail($email) {
+               $this->email = $email;
+               return $this;
+       }
+
+       /**
+        * Email address representing the Payer.
+        * @return string
+        */
+       public function getEmail() {
+               return $this->email;
+       }
+
+
+       /**
+        * First Name of the Payer from their PayPal Account.
+        * @param string $first_name
+        */
+       public function setFirstName($first_name) {
+               $this->first_name = $first_name;
+               return $this;
+       }
+
+       /**
+        * First Name of the Payer from their PayPal Account.
+        * @return string
+        */
+       public function getFirstName() {
+               return $this->first_name;
+       }
+
+       /**
+        * First Name of the Payer from their PayPal Account.
+        * @param string $first_name
+        * @deprecated. Instead use setFirstName
+        */
+       public function setFirst_name($first_name) {
+               $this->first_name = $first_name;
+               return $this;
+       }
+       /**
+        * First Name of the Payer from their PayPal Account.
+        * @return string
+        * @deprecated. Instead use getFirstName
+        */
+       public function getFirst_name() {
+               return $this->first_name;
+       }
+
+       /**
+        * Last Name of the Payer from their PayPal Account.
+        * @param string $last_name
+        */
+       public function setLastName($last_name) {
+               $this->last_name = $last_name;
+               return $this;
+       }
+
+       /**
+        * Last Name of the Payer from their PayPal Account.
+        * @return string
+        */
+       public function getLastName() {
+               return $this->last_name;
+       }
+
+       /**
+        * Last Name of the Payer from their PayPal Account.
+        * @param string $last_name
+        * @deprecated. Instead use setLastName
+        */
+       public function setLast_name($last_name) {
+               $this->last_name = $last_name;
+               return $this;
+       }
+       /**
+        * Last Name of the Payer from their PayPal Account.
+        * @return string
+        * @deprecated. Instead use getLastName
+        */
+       public function getLast_name() {
+               return $this->last_name;
+       }
+
+       /**
+        * PayPal assigned Payer ID.
+        * @param string $payer_id
+        */
+       public function setPayerId($payer_id) {
+               $this->payer_id = $payer_id;
+               return $this;
+       }
+
+       /**
+        * PayPal assigned Payer ID.
+        * @return string
+        */
+       public function getPayerId() {
+               return $this->payer_id;
+       }
+
+       /**
+        * PayPal assigned Payer ID.
+        * @param string $payer_id
+        * @deprecated. Instead use setPayerId
+        */
+       public function setPayer_id($payer_id) {
+               $this->payer_id = $payer_id;
+               return $this;
+       }
+       /**
+        * PayPal assigned Payer ID.
+        * @return string
+        * @deprecated. Instead use getPayerId
+        */
+       public function getPayer_id() {
+               return $this->payer_id;
+       }
+
+       /**
+        * Phone number representing the Payer.
+        * @param string $phone
+        */
+       public function setPhone($phone) {
+               $this->phone = $phone;
+               return $this;
+       }
+
+       /**
+        * Phone number representing the Payer.
+        * @return string
+        */
+       public function getPhone() {
+               return $this->phone;
+       }
+
+
+       /**
+        * Shipping address of the Payer from their PayPal Account.
+        * @param PayPal\Api\Address $shipping_address
+        */
+       public function setShippingAddress($shipping_address) {
+               $this->shipping_address = $shipping_address;
+               return $this;
+       }
+
+       /**
+        * Shipping address of the Payer from their PayPal Account.
+        * @return PayPal\Api\Address
+        */
+       public function getShippingAddress() {
+               return $this->shipping_address;
+       }
+
+       /**
+        * Shipping address of the Payer from their PayPal Account.
+        * @param PayPal\Api\Address $shipping_address
+        * @deprecated. Instead use setShippingAddress
+        */
+       public function setShipping_address($shipping_address) {
+               $this->shipping_address = $shipping_address;
+               return $this;
+       }
+       /**
+        * Shipping address of the Payer from their PayPal Account.
+        * @return PayPal\Api\Address
+        * @deprecated. Instead use getShippingAddress
+        */
+       public function getShipping_address() {
+               return $this->shipping_address;
+       }
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Payment.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Payment.php
new file mode 100644 (file)
index 0000000..cf223f0
--- /dev/null
@@ -0,0 +1,299 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+use PayPal\Rest\IResource;
+use PayPal\Rest\Call;
+use PayPal\Rest\ApiContext;
+use PayPal\Api\Payment;
+use PayPal\Api\PaymentHistory;
+use PayPal\Transport\PPRestCall;
+
+class Payment extends PPModel implements IResource {
+
+       private static $credential;
+
+       /**
+        *
+        * @deprecated. Pass ApiContext to create/get methods instead
+        */
+       public static function setCredential($credential) {
+               self::$credential = $credential;
+       }
+
+       /**
+        * Identifier of the payment resource created.
+        * @param string $id
+        */
+       public function setId($id) {
+               $this->id = $id;
+               return $this;
+       }
+
+       /**
+        * Identifier of the payment resource created.
+        * @return string
+        */
+       public function getId() {
+               return $this->id;
+       }
+
+
+       /**
+        * Time the resource was created.
+        * @param string $create_time
+        */
+       public function setCreateTime($create_time) {
+               $this->create_time = $create_time;
+               return $this;
+       }
+
+       /**
+        * Time the resource was created.
+        * @return string
+        */
+       public function getCreateTime() {
+               return $this->create_time;
+       }
+
+       /**
+        * Time the resource was created.
+        * @param string $create_time
+        * @deprecated. Instead use setCreateTime
+        */
+       public function setCreate_time($create_time) {
+               $this->create_time = $create_time;
+               return $this;
+       }
+       /**
+        * Time the resource was created.
+        * @return string
+        * @deprecated. Instead use getCreateTime
+        */
+       public function getCreate_time() {
+               return $this->create_time;
+       }
+
+       /**
+        * Time the resource was last updated.
+        * @param string $update_time
+        */
+       public function setUpdateTime($update_time) {
+               $this->update_time = $update_time;
+               return $this;
+       }
+
+       /**
+        * Time the resource was last updated.
+        * @return string
+        */
+       public function getUpdateTime() {
+               return $this->update_time;
+       }
+
+       /**
+        * Time the resource was last updated.
+        * @param string $update_time
+        * @deprecated. Instead use setUpdateTime
+        */
+       public function setUpdate_time($update_time) {
+               $this->update_time = $update_time;
+               return $this;
+       }
+       /**
+        * Time the resource was last updated.
+        * @return string
+        * @deprecated. Instead use getUpdateTime
+        */
+       public function getUpdate_time() {
+               return $this->update_time;
+       }
+
+       /**
+        * Intent of the payment - Sale or Authorization or Order.
+        * @param string $intent
+        */
+       public function setIntent($intent) {
+               $this->intent = $intent;
+               return $this;
+       }
+
+       /**
+        * Intent of the payment - Sale or Authorization or Order.
+        * @return string
+        */
+       public function getIntent() {
+               return $this->intent;
+       }
+
+
+       /**
+        * Source of the funds for this payment represented by a PayPal account or a direct credit card.
+        * @param PayPal\Api\Payer $payer
+        */
+       public function setPayer($payer) {
+               $this->payer = $payer;
+               return $this;
+       }
+
+       /**
+        * Source of the funds for this payment represented by a PayPal account or a direct credit card.
+        * @return PayPal\Api\Payer
+        */
+       public function getPayer() {
+               return $this->payer;
+       }
+
+
+       /**
+        * A payment can have more than one transaction, with each transaction establishing a contract between the payer and a payee
+        * @array
+        * @param PayPal\Api\Transaction $transactions
+        */
+       public function setTransactions($transactions) {
+               $this->transactions = $transactions;
+               return $this;
+       }
+
+       /**
+        * A payment can have more than one transaction, with each transaction establishing a contract between the payer and a payee
+        * @return PayPal\Api\Transaction
+        */
+       public function getTransactions() {
+               return $this->transactions;
+       }
+
+
+       /**
+        * state of the payment
+        * @param string $state
+        */
+       public function setState($state) {
+               $this->state = $state;
+               return $this;
+       }
+
+       /**
+        * state of the payment
+        * @return string
+        */
+       public function getState() {
+               return $this->state;
+       }
+
+
+       /**
+        * Redirect urls required only when using payment_method as PayPal - the only settings supported are return and cancel urls.
+        * @param PayPal\Api\RedirectUrls $redirect_urls
+        */
+       public function setRedirectUrls($redirect_urls) {
+               $this->redirect_urls = $redirect_urls;
+               return $this;
+       }
+
+       /**
+        * Redirect urls required only when using payment_method as PayPal - the only settings supported are return and cancel urls.
+        * @return PayPal\Api\RedirectUrls
+        */
+       public function getRedirectUrls() {
+               return $this->redirect_urls;
+       }
+
+       /**
+        * Redirect urls required only when using payment_method as PayPal - the only settings supported are return and cancel urls.
+        * @param PayPal\Api\RedirectUrls $redirect_urls
+        * @deprecated. Instead use setRedirectUrls
+        */
+       public function setRedirect_urls($redirect_urls) {
+               $this->redirect_urls = $redirect_urls;
+               return $this;
+       }
+       /**
+        * Redirect urls required only when using payment_method as PayPal - the only settings supported are return and cancel urls.
+        * @return PayPal\Api\RedirectUrls
+        * @deprecated. Instead use getRedirectUrls
+        */
+       public function getRedirect_urls() {
+               return $this->redirect_urls;
+       }
+
+       /**
+        * 
+        * @array
+        * @param PayPal\Api\Links $links
+        */
+       public function setLinks($links) {
+               $this->links = $links;
+               return $this;
+       }
+
+       /**
+        * 
+        * @return PayPal\Api\Links
+        */
+       public function getLinks() {
+               return $this->links;
+       }
+
+
+
+       public function create($apiContext = null) {
+               $payLoad = $this->toJSON();
+               if ($apiContext == null) {
+                       $apiContext = new ApiContext(self::$credential);
+               }
+               $call = new PPRestCall($apiContext);
+               $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/payment", "POST", $payLoad);
+               $this->fromJson($json);
+               return $this;
+       }
+
+       public static function get($paymentId, $apiContext = null) {
+               if (($paymentId == null) || (strlen($paymentId) <= 0)) {
+                       throw new \InvalidArgumentException("paymentId cannot be null or empty");
+               }
+               $payLoad = "";
+               if ($apiContext == null) {
+                       $apiContext = new ApiContext(self::$credential);
+               }
+               $call = new PPRestCall($apiContext);
+               $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/payment/$paymentId", "GET", $payLoad);
+               $ret = new Payment();
+               $ret->fromJson($json);
+               return $ret;
+       }
+
+       public function execute($paymentExecution, $apiContext = null) {
+               if ($this->getId() == null) {
+                       throw new \InvalidArgumentException("Id cannot be null");
+               }
+               if (($paymentExecution == null)) {
+                       throw new \InvalidArgumentException("paymentExecution cannot be null or empty");
+               }
+               $payLoad = $paymentExecution->toJSON();
+               if ($apiContext == null) {
+                       $apiContext = new ApiContext(self::$credential);
+               }
+               $call = new PPRestCall($apiContext);
+               $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/payment/{$this->getId()}/execute", "POST", $payLoad);
+               $ret = new Payment();
+               $ret->fromJson($json);
+               return $ret;
+       }
+
+       public static function all($params, $apiContext = null) {
+               if (($params == null)) {
+                       throw new \InvalidArgumentException("params cannot be null or empty");
+               }
+               $payLoad = "";
+               $allowedParams = array('count' => 1, 'start_id' => 1, 'start_index' => 1, 'start_time' => 1, 'end_time' => 1, 'payee_id' => 1, 'sort_by' => 1, 'sort_order' => 1, );
+               if ($apiContext == null) {
+                       $apiContext = new ApiContext(self::$credential);
+               }
+               $call = new PPRestCall($apiContext);
+               $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/payment?" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad);
+               $ret = new PaymentHistory();
+               $ret->fromJson($json);
+               return $ret;
+       }
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/PaymentExecution.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/PaymentExecution.php
new file mode 100644 (file)
index 0000000..b7048eb
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+
+class PaymentExecution extends PPModel {
+       /**
+        * PayPal assigned Payer ID returned in the approval return url.
+        * @param string $payer_id
+        */
+       public function setPayerId($payer_id) {
+               $this->payer_id = $payer_id;
+               return $this;
+       }
+
+       /**
+        * PayPal assigned Payer ID returned in the approval return url.
+        * @return string
+        */
+       public function getPayerId() {
+               return $this->payer_id;
+       }
+
+       /**
+        * PayPal assigned Payer ID returned in the approval return url.
+        * @param string $payer_id
+        * @deprecated. Instead use setPayerId
+        */
+       public function setPayer_id($payer_id) {
+               $this->payer_id = $payer_id;
+               return $this;
+       }
+       /**
+        * PayPal assigned Payer ID returned in the approval return url.
+        * @return string
+        * @deprecated. Instead use getPayerId
+        */
+       public function getPayer_id() {
+               return $this->payer_id;
+       }
+
+       /**
+        * If the amount needs to be updated after obtaining the PayPal Payer info (eg. shipping address), it can be updated using this element.
+        * @array
+        * @param PayPal\Api\Transactions $transactions
+        */
+       public function setTransactions($transactions) {
+               $this->transactions = $transactions;
+               return $this;
+       }
+
+       /**
+        * If the amount needs to be updated after obtaining the PayPal Payer info (eg. shipping address), it can be updated using this element.
+        * @return PayPal\Api\Transactions
+        */
+       public function getTransactions() {
+               return $this->transactions;
+       }
+
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/PaymentHistory.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/PaymentHistory.php
new file mode 100644 (file)
index 0000000..e9f28af
--- /dev/null
@@ -0,0 +1,79 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+
+class PaymentHistory extends PPModel {
+       /**
+        * A list of Payment resources
+        * @array
+        * @param PayPal\Api\Payment $payments
+        */
+       public function setPayments($payments) {
+               $this->payments = $payments;
+               return $this;
+       }
+
+       /**
+        * A list of Payment resources
+        * @return PayPal\Api\Payment
+        */
+       public function getPayments() {
+               return $this->payments;
+       }
+
+
+       /**
+        * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items.
+        * @param integer $count
+        */
+       public function setCount($count) {
+               $this->count = $count;
+               return $this;
+       }
+
+       /**
+        * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items.
+        * @return integer
+        */
+       public function getCount() {
+               return $this->count;
+       }
+
+
+       /**
+        * Identifier of the next element to get the next range of results.
+        * @param string $next_id
+        */
+       public function setNextId($next_id) {
+               $this->next_id = $next_id;
+               return $this;
+       }
+
+       /**
+        * Identifier of the next element to get the next range of results.
+        * @return string
+        */
+       public function getNextId() {
+               return $this->next_id;
+       }
+
+       /**
+        * Identifier of the next element to get the next range of results.
+        * @param string $next_id
+        * @deprecated. Instead use setNextId
+        */
+       public function setNext_id($next_id) {
+               $this->next_id = $next_id;
+               return $this;
+       }
+       /**
+        * Identifier of the next element to get the next range of results.
+        * @return string
+        * @deprecated. Instead use getNextId
+        */
+       public function getNext_id() {
+               return $this->next_id;
+       }
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/RedirectUrls.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/RedirectUrls.php
new file mode 100644 (file)
index 0000000..c954b49
--- /dev/null
@@ -0,0 +1,77 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+
+class RedirectUrls extends PPModel {
+       /**
+        * Url where the payer would be redirected to after approving the payment.
+        * @param string $return_url
+        */
+       public function setReturnUrl($return_url) {
+               $this->return_url = $return_url;
+               return $this;
+       }
+
+       /**
+        * Url where the payer would be redirected to after approving the payment.
+        * @return string
+        */
+       public function getReturnUrl() {
+               return $this->return_url;
+       }
+
+       /**
+        * Url where the payer would be redirected to after approving the payment.
+        * @param string $return_url
+        * @deprecated. Instead use setReturnUrl
+        */
+       public function setReturn_url($return_url) {
+               $this->return_url = $return_url;
+               return $this;
+       }
+       /**
+        * Url where the payer would be redirected to after approving the payment.
+        * @return string
+        * @deprecated. Instead use getReturnUrl
+        */
+       public function getReturn_url() {
+               return $this->return_url;
+       }
+
+       /**
+        * Url where the payer would be redirected to after canceling the payment.
+        * @param string $cancel_url
+        */
+       public function setCancelUrl($cancel_url) {
+               $this->cancel_url = $cancel_url;
+               return $this;
+       }
+
+       /**
+        * Url where the payer would be redirected to after canceling the payment.
+        * @return string
+        */
+       public function getCancelUrl() {
+               return $this->cancel_url;
+       }
+
+       /**
+        * Url where the payer would be redirected to after canceling the payment.
+        * @param string $cancel_url
+        * @deprecated. Instead use setCancelUrl
+        */
+       public function setCancel_url($cancel_url) {
+               $this->cancel_url = $cancel_url;
+               return $this;
+       }
+       /**
+        * Url where the payer would be redirected to after canceling the payment.
+        * @return string
+        * @deprecated. Instead use getCancelUrl
+        */
+       public function getCancel_url() {
+               return $this->cancel_url;
+       }
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Refund.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Refund.php
new file mode 100644 (file)
index 0000000..095200a
--- /dev/null
@@ -0,0 +1,251 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+use PayPal\Rest\IResource;
+use PayPal\Rest\Call;
+use PayPal\Rest\ApiContext;
+use PayPal\Api\Refund;
+use PayPal\Transport\PPRestCall;
+
+class Refund extends PPModel implements IResource {
+
+       private static $credential;
+
+       /**
+        *
+        * @deprecated. Pass ApiContext to create/get methods instead
+        */
+       public static function setCredential($credential) {
+               self::$credential = $credential;
+       }
+
+       /**
+        * Identifier of the refund transaction.
+        * @param string $id
+        */
+       public function setId($id) {
+               $this->id = $id;
+               return $this;
+       }
+
+       /**
+        * Identifier of the refund transaction.
+        * @return string
+        */
+       public function getId() {
+               return $this->id;
+       }
+
+
+       /**
+        * Time the resource was created.
+        * @param string $create_time
+        */
+       public function setCreateTime($create_time) {
+               $this->create_time = $create_time;
+               return $this;
+       }
+
+       /**
+        * Time the resource was created.
+        * @return string
+        */
+       public function getCreateTime() {
+               return $this->create_time;
+       }
+
+       /**
+        * Time the resource was created.
+        * @param string $create_time
+        * @deprecated. Instead use setCreateTime
+        */
+       public function setCreate_time($create_time) {
+               $this->create_time = $create_time;
+               return $this;
+       }
+       /**
+        * Time the resource was created.
+        * @return string
+        * @deprecated. Instead use getCreateTime
+        */
+       public function getCreate_time() {
+               return $this->create_time;
+       }
+
+       /**
+        * Details including both refunded amount (to Payer) and refunded fee (to Payee).If amount is not specified, it's assumed to be full refund.
+        * @param PayPal\Api\Amount $amount
+        */
+       public function setAmount($amount) {
+               $this->amount = $amount;
+               return $this;
+       }
+
+       /**
+        * Details including both refunded amount (to Payer) and refunded fee (to Payee).If amount is not specified, it's assumed to be full refund.
+        * @return PayPal\Api\Amount
+        */
+       public function getAmount() {
+               return $this->amount;
+       }
+
+
+       /**
+        * State of the refund transaction.
+        * @param string $state
+        */
+       public function setState($state) {
+               $this->state = $state;
+               return $this;
+       }
+
+       /**
+        * State of the refund transaction.
+        * @return string
+        */
+       public function getState() {
+               return $this->state;
+       }
+
+
+       /**
+        * ID of the Sale transaction being refunded. 
+        * @param string $sale_id
+        */
+       public function setSaleId($sale_id) {
+               $this->sale_id = $sale_id;
+               return $this;
+       }
+
+       /**
+        * ID of the Sale transaction being refunded. 
+        * @return string
+        */
+       public function getSaleId() {
+               return $this->sale_id;
+       }
+
+       /**
+        * ID of the Sale transaction being refunded. 
+        * @param string $sale_id
+        * @deprecated. Instead use setSaleId
+        */
+       public function setSale_id($sale_id) {
+               $this->sale_id = $sale_id;
+               return $this;
+       }
+       /**
+        * ID of the Sale transaction being refunded. 
+        * @return string
+        * @deprecated. Instead use getSaleId
+        */
+       public function getSale_id() {
+               return $this->sale_id;
+       }
+
+       /**
+        * ID of the Capture transaction being refunded. 
+        * @param string $capture_id
+        */
+       public function setCaptureId($capture_id) {
+               $this->capture_id = $capture_id;
+               return $this;
+       }
+
+       /**
+        * ID of the Capture transaction being refunded. 
+        * @return string
+        */
+       public function getCaptureId() {
+               return $this->capture_id;
+       }
+
+       /**
+        * ID of the Capture transaction being refunded. 
+        * @param string $capture_id
+        * @deprecated. Instead use setCaptureId
+        */
+       public function setCapture_id($capture_id) {
+               $this->capture_id = $capture_id;
+               return $this;
+       }
+       /**
+        * ID of the Capture transaction being refunded. 
+        * @return string
+        * @deprecated. Instead use getCaptureId
+        */
+       public function getCapture_id() {
+               return $this->capture_id;
+       }
+
+       /**
+        * ID of the Payment resource that this transaction is based on.
+        * @param string $parent_payment
+        */
+       public function setParentPayment($parent_payment) {
+               $this->parent_payment = $parent_payment;
+               return $this;
+       }
+
+       /**
+        * ID of the Payment resource that this transaction is based on.
+        * @return string
+        */
+       public function getParentPayment() {
+               return $this->parent_payment;
+       }
+
+       /**
+        * ID of the Payment resource that this transaction is based on.
+        * @param string $parent_payment
+        * @deprecated. Instead use setParentPayment
+        */
+       public function setParent_payment($parent_payment) {
+               $this->parent_payment = $parent_payment;
+               return $this;
+       }
+       /**
+        * ID of the Payment resource that this transaction is based on.
+        * @return string
+        * @deprecated. Instead use getParentPayment
+        */
+       public function getParent_payment() {
+               return $this->parent_payment;
+       }
+
+       /**
+        * 
+        * @array
+        * @param PayPal\Api\Links $links
+        */
+       public function setLinks($links) {
+               $this->links = $links;
+               return $this;
+       }
+
+       /**
+        * 
+        * @return PayPal\Api\Links
+        */
+       public function getLinks() {
+               return $this->links;
+       }
+
+
+
+       public static function get($refundId, $apiContext = null) {
+               if (($refundId == null) || (strlen($refundId) <= 0)) {
+                       throw new \InvalidArgumentException("refundId cannot be null or empty");
+               }
+               $payLoad = "";
+               if ($apiContext == null) {
+                       $apiContext = new ApiContext(self::$credential);
+               }
+               $call = new PPRestCall($apiContext);
+               $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/refund/$refundId", "GET", $payLoad);
+               $ret = new Refund();
+               $ret->fromJson($json);
+               return $ret;
+       }
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/RelatedResources.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/RelatedResources.php
new file mode 100644 (file)
index 0000000..7e97776
--- /dev/null
@@ -0,0 +1,79 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+
+class RelatedResources extends PPModel {
+       /**
+        * A sale transaction
+        * @param PayPal\Api\Sale $sale
+        */
+       public function setSale($sale) {
+               $this->sale = $sale;
+               return $this;
+       }
+
+       /**
+        * A sale transaction
+        * @return PayPal\Api\Sale
+        */
+       public function getSale() {
+               return $this->sale;
+       }
+
+
+       /**
+        * An authorization transaction
+        * @param PayPal\Api\Authorization $authorization
+        */
+       public function setAuthorization($authorization) {
+               $this->authorization = $authorization;
+               return $this;
+       }
+
+       /**
+        * An authorization transaction
+        * @return PayPal\Api\Authorization
+        */
+       public function getAuthorization() {
+               return $this->authorization;
+       }
+
+
+       /**
+        * A capture transaction
+        * @param PayPal\Api\Capture $capture
+        */
+       public function setCapture($capture) {
+               $this->capture = $capture;
+               return $this;
+       }
+
+       /**
+        * A capture transaction
+        * @return PayPal\Api\Capture
+        */
+       public function getCapture() {
+               return $this->capture;
+       }
+
+
+       /**
+        * A refund transaction
+        * @param PayPal\Api\Refund $refund
+        */
+       public function setRefund($refund) {
+               $this->refund = $refund;
+               return $this;
+       }
+
+       /**
+        * A refund transaction
+        * @return PayPal\Api\Refund
+        */
+       public function getRefund() {
+               return $this->refund;
+       }
+
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Sale.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Sale.php
new file mode 100644 (file)
index 0000000..5fb1284
--- /dev/null
@@ -0,0 +1,235 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+use PayPal\Rest\IResource;
+use PayPal\Rest\Call;
+use PayPal\Rest\ApiContext;
+use PayPal\Api\Sale;
+use PayPal\Api\Refund;
+use PayPal\Transport\PPRestCall;
+
+class Sale extends PPModel implements IResource {
+
+       private static $credential;
+
+       /**
+        *
+        * @deprecated. Pass ApiContext to create/get methods instead
+        */
+       public static function setCredential($credential) {
+               self::$credential = $credential;
+       }
+
+       /**
+        * Identifier of the authorization transaction.
+        * @param string $id
+        */
+       public function setId($id) {
+               $this->id = $id;
+               return $this;
+       }
+
+       /**
+        * Identifier of the authorization transaction.
+        * @return string
+        */
+       public function getId() {
+               return $this->id;
+       }
+
+
+       /**
+        * Time the resource was created.
+        * @param string $create_time
+        */
+       public function setCreateTime($create_time) {
+               $this->create_time = $create_time;
+               return $this;
+       }
+
+       /**
+        * Time the resource was created.
+        * @return string
+        */
+       public function getCreateTime() {
+               return $this->create_time;
+       }
+
+       /**
+        * Time the resource was created.
+        * @param string $create_time
+        * @deprecated. Instead use setCreateTime
+        */
+       public function setCreate_time($create_time) {
+               $this->create_time = $create_time;
+               return $this;
+       }
+       /**
+        * Time the resource was created.
+        * @return string
+        * @deprecated. Instead use getCreateTime
+        */
+       public function getCreate_time() {
+               return $this->create_time;
+       }
+
+       /**
+        * Time the resource was last updated.
+        * @param string $update_time
+        */
+       public function setUpdateTime($update_time) {
+               $this->update_time = $update_time;
+               return $this;
+       }
+
+       /**
+        * Time the resource was last updated.
+        * @return string
+        */
+       public function getUpdateTime() {
+               return $this->update_time;
+       }
+
+       /**
+        * Time the resource was last updated.
+        * @param string $update_time
+        * @deprecated. Instead use setUpdateTime
+        */
+       public function setUpdate_time($update_time) {
+               $this->update_time = $update_time;
+               return $this;
+       }
+       /**
+        * Time the resource was last updated.
+        * @return string
+        * @deprecated. Instead use getUpdateTime
+        */
+       public function getUpdate_time() {
+               return $this->update_time;
+       }
+
+       /**
+        * Amount being collected.
+        * @param PayPal\Api\Amount $amount
+        */
+       public function setAmount($amount) {
+               $this->amount = $amount;
+               return $this;
+       }
+
+       /**
+        * Amount being collected.
+        * @return PayPal\Api\Amount
+        */
+       public function getAmount() {
+               return $this->amount;
+       }
+
+
+       /**
+        * State of the sale transaction.
+        * @param string $state
+        */
+       public function setState($state) {
+               $this->state = $state;
+               return $this;
+       }
+
+       /**
+        * State of the sale transaction.
+        * @return string
+        */
+       public function getState() {
+               return $this->state;
+       }
+
+
+       /**
+        * ID of the Payment resource that this transaction is based on.
+        * @param string $parent_payment
+        */
+       public function setParentPayment($parent_payment) {
+               $this->parent_payment = $parent_payment;
+               return $this;
+       }
+
+       /**
+        * ID of the Payment resource that this transaction is based on.
+        * @return string
+        */
+       public function getParentPayment() {
+               return $this->parent_payment;
+       }
+
+       /**
+        * ID of the Payment resource that this transaction is based on.
+        * @param string $parent_payment
+        * @deprecated. Instead use setParentPayment
+        */
+       public function setParent_payment($parent_payment) {
+               $this->parent_payment = $parent_payment;
+               return $this;
+       }
+       /**
+        * ID of the Payment resource that this transaction is based on.
+        * @return string
+        * @deprecated. Instead use getParentPayment
+        */
+       public function getParent_payment() {
+               return $this->parent_payment;
+       }
+
+       /**
+        * 
+        * @array
+        * @param PayPal\Api\Links $links
+        */
+       public function setLinks($links) {
+               $this->links = $links;
+               return $this;
+       }
+
+       /**
+        * 
+        * @return PayPal\Api\Links
+        */
+       public function getLinks() {
+               return $this->links;
+       }
+
+
+
+       public static function get($saleId, $apiContext = null) {
+               if (($saleId == null) || (strlen($saleId) <= 0)) {
+                       throw new \InvalidArgumentException("saleId cannot be null or empty");
+               }
+               $payLoad = "";
+               if ($apiContext == null) {
+                       $apiContext = new ApiContext(self::$credential);
+               }
+               $call = new PPRestCall($apiContext);
+               $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/sale/$saleId", "GET", $payLoad);
+               $ret = new Sale();
+               $ret->fromJson($json);
+               return $ret;
+       }
+
+       public function refund($refund, $apiContext = null) {
+               if ($this->getId() == null) {
+                       throw new \InvalidArgumentException("Id cannot be null");
+               }
+               if (($refund == null)) {
+                       throw new \InvalidArgumentException("refund cannot be null or empty");
+               }
+               $payLoad = $refund->toJSON();
+               if ($apiContext == null) {
+                       $apiContext = new ApiContext(self::$credential);
+               }
+               $call = new PPRestCall($apiContext);
+               $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/sale/{$this->getId()}/refund", "POST", $payLoad);
+               $ret = new Refund();
+               $ret->fromJson($json);
+               return $ret;
+       }
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/ShippingAddress.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/ShippingAddress.php
new file mode 100644 (file)
index 0000000..a7f4de9
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+
+class ShippingAddress extends Address {
+       /**
+        * Name of the recipient at this address.
+        * @param string $recipient_name
+        */
+       public function setRecipientName($recipient_name) {
+               $this->recipient_name = $recipient_name;
+               return $this;
+       }
+
+       /**
+        * Name of the recipient at this address.
+        * @return string
+        */
+       public function getRecipientName() {
+               return $this->recipient_name;
+       }
+
+       /**
+        * Name of the recipient at this address.
+        * @param string $recipient_name
+        * @deprecated. Instead use setRecipientName
+        */
+       public function setRecipient_name($recipient_name) {
+               $this->recipient_name = $recipient_name;
+               return $this;
+       }
+       /**
+        * Name of the recipient at this address.
+        * @return string
+        * @deprecated. Instead use getRecipientName
+        */
+       public function getRecipient_name() {
+               return $this->recipient_name;
+       }
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Transaction.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Transaction.php
new file mode 100644 (file)
index 0000000..d8420aa
--- /dev/null
@@ -0,0 +1,152 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+
+class Transaction extends PPModel {
+       /**
+        * Amount being collected.
+        * @param PayPal\Api\Amount $amount
+        */
+       public function setAmount($amount) {
+               $this->amount = $amount;
+               return $this;
+       }
+
+       /**
+        * Amount being collected.
+        * @return PayPal\Api\Amount
+        */
+       public function getAmount() {
+               return $this->amount;
+       }
+
+
+       /**
+        * Recepient of the funds in this transaction.
+        * @param PayPal\Api\Payee $payee
+        */
+       public function setPayee($payee) {
+               $this->payee = $payee;
+               return $this;
+       }
+
+       /**
+        * Recepient of the funds in this transaction.
+        * @return PayPal\Api\Payee
+        */
+       public function getPayee() {
+               return $this->payee;
+       }
+
+
+       /**
+        * Description of what is being paid for.
+        * @param string $description
+        */
+       public function setDescription($description) {
+               $this->description = $description;
+               return $this;
+       }
+
+       /**
+        * Description of what is being paid for.
+        * @return string
+        */
+       public function getDescription() {
+               return $this->description;
+       }
+
+
+       /**
+        * List of items being paid for.
+        * @param PayPal\Api\ItemList $item_list
+        */
+       public function setItemList($item_list) {
+               $this->item_list = $item_list;
+               return $this;
+       }
+
+       /**
+        * List of items being paid for.
+        * @return PayPal\Api\ItemList
+        */
+       public function getItemList() {
+               return $this->item_list;
+       }
+
+       /**
+        * List of items being paid for.
+        * @param PayPal\Api\ItemList $item_list
+        * @deprecated. Instead use setItemList
+        */
+       public function setItem_list($item_list) {
+               $this->item_list = $item_list;
+               return $this;
+       }
+       /**
+        * List of items being paid for.
+        * @return PayPal\Api\ItemList
+        * @deprecated. Instead use getItemList
+        */
+       public function getItem_list() {
+               return $this->item_list;
+       }
+
+       /**
+        * List of financial transactions (Sale, Authorization, Capture, Refund) related to the payment.
+        * @array
+        * @param PayPal\Api\RelatedResources $related_resources
+        */
+       public function setRelatedResources($related_resources) {
+               $this->related_resources = $related_resources;
+               return $this;
+       }
+
+       /**
+        * List of financial transactions (Sale, Authorization, Capture, Refund) related to the payment.
+        * @return PayPal\Api\RelatedResources
+        */
+       public function getRelatedResources() {
+               return $this->related_resources;
+       }
+
+       /**
+        * List of financial transactions (Sale, Authorization, Capture, Refund) related to the payment.
+        * @array
+        * @param PayPal\Api\RelatedResources $related_resources
+        * @deprecated. Instead use setRelatedResources
+        */
+       public function setRelated_resources($related_resources) {
+               $this->related_resources = $related_resources;
+               return $this;
+       }
+       /**
+        * List of financial transactions (Sale, Authorization, Capture, Refund) related to the payment.
+        * @return PayPal\Api\RelatedResources
+        * @deprecated. Instead use getRelatedResources
+        */
+       public function getRelated_resources() {
+               return $this->related_resources;
+       }
+
+       /**
+        * Additional transactions for complex payment (Parallel and Chained) scenarios.
+        * @array
+        * @param PayPal\Api\self $transactions
+        */
+       public function setTransactions($transactions) {
+               $this->transactions = $transactions;
+               return $this;
+       }
+
+       /**
+        * Additional transactions for complex payment (Parallel and Chained) scenarios.
+        * @return PayPal\Api\self
+        */
+       public function getTransactions() {
+               return $this->transactions;
+       }
+
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Transactions.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Transactions.php
new file mode 100644 (file)
index 0000000..2219837
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+namespace PayPal\Api;
+
+use PayPal\Common\PPModel;
+
+class Transactions extends PPModel {
+       /**
+        * Amount being collected.
+        * @param PayPal\Api\Amount $amount
+        */
+       public function setAmount($amount) {
+               $this->amount = $amount;
+               return $this;
+       }
+
+       /**
+        * Amount being collected.
+        * @return PayPal\Api\Amount
+        */
+       public function getAmount() {
+               return $this->amount;
+       }
+
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Auth/OAuthTokenCredential.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Auth/OAuthTokenCredential.php
new file mode 100644 (file)
index 0000000..1eeac13
--- /dev/null
@@ -0,0 +1,137 @@
+<?php
+
+namespace PayPal\Auth;
+
+/**
+ * Oauth Token credential
+ *
+ */
+use PayPal\Rest\RestHandler;
+use PayPal\Common\PPUserAgent;
+use PayPal\Core\PPLoggingManager;
+use PayPal\Core\PPConstants;
+use PayPal\Core\PPHttpConfig;
+use PayPal\Core\PPConnectionManager;
+use PayPal\Exception\PPConfigurationException;
+
+class OAuthTokenCredential {
+       
+       private static $expiryBufferTime = 120;
+       
+       private $logger;
+       
+       /**
+        * Client ID as obtained from the developer portal
+        */
+       private $clientId;
+       
+       /**
+        * Client secret as obtained from the developer portal
+        */
+       private $clientSecret;
+       
+       
+       /**
+        * Generated Access Token
+        */
+       private $accessToken;   
+       
+       /**
+        * Seconds for with access token is valid
+        */
+       private $tokenExpiresIn;
+       
+       /**
+        * Last time (in milliseconds) when access token was generated
+        */
+       private $tokenCreateTime;
+       
+       /**
+        * 
+        * @param string $clientId client id obtained from the developer portal
+        * @param string $clientSecret client secret obtained from the developer portal
+        */
+       public function __construct($clientId, $clientSecret) {
+               $this->clientId = $clientId;
+               $this->clientSecret = $clientSecret;            
+       }
+       
+       /**
+        * @return the accessToken
+        */
+       public function getAccessToken($config) {
+
+               $this->logger = new PPLoggingManager(__CLASS__, $config);
+               // Check if Access Token is not null and has not expired.
+               // The API returns expiry time as a relative time unit 
+               // We use a buffer time when checking for token expiry to account
+               // for API call delays and any delay between the time the token is
+               // retrieved and subsequently used
+               if ($this->accessToken != null && 
+                               (time() - $this->tokenCreateTime) > ($this->tokenExpiresIn - self::$expiryBufferTime)) {                        
+                               $this->accessToken = null;                      
+               }
+               // If accessToken is Null, obtain a new token
+               if ($this->accessToken == null) {                       
+                       $this->_generateAccessToken($config);
+               }
+               return $this->accessToken;
+       }
+       
+       /**
+        * Generates a new access token
+        */
+       private function _generateAccessToken($config) {
+
+               $base64ClientID = base64_encode($this->clientId . ":" . $this->clientSecret);                                                   
+               $headers = array(
+                       "User-Agent" => PPUserAgent::getValue(RestHandler::$sdkName, RestHandler::$sdkVersion), 
+                       "Authorization" => "Basic " . $base64ClientID,
+                       "Accept" => "*/*"
+               );              
+               $httpConfiguration = $this->getOAuthHttpConfiguration($config);
+               $httpConfiguration->setHeaders($headers);
+               
+               $connection = PPConnectionManager::getInstance()->getConnection($httpConfiguration, $config);           
+               $res = $connection->execute("grant_type=client_credentials");           
+               $jsonResponse = json_decode($res, true);
+               if($jsonResponse == NULL || 
+                               !isset($jsonResponse["access_token"]) || !isset($jsonResponse["expires_in"]) ) {
+                       $this->accessToken = NULL;
+                       $this->tokenExpiresIn = NULL;   
+                       $this->logger->warning("Could not generate new Access token. Invalid response from server: " . $jsonResponse);          
+               } else {
+                       $this->accessToken = $jsonResponse["access_token"];
+                       $this->tokenExpiresIn = $jsonResponse["expires_in"];
+               }
+               $this->tokenCreateTime = time();
+               return $this->accessToken;
+       }
+       
+       /*
+        * Get HttpConfiguration object for OAuth API
+       */
+       private function getOAuthHttpConfiguration($config) {
+               if (isset($config['oauth.EndPoint'])) {
+                       $baseEndpoint = $config['oauth.EndPoint'];
+               } else if (isset($config['service.EndPoint'])) {
+                       $baseEndpoint = $config['service.EndPoint'];
+               } else if (isset($config['mode'])) {
+                       switch (strtoupper($config['mode'])) {
+                               case 'SANDBOX':
+                                       $baseEndpoint = PPConstants::REST_SANDBOX_ENDPOINT;
+                                       break;
+                               case 'LIVE':
+                                       $baseEndpoint = PPConstants::REST_LIVE_ENDPOINT;
+                                       break;
+                               default:
+                                       throw new PPConfigurationException('The mode config parameter must be set to either sandbox/live');
+                       }
+               } else {
+                       throw new PPConfigurationException('You must set one of service.endpoint or mode parameters in your configuration');
+               }               
+               
+               $baseEndpoint = rtrim(trim($baseEndpoint), '/');                 
+               return new PPHttpConfig($baseEndpoint . "/v1/oauth2/token", "POST");
+       }
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Rest/ApiContext.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Rest/ApiContext.php
new file mode 100755 (executable)
index 0000000..e0d8df3
--- /dev/null
@@ -0,0 +1,78 @@
+<?php
+namespace PayPal\Rest;
+
+use PayPal\Common\PPApiContext;
+
+echo "ADASDASD";
+/**
+ * 
+ * Call level parameters such as
+ * request id, credentials etc
+ */
+class ApiContext extends PPApiContext {
+       
+       /**
+        * OAuth Credentials to use for this call
+        * @var PayPal/Api/OAuthTokenCredential
+        */
+       private $credential;
+       
+       /**
+        * Unique request id to be used for this call
+        * The user can either generate one as per application
+        * needs or let the SDK generate one
+        * @var string
+        */
+       private $requestId;
+       
+       /**
+        * 
+        */
+       public function getCredential() {
+               return $this->credential;               
+       }
+       
+       public function getrequestId() {
+               if($this->requestId == null) {
+                       $this->requestId = $this->generateRequestId();
+               }
+               return $this->requestId;
+       }
+       
+       
+       /**
+        * 
+        * @param PayPal/Api/OAuthTokenCredential $credential
+        * @param string $requestId
+        */
+       public function __construct($credential, $requestId=null) {
+               $this->credential = $credential;
+               $this->requestId = $requestId;
+       }
+       
+       /**
+        * Generates a unique per request id that
+        * can be used to set the PayPal-Request-Id header
+        * that is used for idemptency
+        * @return string
+        */
+       private function generateRequestId() {
+               
+               static $pid = -1;
+               static $addr = -1;
+               
+               if ($pid == -1) {
+                       $pid = getmypid();
+               }
+               if ($addr == -1) {
+                       if(array_key_exists('SERVER_ADDR', $_SERVER)) {
+                               $addr = ip2long($_SERVER['SERVER_ADDR']);
+                       } else {
+                               $addr  = php_uname('n');
+                       }
+               }
+               
+               return $addr . $pid . $_SERVER['REQUEST_TIME'] . mt_rand(0, 0xffff);
+       }
+}
+echo "kkkkk";
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Rest/IResource.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Rest/IResource.php
new file mode 100644 (file)
index 0000000..395586c
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+
+namespace PayPal\Rest;
+
+interface IResource {
+       
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Rest/RestHandler.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Rest/RestHandler.php
new file mode 100644 (file)
index 0000000..b7fcade
--- /dev/null
@@ -0,0 +1,84 @@
+<?php
+namespace PayPal\Rest;
+
+use PayPal\Auth\OAuthTokenCredential;
+use PayPal\Handler\IPPHandler;
+use PayPal\Core\PPCredentialManager;
+use PayPal\Core\PPConstants;
+use PayPal\Exception\PPMissingCredentialException;
+use PayPal\Exception\PPInvalidCredentialException;
+use PayPal\Exception\PPConfigurationException;
+use PayPal\Common\PPUserAgent;
+
+/**
+ * 
+ * API handler for all REST API calls
+ */
+class RestHandler implements IPPHandler {
+
+       private $apiContext;
+       
+       public static $sdkName = "rest-sdk-php";        
+       public static $sdkVersion = "0.6.0";
+       
+       public function __construct($apiContext) {
+               $this->apiContext = $apiContext;
+       }
+       
+       public function handle($httpConfig, $request, $options) {
+               
+               $credential = $this->apiContext->getCredential();
+               $config = $this->apiContext->getConfig();
+               
+               if($credential == NULL) {
+                       // Try picking credentials from the config file
+                       $credMgr = PPCredentialManager::getInstance($config);
+                       $credValues = $credMgr->getCredentialObject();
+                       if(!is_array($credValues)) {
+                               throw new PPMissingCredentialException("Empty or invalid credentials passed");
+                       }
+                       $credential = new OAuthTokenCredential($credValues['clientId'], $credValues['clientSecret']);
+               }
+               if($credential == NULL || ! ($credential instanceof OAuthTokenCredential) ) {
+                       throw new PPInvalidCredentialException("Invalid credentials passed");
+               }
+
+               
+               $httpConfig->setUrl(
+                       rtrim( trim($this->_getEndpoint($config)), '/') . 
+                               (isset($options['path']) ? $options['path'] : '')
+               );
+               
+               if(!array_key_exists("User-Agent", $httpConfig->getHeaders())) {
+                       $httpConfig->addHeader("User-Agent", PPUserAgent::getValue(self::$sdkName, self::$sdkVersion));
+               }               
+               if(!is_null($credential) && $credential instanceof OAuthTokenCredential) {
+                       $httpConfig->addHeader('Authorization', "Bearer " . $credential->getAccessToken($config));
+               }
+               if($httpConfig->getMethod() == 'POST' || $httpConfig->getMethod() == 'PUT') {
+                       $httpConfig->addHeader('PayPal-Request-Id', $this->apiContext->getRequestId());
+               }
+               
+       }
+       
+       private function _getEndpoint($config) {
+               if (isset($config['service.EndPoint'])) {
+                       return $config['service.EndPoint'];
+               } else if (isset($config['mode'])) {
+                       switch (strtoupper($config['mode'])) {
+                               case 'SANDBOX':
+                                       return PPConstants::REST_SANDBOX_ENDPOINT;
+                                       break;
+                               case 'LIVE':
+                                       return PPConstants::REST_LIVE_ENDPOINT;
+                                       break;
+                               default:
+                                       throw new PPConfigurationException('The mode config parameter must be set to either sandbox/live');
+                                       break;
+                       }
+               } else {
+                       throw new PPConfigurationException('You must set one of service.endpoint or mode parameters in your configuration');
+               }
+       }
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/phpunit.xml b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/phpunit.xml
new file mode 100644 (file)
index 0000000..d8063ef
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<phpunit bootstrap="./tests/bootstrap.php"
+         colors="true"
+         processIsolation="false"
+         stopOnFailure="false"
+         syntaxCheck="false"
+         convertErrorsToExceptions="true"
+         convertNoticesToExceptions="true"
+         convertWarningsToExceptions="true"
+         testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader">
+
+    <testsuites>
+        <testsuite name="All">
+            <directory>tests</directory>
+        </testsuite>
+    </testsuites>
+
+    <logging>
+        <log type="junit" target="build/junit.xml" logIncompleteSkipped="false" />
+    </logging>
+
+    <filter>
+        <whitelist>
+            <directory suffix=".php">./lib</directory>
+            <exclude>
+            </exclude>
+        </whitelist>
+    </filter>
+</phpunit>
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/AddressTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/AddressTest.php
new file mode 100644 (file)
index 0000000..ec271c9
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+namespace PayPal\Test\Api;
+
+use PayPal\Api\Address;
+use PayPal\Test\Constants;
+
+class AddressTest extends \PHPUnit_Framework_TestCase {
+
+       private $address;
+
+       public static $line1 = "3909 Witmer Road";
+       public static $line2 = "Niagara Falls"; 
+       public static $city = "Niagara Falls";
+       public static $state = "NY";
+       public static $postalCode = "14305";
+       public static $countryCode = "US";
+       public static $phone = "716-298-1822";
+       public static $type = "Billing";
+
+       public static function createAddress() {
+               $addr = new Address();
+               $addr->setLine1(self::$line1);
+               $addr->setLine2(self::$line2);
+               $addr->setCity(self::$city);
+               $addr->setState(self::$state);
+               $addr->setPostalCode(self::$postalCode);
+               $addr->setCountryCode(self::$countryCode);
+               $addr->setPhone(self::$phone);
+               return $addr;
+       }
+       
+       public function setup() {
+               $this->address = self::createAddress();
+       }
+
+       public function testGetterSetter() {
+               $this->assertEquals(self::$line1, $this->address->getLine1());
+               $this->assertEquals(self::$line2, $this->address->getLine2());
+               $this->assertEquals(self::$city, $this->address->getCity());
+               $this->assertEquals(self::$state, $this->address->getState());
+               $this->assertEquals(self::$postalCode, $this->address->getPostalCode());
+               $this->assertEquals(self::$countryCode, $this->address->getCountryCode());
+               $this->assertEquals(self::$phone, $this->address->getPhone());
+       }
+       
+       public function testSerializeDeserialize() {
+               $a1 = $this->address;
+               
+               $a2 = new Address();
+               $a2->fromJson($a1->toJson());
+               
+               $this->assertEquals($a1, $a2);
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/AmountTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/AmountTest.php
new file mode 100644 (file)
index 0000000..7f24e7b
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+
+namespace PayPal\Test\Api;
+
+use PayPal\Api\Amount;
+use PayPal\Test\Constants;
+
+class AmountTest extends \PHPUnit_Framework_TestCase {
+
+       private $amounts;
+
+       public static $currency = "USD";
+       public static $total = "1.12";  
+
+       public static function createAmount() {
+               $amount = new Amount();
+               $amount->setCurrency(self::$currency);
+               $amount->setTotal(self::$total);
+               
+               return $amount;
+       }
+       
+       public function setup() {
+               $this->amounts['partial'] = self::createAmount();
+               
+               $amount = self::createAmount();
+               $amount->setDetails(DetailsTest::createAmountDetails());
+               $this->amounts['full'] = $amount;
+       }
+
+       public function testGetterSetter() {
+               $this->assertEquals(self::$currency, $this->amounts['partial']->getCurrency());
+               $this->assertEquals(self::$total, $this->amounts['partial']->getTotal());
+               $this->assertEquals(DetailsTest::$fee, $this->amounts['full']->getDetails()->getFee());
+       }
+       
+       public function testSerializeDeserialize() {
+               $a1 = $this->amounts['partial'];
+               
+               $a2 = new Amount();
+               $a2->fromJson($a1->toJson());
+               
+               $this->assertEquals($a1, $a2);
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/AuthorizationTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/AuthorizationTest.php
new file mode 100644 (file)
index 0000000..63ba8cb
--- /dev/null
@@ -0,0 +1,156 @@
+<?php
+namespace PayPal\Test\Api;
+
+use PayPal\Api\Amount;
+use PayPal\Api\Authorization;
+use PayPal\Api\Links;
+use PayPal\Test\Constants;
+use PayPal\Api\RedirectUrls;
+use PayPal\Api\Address;
+
+use PayPal\Api\Capture;
+use PayPal\Api\CreditCard;
+use PayPal\Api\Payer;
+use PayPal\Api\Payment;
+use PayPal\Api\FundingInstrument;
+use PayPal\Api\Transaction;
+use PayPal\Exception\PPConnectionException;
+
+class AuthorizationTest extends \PHPUnit_Framework_TestCase {
+       private $authorizations = array();
+       public static $create_time = "2013-02-28T00:00:00Z";
+       public static $id = "AUTH-123";
+       public static $state = "Created";
+       public static $parent_payment = "PAY-12345";
+       public static $currency = "USD";
+       public static $total = "1.12";
+       public static $href = "USD";
+       public static $rel = "1.12";
+       public static $method = "1.12";
+       
+       public static function createAuthorization() {                  
+               $authorization = new Authorization();
+               $authorization->setCreateTime(self::$create_time);
+               $authorization->setId(self::$id);
+               $authorization->setState(self::$state);
+               
+               $authorization->setAmount(AmountTest::createAmount());
+               $authorization->setLinks(array(LinksTest::createLinks()));      
+               
+               return $authorization;
+       }
+       
+       public static function authorize()
+       {
+               $addr = new Address();
+               $addr->setLine1("3909 Witmer Road");
+               $addr->setLine2("Niagara Falls");
+               $addr->setCity("Niagara Falls");
+               $addr->setState("NY");
+               $addr->setPostal_code("14305");
+               $addr->setCountry_code("US");
+               $addr->setPhone("716-298-1822");
+               
+               $card = new CreditCard();
+               $card->setType("visa");
+               $card->setNumber("4417119669820331");
+               $card->setExpire_month("11");
+               $card->setExpire_year("2019");
+               $card->setCvv2("012");
+               $card->setFirst_name("Joe");
+               $card->setLast_name("Shopper");
+               $card->setBilling_address($addr);
+               
+               $fi = new FundingInstrument();
+               $fi->setCredit_card($card);
+               
+               $payer = new Payer();
+               $payer->setPayment_method("credit_card");
+               $payer->setFunding_instruments(array($fi));
+               
+               $amount = new Amount();
+               $amount->setCurrency("USD");
+               $amount->setTotal("1.00");
+               
+               $transaction = new Transaction();
+               $transaction->setAmount($amount);
+               $transaction->setDescription("This is the payment description.");
+               
+               $payment = new Payment();
+               $payment->setIntent("authorize");
+               $payment->setPayer($payer);
+               $payment->setTransactions(array($transaction));
+               
+               $paymnt = $payment->create();
+               $resArray = $paymnt->toArray();
+               
+               return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id'];
+               
+       }
+       public function setup() {
+               $authorization = new Authorization();
+               $authorization->setCreateTime(self::$create_time);
+               $authorization->setId(self::$id);
+               $authorization->setState(self::$state);
+               $authorization->setParentPayment(self::$parent_payment);
+               $this->authorizations['partial'] = $authorization;
+               $this->authorizations['full'] = self::createAuthorization();
+               
+       }
+
+       public function testGetterSetter() {            
+               $authorization = $this->authorizations['partial'];
+               $this->assertEquals(self::$create_time, $authorization->getCreateTime());
+               $this->assertEquals(self::$id, $authorization->getId());
+               $this->assertEquals(self::$state, $authorization->getState());
+               $this->assertEquals(self::$parent_payment, $authorization->getParentPayment());
+               
+               $authorization = $this->authorizations['full'];
+               $this->assertEquals(AmountTest::$currency, $authorization->getAmount()->getCurrency());
+               $this->assertEquals(1, count($authorization->getLinks()));
+       }
+       
+       public function testSerializeDeserialize() {
+               $a1 = $this->authorizations['partial'];
+               $a2 = new Authorization();
+               $a2->fromJson($a1->toJson());
+               $this->assertEquals($a1, $a2);
+       }
+       public function testOperations() {
+               $authId = self::authorize();
+               $auth = Authorization::get($authId);
+               $this->assertNotNull($auth->getId());
+               
+               $amount = new Amount();
+               $amount->setCurrency("USD");
+               $amount->setTotal("1.00");
+               
+               $captur = new Capture();
+               $captur->setId($authId);
+               $captur->setAmount($amount);    
+               
+               $capt = $auth->capture($captur);
+               $this->assertNotNull( $capt->getId());
+               
+               $authId = self::authorize();
+               $auth = Authorization::get($authId);
+               $void = $auth->void();
+               $this->assertNotNull($void->getId());
+
+       }
+       
+       public function testReauthorize(){
+               $authorization = Authorization::get('7GH53639GA425732B');
+       
+               $amount = new Amount();
+               $amount->setCurrency("USD");
+               $amount->setTotal("1.00");
+               
+               $authorization->setAmount($amount);
+               try{
+                       $reauthorization = $authorization->reauthorize();
+               }catch (PPConnectionException $ex){
+                       $this->assertEquals(strpos($ex->getMessage(),"500"), false);
+               }
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/CaptureTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/CaptureTest.php
new file mode 100644 (file)
index 0000000..a1162fd
--- /dev/null
@@ -0,0 +1,87 @@
+<?php
+namespace PayPal\Test\Api;
+
+use PayPal\Api\Capture;
+use PayPal\Api\Refund;
+use PayPal\Api\Authorization;
+use PayPal\Api\Amount;
+use PayPal\Test\Constants;
+
+class CaptureTest extends \PHPUnit_Framework_TestCase {
+
+       private $captures;
+
+       public static $authorization_id = "AUTH-123";
+       public static $create_time = "2013-02-28T00:00:00Z";
+       public static $id = "C-5678";
+       public static $parent_payment = "PAY-123";
+       public static $state = "Created";
+
+       public static function createCapture() {
+               $capture = new Capture();
+               $capture->setCreateTime(self::$create_time);
+               $capture->setId(self::$id);
+               $capture->setParentPayment(self::$parent_payment);
+               $capture->setState(self::$state);               
+               
+               return $capture;
+       }
+       
+       public function setup() {
+               $this->captures['partial'] = self::createCapture();
+               
+               $capture = self::createCapture();
+               $capture->setAmount(AmountTest::createAmount());
+               $capture->setLinks(array(LinksTest::createLinks()));
+               $this->captures['full'] = $capture;
+       }
+
+       public function testGetterSetter() {
+               $this->assertEquals(self::$create_time, $this->captures['partial']->getCreateTime());
+               $this->assertEquals(self::$id, $this->captures['partial']->getId());
+               $this->assertEquals(self::$parent_payment, $this->captures['partial']->getParentPayment());
+               $this->assertEquals(self::$state, $this->captures['partial']->getState());
+               
+               $this->assertEquals(AmountTest::$currency, $this->captures['full']->getAmount()->getCurrency());
+               $links = $this->captures['full']->getLinks();
+               $this->assertEquals(LinksTest::$href, $links[0]->getHref());
+       }
+       
+       public function testSerializeDeserialize() {
+               $c1 = $this->captures['partial'];
+               
+               $c2 = new Capture();
+               $c2->fromJson($c1->toJson());
+               
+               $this->assertEquals($c1, $c2);
+       }
+       
+       public function testOperations()
+       {
+               $authId = AuthorizationTest::authorize();
+               $auth = Authorization::get($authId);
+               
+               $amount = new Amount();
+               $amount->setCurrency("USD");
+               $amount->setTotal("1.00");
+               
+               $captr = new Capture();
+               $captr->setId($authId);
+               $captr->setAmount($amount);
+               
+               $capt = $auth->capture($captr);
+               $captureId = $capt->getId();
+               $this->assertNotNull($captureId);
+               
+               $refund = new Refund();
+               $refund->setId($captureId);
+               $refund->setAmount($amount);
+               
+               $capture = Capture::get($captureId);
+               $this->assertNotNull($capture->getId());
+               
+               $retund = $capture->refund($refund);
+               $this->assertNotNull($retund->getId());
+               
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/CreditCardHistoryTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/CreditCardHistoryTest.php
new file mode 100644 (file)
index 0000000..a7f1b53
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+namespace PayPal\Test\Api;
+
+use PayPal\Api\CreditCardHistory;
+
+use PayPal\Api\Address;
+use PayPal\Api\CreditCard;
+use PayPal\Test\Constants;
+
+class CreditCardHistoryTest extends \PHPUnit_Framework_TestCase {
+       
+       private $cards;
+       
+       public static $id = "id";
+       public static $validUntil = "2013-02-28T00:00:00Z";
+       public static $state = "created";
+       public static $payerId = "payer-id";
+       public static $cardType = "visa";
+       public static $cardNumber = "4417119669820331";
+       public static $expireMonth = 11;
+       public static $expireYear = "2019";
+       public static $cvv = "012";
+       public static $firstName = "V";
+       public static $lastName = "C";
+       
+       public static function createCreditCard() {
+               $card = new CreditCard();
+               $card->setType(self::$cardType);
+               $card->setNumber(self::$cardNumber);
+               $card->setExpireMonth(self::$expireMonth);
+               $card->setExpireYear(self::$expireYear);
+               $card->setCvv2(self::$cvv);
+               $card->setFirstName(self::$firstName);
+               $card->setLastName(self::$lastName);
+               $card->setId(self::$id);
+               $card->setValidUntil(self::$validUntil);
+               $card->setState(self::$state);
+               $card->setPayerId(self::$payerId);
+               return $card;
+       }
+       
+       public function setup() {
+               
+               $card = self::createCreditCard();
+               $card->setBillingAddress(AddressTest::createAddress()); 
+               $card->setLinks(array(LinksTest::createLinks()));
+               $this->cards['full'] = $card;
+               
+               $card = self::createCreditCard();       
+               $this->cards['partial'] = $card;
+       }
+       
+       public function testGetterSetters() {
+               $cardHistory = new CreditCardHistory();
+               $cardHistory->setCreditCards(array($this->cards['partial'], $this->cards['full']));
+               $cardHistory->setCount(2);
+               
+               $this->assertEquals(2, count($cardHistory->getCreditCards()));
+       }
+
+       
+       public function testSerializationDeserialization() {
+               $cardHistory = new CreditCardHistory();
+               $cardHistory->setCreditCards(array($this->cards['partial'], $this->cards['full']));
+               $cardHistory->setCount(2);
+       
+               $cardHistoryCopy = new CreditCardHistory();
+               $cardHistoryCopy->fromJson($cardHistory->toJSON());
+               
+               $this->assertEquals($cardHistory, $cardHistoryCopy);
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/CreditCardTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/CreditCardTest.php
new file mode 100644 (file)
index 0000000..27896fe
--- /dev/null
@@ -0,0 +1,94 @@
+<?php
+namespace PayPal\Test\Api;
+
+use PayPal\Api\Address;
+use PayPal\Api\CreditCard;
+use PayPal\Test\Constants;
+class CreditCardTest extends \PHPUnit_Framework_TestCase {
+       
+       private $cards;
+       
+       public static $id = "id";
+       public static $validUntil = "2013-02-28T00:00:00Z";
+       public static $state = "created";
+       public static $payerId = "payer-id";
+       public static $cardType = "visa";
+       public static $cardNumber = "4417119669820331";
+       public static $expireMonth = 11;
+       public static $expireYear = "2019";
+       public static $cvv = "012";
+       public static $firstName = "V";
+       public static $lastName = "C";
+       
+       public static function createCreditCard() {
+               $card = new CreditCard();
+               $card->setType(self::$cardType);
+               $card->setNumber(self::$cardNumber);
+               $card->setExpireMonth(self::$expireMonth);
+               $card->setExpireYear(self::$expireYear);
+               $card->setCvv2(self::$cvv);
+               $card->setFirstName(self::$firstName);
+               $card->setLastName(self::$lastName);
+               $card->setId(self::$id);
+               $card->setValidUntil(self::$validUntil);
+               $card->setState(self::$state);
+               $card->setPayerId(self::$payerId);
+               return $card;
+       }
+       
+       public function setup() {
+               
+               $card = self::createCreditCard();
+               $card->setBillingAddress(AddressTest::createAddress()); 
+               $card->setLinks(array(LinksTest::createLinks()));
+               $this->cards['full'] = $card;
+               
+               $card = self::createCreditCard();       
+               $this->cards['partial'] = $card;
+       }
+       
+       public function testGetterSetters() {
+               $c = $this->cards['partial'];
+               $this->assertEquals(self::$cardType, $c->getType());
+               $this->assertEquals(self::$cardNumber, $c->getNumber());
+               $this->assertEquals(self::$expireMonth, $c->getExpireMonth());
+               $this->assertEquals(self::$expireYear, $c->getExpireYear());
+               $this->assertEquals(self::$cvv, $c->getCvv2());
+               $this->assertEquals(self::$firstName, $c->getFirstName());
+               $this->assertEquals(self::$lastName, $c->getLastName());
+               $this->assertEquals(self::$id, $c->getId());
+               $this->assertEquals(self::$validUntil, $c->getValidUntil());
+               $this->assertEquals(self::$state, $c->getState());
+               $this->assertEquals(self::$payerId, $c->getPayerId());
+               
+               $c = $this->cards['full'];
+               $this->assertEquals(AddressTest::$line1, $c->getBillingAddress()->getLine1());
+               $link = $c->getLinks();
+               $this->assertEquals(LinksTest::$href, $link[0]->getHref());
+       }
+       
+       public function testSerializeDeserialize() {
+               $c1 = $this->cards['full'];
+               $json = $c1->toJson();
+               
+               $c2 = new CreditCard();
+               $c2->fromJson($json);           
+               
+               $this->assertEquals($c1, $c2);
+       }
+       
+       public function testOperations() {
+               $c1 = $this->cards['full'];
+               
+//             $this->assertNull($c1->getId());
+               $c1->create();          
+               $this->assertNotNull($c1->getId());
+               
+               $c2 = CreditCard::get($c1->getId());
+               $this->assertEquals($c1->getBillingAddress(), $c2->getBillingAddress());
+               $this->assertGreaterThan(0, count($c2->getLinks()));
+               $this->assertEquals(self::$cardType, $c2->getType());
+               $this->assertNotNull($c2->getState());
+               $this->assertEquals(true, $c2->delete());
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/CreditCardTokenTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/CreditCardTokenTest.php
new file mode 100644 (file)
index 0000000..d1f8db9
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+namespace PayPal\Test\Api;
+
+use PayPal\Api\CreditCardToken;
+use PayPal\Test\Constants;
+
+class CreditCardTokenTest extends \PHPUnit_Framework_TestCase {
+
+       private $ccToken;
+
+       public static $payerId = "PAYER-123";
+       public static $creditCardId = "CC-123";
+
+       public static function createCreditCardToken() {
+               $ccToken = new CreditCardToken();
+               $ccToken->setPayerId(self::$payerId);
+               $ccToken->setCreditCardId(self::$creditCardId);
+               return $ccToken;
+       }
+       
+       public function setup() {
+               $this->ccToken = self::createCreditCardToken();         
+       }
+
+       public function testGetterSetter() {
+               $this->assertEquals(self::$payerId, $this->ccToken->getPayerId());
+               $this->assertEquals(self::$creditCardId, $this->ccToken->getCreditCardId());
+       }
+       
+       public function testSerializeDeserialize() {
+               $t1 = $this->ccToken;
+               
+               $t2 = new CreditCardToken();
+               $t2->fromJson($t1->toJson());
+               
+               $this->assertEquals($t1, $t2);
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/DetailsTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/DetailsTest.php
new file mode 100644 (file)
index 0000000..ae1cba9
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+namespace PayPal\Test\Api;
+
+use PayPal\Api\Details;
+use PayPal\Test\Constants;
+
+class DetailsTest extends \PHPUnit_Framework_TestCase {
+
+       private $amountDetails;
+
+       public static $subtotal = "2.00";
+       public static $tax = "1.12";
+       public static $shipping = "3.15";
+       public static $fee = "4.99";
+
+       public static function createAmountDetails() {
+               $amountDetails = new Details();
+               $amountDetails->setSubtotal(self::$subtotal);
+               $amountDetails->setTax(self::$tax);
+               $amountDetails->setShipping(self::$shipping);
+               $amountDetails->setFee(self::$fee);
+               
+               return $amountDetails;
+       }
+
+       public function setup() {
+               $this->amountDetails = self::createAmountDetails();
+       }
+       
+       public function testGetterSetters() {
+               $this->assertEquals(self::$subtotal, $this->amountDetails->getSubtotal());
+               $this->assertEquals(self::$tax, $this->amountDetails->getTax());
+               $this->assertEquals(self::$shipping, $this->amountDetails->getShipping());
+               $this->assertEquals(self::$fee, $this->amountDetails->getFee());                
+       }
+       
+       public function testSerializeDeserialize() {
+               $a1 = $this->amountDetails;
+               
+               $a2 = new Details();
+               $a2->fromJson($a1->toJson());
+               
+               $this->assertEquals($a1, $a2);
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/FundingInstrumentTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/FundingInstrumentTest.php
new file mode 100644 (file)
index 0000000..cb420d6
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+
+namespace PayPal\Test\Api;
+
+use PayPal\Api\FundingInstrument;
+use PayPal\Test\Constants;
+
+class FundingInstrumentTest extends \PHPUnit_Framework_TestCase {
+
+       private $fi;
+
+       public static function createFundingInstrument() {
+               $fi = new FundingInstrument();
+               $fi->setCreditCard(CreditCardTest::createCreditCard());
+               $fi->setCreditCardToken(CreditCardTokenTest::createCreditCardToken());
+               return $fi;
+       }
+       
+       public function setup() {
+               $this->fi = self::createFundingInstrument();
+       }
+
+       public function testGetterSetter() {
+               $this->assertEquals(CreditCardTest::$cardNumber, $this->fi->getCreditCard()->getNumber());
+               $this->assertEquals(CreditCardTokenTest::$creditCardId, 
+                               $this->fi->getCreditCardToken()->getCreditCardId());
+       }
+       
+       public function testSerializeDeserialize() {
+               $fi1 = $this->fi;
+               
+               $fi2 = new FundingInstrument();
+               $fi2->fromJson($fi1->toJson());         
+               $this->assertEquals($fi1, $fi2);
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/ItemListTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/ItemListTest.php
new file mode 100644 (file)
index 0000000..fe5f870
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+namespace PayPal\Test\Api;
+
+use PayPal\Api\Item;
+use PayPal\Api\ItemList;
+use PayPal\Test\Constants;
+
+class ItemListTest extends \PHPUnit_Framework_TestCase {
+       
+       private $items = array();
+       
+       private static $name = "item name";
+       private static $price = "1.12";
+       private static $quantity = "10";
+       private static $sku = "AXVTY123";
+       private static $currency = "USD";
+       
+       public static function createItemList() {
+               
+               $item = ItemTest::createItem();
+               
+               $itemList = new ItemList();
+               $itemList->setItems(array($item));
+               $itemList->setShippingAddress(ShippingAddressTest::createAddress());
+               
+               return $itemList;
+       }
+       
+       public function setup() {               
+               $this->items = self::createItemList();
+       }
+       
+       public function testGetterSetters() {
+               $items = $this->items->getItems();              
+               $this->assertEquals(ItemTest::createItem(), $items[0]);
+               $this->assertEquals(ShippingAddressTest::createAddress(), $this->items->getShippingAddress());
+       }
+       
+       public function testSerializeDeserialize() {
+               $itemList = new ItemList();
+               $itemList->fromJson($this->items->toJSON());
+       
+               $this->assertEquals($itemList, $this->items);
+       }
+       
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/ItemTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/ItemTest.php
new file mode 100644 (file)
index 0000000..59be288
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+namespace PayPal\Test\Api;
+
+use PayPal\Api\Item;
+use PayPal\Test\Constants;
+
+class ItemTest extends \PHPUnit_Framework_TestCase {
+       
+       private $item;
+       
+       public static $name = "item name";
+       public static $price = "1.12";
+       public static $quantity = "10";
+       public static $sku = "AXVTY123";
+       public static $currency = "USD";
+       
+       public static function createItem() {
+               $item = new Item();
+               $item->setName(self::$name);
+               $item->setPrice(self::$price);
+               $item->setQuantity(self::$quantity);
+               $item->setSku(self::$sku);
+               $item->setCurrency(self::$currency);
+               
+               return $item;
+       }
+       public function setup() {               
+               $this->item = ItemTest::createItem();
+       }
+       
+       public function testGetterSetters() {
+               $this->assertEquals(self::$name, $this->item->getName());
+               $this->assertEquals(self::$price, $this->item->getPrice());
+               $this->assertEquals(self::$sku, $this->item->getSku());
+               $this->assertEquals(self::$quantity, $this->item->getQuantity());
+               $this->assertEquals(self::$currency, $this->item->getCurrency());
+       }
+       
+       public function testSerializeDeserialize() {
+               $item = new Item();
+               $item->fromJson($this->item->toJSON());
+       
+               $this->assertEquals($item, $this->item);
+       }
+       
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/LinksTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/LinksTest.php
new file mode 100644 (file)
index 0000000..68da69a
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+
+namespace PayPal\Test\Api;
+
+use PayPal\Api\Links;
+use PayPal\Test\Constants;
+
+class LinksTest extends \PHPUnit_Framework_TestCase {
+
+       private $links;
+
+       public static $href = "USD";
+       public static $rel = "1.12";
+       public static $method = "1.12";
+       
+       public static function createLinks() {
+               $links = new Links();
+               $links->setHref(self::$href);
+               $links->setRel(self::$rel);
+               $links->setMethod(self::$method);
+               
+               return $links;
+       }
+       
+       public function setup() {
+               $this->links = self::createLinks();
+       }
+       
+       public function testGetterSetters() {
+               $this->assertEquals(self::$href, $this->links->getHref());
+               $this->assertEquals(self::$rel, $this->links->getRel());
+               $this->assertEquals(self::$method, $this->links->getMethod());
+       }
+       
+       public function testSerializeDeserialize() {
+               $link2 = new Links();
+               $link2->fromJson($this->links->toJSON());
+               $this->assertEquals($this->links, $link2);
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/PayeeTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/PayeeTest.php
new file mode 100644 (file)
index 0000000..ea9469f
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+
+namespace PayPal\Test\Api;
+
+use PayPal\Api\Payee;
+use PayPal\Test\Constants;
+
+class PayeeTest extends \PHPUnit_Framework_TestCase {
+
+       private $payee;
+
+       public static $email = "test@paypal.com";
+       public static $merchant_id = "1XY12121";
+       public static $phone = "+14081234566";
+       
+
+       public static function createPayee() {
+               $payee = new Payee();
+               $payee->setEmail(self::$email);
+               $payee->setMerchantId(self::$merchant_id);
+               $payee->setPhone(self::$phone);         
+               
+               return $payee;
+       }
+       
+       public function setup() {
+               $this->payee = self::createPayee();
+       }
+
+       public function testGetterSetter() {
+               $this->assertEquals(self::$email, $this->payee->getEmail());
+               $this->assertEquals(self::$merchant_id, $this->payee->getMerchantId());
+               $this->assertEquals(self::$phone, $this->payee->getPhone());
+       }
+       
+       public function testSerializeDeserialize() {
+               $p1 = $this->payee;
+               
+               $p2 = new Payee();
+               $p2->fromJson($p1->toJson());
+               
+               $this->assertEquals($p1, $p2);
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/PayerInfoTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/PayerInfoTest.php
new file mode 100644 (file)
index 0000000..b1f5858
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+namespace PayPal\Test\Api;
+
+use PayPal\Api\PayerInfo;
+use PayPal\Test\Constants;
+
+class PayerInfoTest extends \PHPUnit_Framework_TestCase {
+
+       private $payerInfo;
+
+       public static $email = "test@paypal.com";
+       public static $firstName = "first";
+       public static $lastName = "last";
+       public static $phone = "408-1234-5687";
+       public static $payerId = "PAYER-1234";
+
+       public static function createPayerInfo() {
+               $payerInfo = new PayerInfo();
+               $payerInfo->setEmail(self::$email);
+               $payerInfo->setFirstName(self::$firstName);
+               $payerInfo->setLastName(self::$lastName);
+               $payerInfo->setPhone(self::$phone);
+               $payerInfo->setPayerId(self::$payerId);
+               $payerInfo->setShippingAddress(AddressTest::createAddress());
+               
+               return $payerInfo;
+       }
+       
+       public function setup() {
+               $this->payerInfo = self::createPayerInfo();
+       }
+
+       public function testGetterSetter() {
+               $this->assertEquals(self::$email, $this->payerInfo->getEmail());
+               $this->assertEquals(self::$firstName, $this->payerInfo->getFirstName());
+               $this->assertEquals(self::$lastName, $this->payerInfo->getLastName());
+               $this->assertEquals(self::$phone, $this->payerInfo->getPhone());
+               $this->assertEquals(self::$payerId, $this->payerInfo->getPayerId());
+               $this->assertEquals(AddressTest::$line1, $this->payerInfo->getShippingAddress()->getLine1());
+       }
+       
+       public function testSerializeDeserialize() {
+               $p1 = $this->payerInfo;
+               
+               $p2 = new PayerInfo();
+               $p2->fromJson($p1->toJson());
+               
+               $this->assertEquals($p1, $p2);
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/PayerTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/PayerTest.php
new file mode 100644 (file)
index 0000000..7568a3c
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+
+namespace PayPal\Test\Api;
+
+use PayPal\Api\FundingInstrument;
+
+use PayPal\Api\Payer;
+use PayPal\Test\Constants;
+
+class PayerTest extends \PHPUnit_Framework_TestCase {
+
+       private $payer;
+
+       private static $paymentMethod = "credit_card";
+
+       public static function createPayer() {
+               $payer = new Payer();
+               $payer->setPaymentMethod(self::$paymentMethod);
+               $payer->setPayerInfo(PayerInfoTest::createPayerInfo());
+               $payer->setFundingInstruments(array(FundingInstrumentTest::createFundingInstrument()));
+               
+               return $payer;
+       }
+       
+       public function setup() {
+               $this->payer = self::createPayer();
+       }
+
+       public function testGetterSetter() {
+               $this->assertEquals(self::$paymentMethod, $this->payer->getPaymentMethod());
+               $this->assertEquals(PayerInfoTest::$email, $this->payer->getPayerInfo()->getEmail());
+               
+               $fi = $this->payer->getFundingInstruments();
+               $this->assertEquals(CreditCardTokenTest::$creditCardId, $fi[0]->getCreditCardToken()->getCreditCardId());
+       }
+       
+       public function testSerializeDeserialize() {
+               $p1 = $this->payer;
+               
+               $p2 = new Payer();
+               $p2->fromJson($p1->toJson());
+               
+               $this->assertEquals($p1, $p2);
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/PaymentHistoryTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/PaymentHistoryTest.php
new file mode 100644 (file)
index 0000000..577d282
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+
+namespace PayPal\Test\Api;
+
+use PayPal\Api\PaymentHistory;
+use PayPal\Test\Constants;
+
+class PaymentHistoryTest extends \PHPUnit_Framework_TestCase {
+       
+       private $history;
+       
+       public static $count = "10";
+       public static $nextId = "11";
+       
+       public static function createPaymentHistory() {
+               $history = new PaymentHistory();
+               $history->setCount(self::$count);
+               $history->setNextId(self::$nextId);
+               $history->setPayments(array(PaymentTest::createPayment()));
+               return $history;
+       }
+       public function setup() {               
+               $this->history = PaymentHistoryTest::createPaymentHistory();
+       }
+       
+       public function testGetterSetters() {
+               $this->assertEquals(self::$count, $this->history->getCount());
+               $this->assertEquals(self::$nextId, $this->history->getNextId());
+               
+       }
+       
+       public function testSerializeDeserialize() {
+               $history = new PaymentHistory();
+               $history->fromJson($this->history->toJSON());
+       
+               $this->assertEquals($history, $this->history);
+       }
+       
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/PaymentTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/PaymentTest.php
new file mode 100644 (file)
index 0000000..2bf9795
--- /dev/null
@@ -0,0 +1,78 @@
+<?php
+namespace PayPal\Test\Api;
+use PayPal\Api\RedirectUrls;
+use PayPal\Api\Address;
+use PayPal\Api\Amount;
+use PayPal\Api\CreditCard;
+use PayPal\Api\Payer;
+use PayPal\Api\Payment;
+use PayPal\Api\FundingInstrument;
+use PayPal\Api\Transaction;
+use PayPal\Test\Constants;
+
+class PaymentTest extends \PHPUnit_Framework_TestCase {
+
+       private $payments;      
+
+       public static function createPayment() {
+               
+               $redirectUrls = new RedirectUrls();
+               $redirectUrls->setReturnUrl("http://localhost/return");
+               $redirectUrls->setCancelUrl("http://localhost/cancel");
+               
+               $payment = new Payment();
+               $payment->setIntent("sale");
+               $payment->setRedirectUrls($redirectUrls);
+               $payment->setPayer(PayerTest::createPayer());
+               $payment->setTransactions(array(TransactionTest::createTransaction()));
+               
+               return $payment;                                
+       }
+       
+       public static function createNewPayment() {
+               $payer = new Payer();
+               $payer->setPaymentMethod("credit_card");
+               $payer->setFundingInstruments(array(FundingInstrumentTest::createFundingInstrument()));
+               
+               $transaction = new Transaction();
+               $transaction->setAmount(AmountTest::createAmount());
+               $transaction->setDescription("This is the payment description.");
+               
+               $redirectUrls = new RedirectUrls();
+               $redirectUrls->setReturnUrl("http://localhost/return");
+               $redirectUrls->setCancelUrl("http://localhost/cancel");
+               
+               $payment = new Payment();
+               $payment->setIntent("sale");
+               $payment->setRedirectUrls($redirectUrls);
+               $payment->setPayer($payer);
+               $payment->setTransactions(array($transaction));
+       
+               return $payment;        
+       }
+       
+       public function setup() {               
+               $this->payments['full'] = self::createPayment();
+               $this->payments['new'] = self::createNewPayment();
+       }
+       
+       public function testSerializeDeserialize() {
+               $p2 = new Payment();
+               $p2->fromJson($this->payments['full']->toJSON());               
+               $this->assertEquals($p2, $this->payments['full']);
+       }
+       
+       public function testOperations() {
+
+               $p1 = $this->payments['new'];
+                
+               $p1->create();          
+               $this->assertNotNull($p1->getId());
+               
+               $p2 = Payment::get($p1->getId());
+               $this->assertNotNull($p2);
+               
+               $paymentHistory = Payment::all(array('count' => '10'));
+               $this->assertNotNull($paymentHistory);
+       }
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/RefundTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/RefundTest.php
new file mode 100644 (file)
index 0000000..657e167
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+namespace PayPal\Test\Api;
+
+use PayPal\Api\Refund;
+use PayPal\Test\Constants;
+
+class RefundTest extends \PHPUnit_Framework_TestCase {
+
+       private $refund;
+
+       public static $captureId = "CAP-123";
+       public static $createTime = "2013-02-28T00:00:00Z";
+       public static $id = "R-5678";
+       public static $parentPayment = "PAY-123";
+
+       public static function createRefund() {
+               $refund = new Refund();
+        $refund->setCreateTime(self::$createTime);
+               $refund->setAmount(AmountTest::createAmount());
+               $refund->setCaptureId(self::$captureId);
+               $refund->setId(self::$id);
+               $refund->setLinks(array(LinksTest::createLinks()));
+               $refund->setParentPayment(self::$parentPayment);                
+               
+               return $refund;
+       }
+       
+       public function setup() {
+               $this->refund = self::createRefund();
+       }
+
+       public function testGetterSetter() {
+               $this->assertEquals(self::$captureId, $this->refund->getCaptureId());
+               $this->assertEquals(self::$createTime, $this->refund->getCreateTime());
+               $this->assertEquals(self::$id, $this->refund->getId());
+               $this->assertEquals(self::$parentPayment, $this->refund->getParentPayment());           
+               $this->assertEquals(AmountTest::$currency, $this->refund->getAmount()->getCurrency());
+               $links = $this->refund->getLinks();
+               $this->assertEquals(LinksTest::$href, $links[0]->getHref());
+       }
+       
+       public function testSerializeDeserialize() {
+               $r1 = $this->refund;
+               
+               $r2 = new Refund();
+               $r2->fromJson($r1->toJson());
+               
+               $this->assertEquals($r1, $r2);
+       }
+       
+       public function testOperations() {
+       
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/RelatedResourcesTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/RelatedResourcesTest.php
new file mode 100644 (file)
index 0000000..c977395
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+namespace PayPal\Test\Api;
+
+use PayPal\Api\RelatedResources;
+use PayPal\Test\Constants;
+
+class RelatedResourcesTest extends \PHPUnit_Framework_TestCase {
+
+       private $RelatedResources;
+
+       public static function createRelatedResources() {
+               $relatedResources = new RelatedResources();
+               $relatedResources->setAuthorization(AuthorizationTest::createAuthorization());
+               $relatedResources->setCapture(CaptureTest::createCapture());
+               return $relatedResources;
+       }
+       
+       public function setup() {
+               $this->relatedResources = self::createRelatedResources();
+       }
+
+       public function testGetterSetter() {
+               $this->assertEquals(AuthorizationTest::$create_time, $this->relatedResources->getAuthorization()->getCreateTime());
+               $this->assertEquals(CaptureTest::$create_time, $this->relatedResources->getCapture()->getCreateTime());
+       }
+       
+       public function testSerializeDeserialize() {
+               $s1 = $this->relatedResources;
+               
+               $s2 = new RelatedResources();
+               $s2->fromJson($s1->toJson());
+               
+               $this->assertEquals($s1, $s2);
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/SaleTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/SaleTest.php
new file mode 100644 (file)
index 0000000..b4c6972
--- /dev/null
@@ -0,0 +1,73 @@
+<?php
+namespace PayPal\Test\Api;
+
+use PayPal\Api\Refund;
+use PayPal\Api\Sale;
+use PayPal\Test\Constants;
+use PayPal\Test\Api\AmountTest;
+use PayPal\Test\Api\PaymentTest;
+use PayPal\Test\Api\LinksTest;
+
+class SaleTest extends \PHPUnit_Framework_TestCase {
+
+       private $sale;
+
+       public static $captureId = "CAP-123";
+       public static $createTime = "2013-02-28T00:00:00Z";
+       public static $id = "R-5678";
+       public static $parentPayment = "PAY-123";
+       public static $state = "Created";
+
+       public static function createSale() {
+               $sale = new Sale();
+               $sale->setAmount(AmountTest::createAmount());
+               $sale->setCreateTime(self::$createTime);
+               $sale->setId(self::$id);
+               $sale->setLinks(array(LinksTest::createLinks()));
+               $sale->setParentPayment(self::$parentPayment);          
+               $sale->setState(self::$state);
+               return $sale;
+       }
+       
+       public function setup() {
+               $this->sale = self::createSale();
+       }
+
+       public function testGetterSetter() {
+               $this->assertEquals(self::$createTime, $this->sale->getCreateTime());
+               $this->assertEquals(self::$id, $this->sale->getId());
+               $this->assertEquals(self::$parentPayment, $this->sale->getParentPayment());
+               $this->assertEquals(self::$state, $this->sale->getState());
+               $this->assertEquals(AmountTest::$currency, $this->sale->getAmount()->getCurrency());
+               $links = $this->sale->getLinks();
+               $this->assertEquals(LinksTest::$href, $links[0]->getHref());
+       }
+       
+       public function testSerializeDeserialize() {
+               $s1 = $this->sale;
+               
+               $s2 = new Sale();
+               $s2->fromJson($s1->toJson());
+               
+               $this->assertEquals($s1, $s2);
+       }
+       
+       public function testOperations() {
+               $payment = PaymentTest::createNewPayment();                     
+               $payment->create();
+               
+               $transactions = $payment->getTransactions();
+               $resources = $transactions[0]->getRelatedResources();           
+               $saleId = $resources[0]->getSale()->getId();
+               
+               $sale = Sale::get($saleId);
+               $this->assertNotNull($sale);            
+               
+               $refund = new Refund();
+               $refund->setAmount(AmountTest::createAmount());
+               $sale->refund($refund);
+               
+               $this->setExpectedException('\InvalidArgumentException');
+               $sale->refund(NULL);
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/ShippingAddressTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/ShippingAddressTest.php
new file mode 100644 (file)
index 0000000..6ca8b93
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+namespace PayPal\Test\Api;
+
+use PayPal\Api\ShippingAddress;
+use PayPal\Test\Constants;
+
+class ShippingAddressTest extends \PHPUnit_Framework_TestCase {
+
+       private $address;
+
+       public static $line1 = "3909 Witmer Road";
+       public static $line2 = "Niagara Falls"; 
+       public static $city = "Niagara Falls";
+       public static $state = "NY";
+       public static $postalCode = "14305";
+       public static $countryCode = "US";
+       public static $phone = "716-298-1822";
+       public static $recipientName = "TestUser";
+
+       public static function createAddress() {
+               $addr = new ShippingAddress();
+               $addr->setLine1(self::$line1);
+               $addr->setLine2(self::$line2);
+               $addr->setCity(self::$city);
+               $addr->setState(self::$state);
+               $addr->setPostalCode(self::$postalCode);
+               $addr->setCountryCode(self::$countryCode);
+               $addr->setPhone(self::$phone);
+               $addr->setRecipientName(self::$recipientName);
+               return $addr;
+       }
+       
+       public function setup() {
+               $this->address = self::createAddress();
+       }
+
+       public function testGetterSetter() {
+               $this->assertEquals(self::$line1, $this->address->getLine1());
+               $this->assertEquals(self::$line2, $this->address->getLine2());
+               $this->assertEquals(self::$city, $this->address->getCity());
+               $this->assertEquals(self::$state, $this->address->getState());
+               $this->assertEquals(self::$postalCode, $this->address->getPostalCode());
+               $this->assertEquals(self::$countryCode, $this->address->getCountryCode());
+               $this->assertEquals(self::$phone, $this->address->getPhone());
+               $this->assertEquals(self::$recipientName, $this->address->getRecipientName());
+       }
+       
+       public function testSerializeDeserialize() {
+               $a1 = $this->address;
+               
+               $a2 = new ShippingAddress();
+               $a2->fromJson($a1->toJson());
+               
+               $this->assertEquals($a1, $a2);
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/TransactionTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/TransactionTest.php
new file mode 100644 (file)
index 0000000..f2e0ba3
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+
+namespace PayPal\Test\Api;
+
+use PayPal\Api\SubTransaction;
+
+use PayPal\Api\Transaction;
+use PayPal\Test\Constants;
+
+class TransactionTest extends \PHPUnit_Framework_TestCase {
+
+       private $transaction;
+
+       public static $description = "desc . . . ";
+       public static $total = "1.12";  
+
+       public static function createTransaction() {
+               $transaction = new Transaction();
+               $transaction->setAmount(AmountTest::createAmount());
+               $transaction->setDescription(self::$description);
+               $transaction->setItemList(ItemListTest::createItemList());
+               $transaction->setPayee(PayeeTest::createPayee());
+               $transaction->setRelatedResources( array(RelatedResourcesTest::createRelatedResources()) );
+               return $transaction;
+       }
+       
+       public function setup() {
+               $this->transaction = self::createTransaction();
+       }
+
+       public function testGetterSetter() {
+               $this->assertEquals(AmountTest::$currency, $this->transaction->getAmount()->getCurrency());
+               $this->assertEquals(self::$description, $this->transaction->getDescription());
+               $items = $this->transaction->getItemList()->getItems();
+               $this->assertEquals(ItemTest::$quantity, $items[0]->getQuantity());
+               $this->assertEquals(PayeeTest::$email, $this->transaction->getPayee()->getEmail());
+               $resources = $this->transaction->getRelatedResources();
+               $this->assertEquals(AuthorizationTest::$create_time, $resources[0]->getAuthorization()->getCreateTime());
+       }
+       
+       public function testSerializeDeserialize() {
+               $t1 = $this->transaction;
+               
+               $t2 = new Transaction();
+               $t2->fromJson($t1->toJson());
+               
+               $this->assertEquals($t1, $t2);
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Auth/OAuthTokenCredentialTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Auth/OAuthTokenCredentialTest.php
new file mode 100644 (file)
index 0000000..e356d40
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+
+// namespace PayPal\Test\Common;
+
+use PayPal\Auth\OAuthTokenCredential;
+use PayPal\Test\Constants;
+use PayPal\Core\PPConfigManager;
+use PayPal\Exception\PPConnectionException;
+class OAuthTokenCredentialTest extends PHPUnit_Framework_TestCase {
+       
+       public function testGetAccessToken() {
+               $cred = new OAuthTokenCredential(Constants::CLIENT_ID, Constants::CLIENT_SECRET);
+               $config = PPConfigManager::getInstance()->getConfigHashmap();
+               
+               $token = $cred->getAccessToken($config);                
+               $this->assertNotNull($token);
+               
+               // Check that we get the same token when issuing a new call before token expiry
+               $newToken = $cred->getAccessToken($config);
+               $this->assertNotNull($newToken);
+               $this->assertEquals($token, $newToken);
+               
+//             sleep(60*8);
+//             $newToken = $cred->getAccessToken();
+//             $this->assertNotNull($newToken);
+//             $this->assertNotEqual($token, $newToken);
+               
+       }
+       
+       public function testInvalidCredentials() {
+               $this->setExpectedException('PayPal\Exception\PPConnectionException');
+               $cred = new OAuthTokenCredential('dummy', 'secret');            
+               $this->assertNull($cred->getAccessToken(PPConfigManager::getInstance()->getConfigHashmap()));
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/ArrayClass.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/ArrayClass.php
new file mode 100644 (file)
index 0000000..3470847
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+namespace PayPal\Test\Common;
+use PayPal\Common\PPModel;
+class ArrayClass extends PPModel {
+
+       public function setName($name) {
+               $this->name = $name;
+       }
+       public function getName() {
+               return $this->name;
+       }
+
+       public function setDescription($desc) {
+               $this->desc = $desc;
+       }
+       public function getDescription() {
+               return $this->desc;
+       }
+       
+       public function setTags($tags) {
+               if(!is_array($tags)) {
+                       $tags = array($tags);
+               }
+               $this->tags = $tags;
+       }
+       public function getTags() {
+               return $this->tags;
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/ArrayUtilTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/ArrayUtilTest.php
new file mode 100644 (file)
index 0000000..d0b3821
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+namespace PayPal\Test\Common;
+use PayPal\Common\PPArrayUtil;
+
+class ArrayUtilTest extends \PHPUnit_Framework_TestCase {
+       
+       public function testIsAssocArray() {
+               
+               $arr = array(1, 2, 3);
+               $this->assertEquals(false, PPArrayUtil::isAssocArray($arr));    
+               
+               $arr = array(
+                       'name' => 'John Doe',
+                       'City' => 'San Jose'
+               );
+               $this->assertEquals(true, PPArrayUtil::isAssocArray($arr));
+               
+               $arr[] = 'CA';
+               $this->assertEquals(false, PPArrayUtil::isAssocArray($arr));
+       }
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/ChildClass.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/ChildClass.php
new file mode 100644 (file)
index 0000000..a9a294b
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+namespace PayPal\Test\Common;
+use PayPal\Common\PPModel;
+class ChildClass extends SimpleClass {
+       
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/ModelTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/ModelTest.php
new file mode 100644 (file)
index 0000000..7c80e94
--- /dev/null
@@ -0,0 +1,66 @@
+<?php 
+namespace PayPal\Test\Common;
+use PayPal\Common\PPModel;
+use PayPal\Test\Common\ArrayClass;
+use PayPal\Test\Common\SimpleClass;
+use PayPal\Test\Common\NestedClass;
+class ModelTest extends \PHPUnit_Framework_TestCase {
+       
+       public function testSimpleClassConversion() {
+               $o = new SimpleClass();
+               $o->setName("test");
+               $o->setDescription("description");
+
+               $this->assertEquals("test", $o->getName());
+               $this->assertEquals("description", $o->getDescription());
+               
+               $json = $o->toJSON();           
+               $this->assertEquals('{"name":"test","desc":"description"}', $json);
+               
+               $newO = new SimpleClass();
+               $newO->fromJson($json);
+               $this->assertEquals($o, $newO);
+               
+       }
+       
+       
+       public function testArrayClassConversion() {
+               $o = new ArrayClass();
+               $o->setName("test");
+               $o->setDescription("description");
+               $o->setTags(array('payment', 'info', 'test'));
+               
+               $this->assertEquals("test", $o->getName());
+               $this->assertEquals("description", $o->getDescription());
+               $this->assertEquals(array('payment', 'info', 'test'), $o->getTags());
+               
+               $json = $o->toJSON();
+               $this->assertEquals('{"name":"test","desc":"description","tags":["payment","info","test"]}', $json);
+       
+               $newO = new ArrayClass();
+               $newO->fromJson($json);
+               $this->assertEquals($o, $newO); 
+       }
+       
+       public function testNestedClassConversion() {
+               $n = new ArrayClass();
+               $n->setName("test");
+               $n->setDescription("description");
+//             $n->setTags(array('payment', 'info', 'test'));
+               $o = new NestedClass();
+               $o->setId('123');
+               $o->setInfo($n);
+               
+               $this->assertEquals("123", $o->getId());
+               $this->assertEquals("test", $o->getInfo()->getName());          
+//             $this->assertEquals(array('payment', 'info', 'test'), $o->getInfo()->getTags());
+               
+               $json = $o->toJSON();
+//             $this->assertEquals('{"id":"123","info":{"name":"test","desc":"description","tags":["payment","info","test"]}}', $json);
+               $this->assertEquals('{"id":"123","info":{"name":"test","desc":"description"}}', $json);
+               
+               $newO = new NestedClass();
+               $newO->fromJson($json);
+               $this->assertEquals($o, $newO);
+       }
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/NestedClass.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/NestedClass.php
new file mode 100644 (file)
index 0000000..06e5e00
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+namespace PayPal\Test\Common;
+use PayPal\Common\PPModel;
+class NestedClass extends PPModel {
+       
+       public function setId($id) {
+               $this->id = $id;
+       }
+       public function getId() {
+               return $this->id;
+       }
+       
+       /**
+        * 
+        * @param PayPal\Test\Common\ArrayClass $info
+        */
+       public function setInfo($info) {
+               $this->info = $info;
+       }
+       /**
+        * 
+        * @return PayPal\Test\Common\ArrayClass
+        */
+       public function getInfo() {
+               return $this->info;
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/SimpleClass.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/SimpleClass.php
new file mode 100644 (file)
index 0000000..86732b1
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+namespace PayPal\Test\Common;
+use PayPal\Common\PPModel;
+class SimpleClass extends PPModel {
+
+       public function setName($name) {
+               $this->name = $name;
+       }
+       public function getName() {
+               return $this->name;
+       }
+       
+       public function setDescription($desc) {
+               $this->desc = $desc;
+       }
+       public function getDescription() {
+               return $this->desc;
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/UserAgentTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/UserAgentTest.php
new file mode 100644 (file)
index 0000000..24f4fe3
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+
+use PayPal\Common\PPUserAgent;
+
+class UserAgentTest extends PHPUnit_Framework_TestCase {
+       
+       public function testGetValue() {
+               $ua = PPUserAgent::getValue("name", "version");
+               list($id, $version, $features) = sscanf($ua, "PayPalSDK/%s %s (%s)");
+               
+               // Check that we pass the useragent in the expected format
+               $this->assertNotNull($id);
+               $this->assertNotNull($version);
+               $this->assertNotNull($features);
+               
+               $this->assertEquals("name", $id);
+               $this->assertEquals("version", $version);
+               
+               // Check that we pass in these mininal features
+               $this->assertThat($features, $this->stringContains("OS="));
+               $this->assertThat($features, $this->stringContains("Bit="));
+               $this->assertThat($features, $this->stringContains("Lang="));
+               $this->assertThat($features, $this->stringContains("V="));
+               $this->assertGreaterThan(5, count(explode(';', $features)));
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Constants.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Constants.php
new file mode 100644 (file)
index 0000000..7c424e3
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+namespace PayPal\Test;
+
+class Constants {
+       const CLIENT_ID = 'EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM';
+       const CLIENT_SECRET = 'EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM';
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Rest/CallTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Rest/CallTest.php
new file mode 100644 (file)
index 0000000..3da124e
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+
+// namespace PayPal\Test\Rest;
+
+use PayPal\Auth\OAuthTokenCredential;
+
+use PayPal\Rest\Call;
+use PayPal\Test\Constants;
+
+class CallTest  {
+
+       public function testExecuteWithExplicitCredentials() {
+               $cred = new OAuthTokenCredential(Constants::CLIENT_ID, Constants::CLIENT_SECRET);
+               $data = '"request":"test message"';
+
+               $call = new Call();
+               $ret = $call->execute('/v1/payments/echo', "POST", $data, $cred);
+               $this->assertEquals($data, $ret);
+       }
+
+       public function testExecuteWithInvalidCredentials() {
+
+               $cred = new OAuthTokenCredential('test', 'dummy');
+               $data = '"request":"test message"';
+
+               $call = new Call();
+               $this->setExpectedException('\PPConnectionException');
+               $ret = $call->execute('/v1/payments/echo', "POST", $data, $cred);
+
+       }
+
+
+       public function testExecuteWithDefaultCredentials() {
+
+               $data = '"request":"test message"';
+
+               $call = new Call();
+               $ret = $call->execute('/v1/payments/echo', "POST", $data);
+               $this->assertEquals($data, $ret);
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/bootstrap.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/bootstrap.php
new file mode 100644 (file)
index 0000000..d249596
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+
+// Include the composer autoloader
+$loader = require dirname(__DIR__) . '/vendor/autoload.php';
+$loader->add('PayPal\\Test', __DIR__);
+define("PP_CONFIG_PATH", __DIR__);
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/sdk_config.ini b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/sdk_config.ini
new file mode 100644 (file)
index 0000000..f73b92a
--- /dev/null
@@ -0,0 +1,35 @@
+;Account credentials from developer portal
+[Account]
+acct1.ClientId = EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM
+acct1.ClientSecret = EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM
+
+
+;Connection Information
+[Http]
+http.ConnectionTimeOut = 30
+http.Retry = 1
+;http.Proxy=http://[username:password]@hostname[:port][/path]
+
+
+;Service Configuration
+[Service]
+service.EndPoint="https://api.sandbox.paypal.com"
+; Uncomment this line for integrating with the live endpoint 
+; service.EndPoint="https://api.paypal.com"
+
+
+;Logging Information
+[Log]
+
+log.LogEnabled=true
+
+# When using a relative path, the log file is created
+# relative to the .php file that is the entry point
+# for this request. You can also provide an absolute
+# path here
+log.FileName=PayPal.log
+
+# Logging level can be one of FINE, INFO, WARN or ERROR
+# Logging is most verbose in the 'FINE' level and
+# decreases as you proceed towards ERROR
+log.LogLevel=FINE
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/.gitignore b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/.gitignore
new file mode 100644 (file)
index 0000000..0db5431
--- /dev/null
@@ -0,0 +1,14 @@
+tests/reports
+build
+.DS_Store
+*.log
+
+# IDE
+.project
+.settings
+.buildpath
+*.bak
+
+# Composer
+vendor
+composer.lock
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/CHANGELOG.md b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/CHANGELOG.md
new file mode 100644 (file)
index 0000000..bfa023a
--- /dev/null
@@ -0,0 +1,18 @@
+
+CHANGELOG
+========= 
+V2.4.0 (May 20, 2013)
+---------------------------------------------------------------------------------------
+   * Bugfix - removing deprecated methods like setAccessToken, getAccessToken from baseService 
+   * Bugfix - adding correct thirdparty auth header
+   
+V2.4.0 (May 20, 2013)
+---------------------------------------------------------------------------------------
+   * Updating SDK to use NameSpaces
+   
+
+V1.4.0 (April 26, 2013)
+---------------------------------------------------------------------------------------
+   * Adding support for Openid Connect
+   
+
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/LICENSE.txt b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/LICENSE.txt
new file mode 100644 (file)
index 0000000..ad030e5
--- /dev/null
@@ -0,0 +1,41 @@
+PAYPAL, INC.
+
+SDK LICENSE
+
+NOTICE TO USER:  PayPal, Inc. is providing the Software and Documentation for use under the terms of this Agreement.  Any use, reproduction, modification or distribution of the Software or Documentation, or any derivatives or portions hereof, constitutes your acceptance of this Agreement.
+
+As used in this Agreement, "PayPal" means PayPal, Inc.  "Software" means the software code accompanying this agreement.   "Documentation" means the documents, specifications and all other items accompanying this Agreement other than the Software.   
+
+1.  LICENSE GRANT Subject to the terms of this Agreement, PayPal hereby grants you a non-exclusive, worldwide, royalty free license to use, reproduce, prepare derivative works from, publicly display, publicly perform, distribute and sublicense the Software for any purpose, provided the copyright notice below appears in a conspicuous location within the source code of the distributed Software and this license is distributed in the supporting documentation of the Software you distribute. Furthermore, you must comply with all third party licenses in order to use the third party software contained in the Software.
+
+Subject to the terms of this Agreement, PayPal hereby grants you a non-exclusive, worldwide, royalty free license to use, reproduce, publicly display, publicly perform, distribute and sublicense the Documentation for any purpose.  You may not modify the Documentation.
+
+No title to the intellectual property in the Software or Documentation is transferred to you under the terms of this Agreement.  You do not acquire any rights to the Software or the Documentation except as expressly set forth in this Agreement.
+
+If you choose to distribute the Software in a commercial product, you do so with the understanding that you agree to defend, indemnify and hold harmless PayPal and its suppliers against any losses, damages and costs arising from the claims, lawsuits or other legal actions arising out of such distribution.  You may distribute the Software in object code form under your own license, provided that your license agreement:
+
+(a)    complies with the terms and conditions of this license agreement; 
+
+(b)    effectively disclaims all warranties and conditions, express or implied, on behalf of PayPal;
+
+(c)    effectively excludes all liability for damages on behalf of PayPal;
+
+(d)    states that any provisions that differ from this Agreement are offered by you alone and not PayPal; and
+
+(e)    states that the Software is available from you or PayPal and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.  
+
+2.  DISCLAIMER OF WARRANTY
+PAYPAL LICENSES THE SOFTWARE AND DOCUMENTATION TO YOU ONLY ON AN "AS IS" BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  PAYPAL MAKES NO WARRANTY THAT THE SOFTWARE OR DOCUMENTATION WILL BE ERROR-FREE.  Each user of the Software or Documentation is solely responsible for determining the appropriateness of using and distributing the Software and Documentation and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs, or equipment, and unavailability or interruption of operations.  Use of the Software and Documentation is made with the understanding that PayPal will not provide you with any technical or customer support or maintenance.  Some states or jurisdictions do not allow the exclusion of implied warranties or limitations on how long an implied warranty may last, so the above limitations may not apply to you.  To the extent permissible, any implied warranties are limited to ninety (90) days.
+
+
+3.  LIMITATION OF LIABILITY
+PAYPAL AND ITS SUPPLIERS SHALL NOT BE LIABLE FOR LOSS OR DAMAGE ARISING OUT OF THIS AGREEMENT OR FROM THE USE OF THE SOFTWARE OR DOCUMENTATION.  IN NO EVENT WILL PAYPAL OR ITS SUPPLIERS BE LIABLE TO YOU OR ANY THIRD PARTY FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, INCIDENTAL, OR SPECIAL DAMAGES INCLUDING LOST PROFITS, LOST SAVINGS, COSTS, FEES, OR EXPENSES OF ANY KIND ARISING OUT OF ANY PROVISION OF THIS AGREEMENT OR THE USE OR THE INABILITY TO USE THE SOFTWARE OR DOCUMENTATION, HOWEVER CAUSED AND UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.  PAYPAL'S AGGREGATE LIABILITY AND THAT OF ITS SUPPLIERS UNDER OR IN CONNECTION WITH THIS AGREEMENT SHALL BE LIMITED TO THE AMOUNT PAID BY YOU FOR THE SOFTWARE AND DOCUMENTATION. 
+
+4.  TRADEMARK USAGE
+PayPal is a trademark PayPal, Inc. in the United States and other countries.  Such trademarks may not be used to endorse or promote any product unless expressly permitted under separate agreement with PayPal.  
+
+5.  TERM
+Your rights under this Agreement shall terminate if you fail to comply with any of the material  terms or conditions of this Agreement and do not cure such failure in a reasonable period of time after becoming aware of such noncompliance.  If all your rights under this Agreement terminate, you agree to cease use and distribution of the Software and Documentation as soon as reasonably practicable. 
+
+6. GOVERNING LAW AND JURISDICTION. This Agreement is governed by the statutes and laws of the State of California, without regard to the conflicts of law principles thereof.  If any part of this Agreement is found void and unenforceable, it will not affect the validity of the balance of the Agreement, which shall remain valid and enforceable according to its terms.  Any dispute arising out of or related to this Agreement shall be brought in the courts of Santa Clara County, California, USA. 
+
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/README.md b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/README.md
new file mode 100644 (file)
index 0000000..035c047
--- /dev/null
@@ -0,0 +1,42 @@
+### PayPal Core SDK - V2.4.0
+
+#### Prerequisites
+
+ * PHP 5.3 and above
+ * curl extension with support for OpenSSL
+ * PHPUnit 3.5 for running test suite (Optional)
+ * Composer
+
+#### Configuration
+  
+#### OpenID Connect Integration
+
+   1. Redirect your buyer to `PPOpenIdSession::getAuthorizationUrl($redirectUri, array('openid', 'address'));` to obtain authorization. The second argument is the list of access privileges that you want from the buyer.
+   2. Capture the authorization code that is available as a query parameter (`code`) in the redirect url
+   3. Exchange the authorization code for a access token, refresh token, id token combo
+
+
+```php
+    $token = PPOpenIdTokeninfo::createFromAuthorizationCode(
+               array(
+                       'code' => $authCode
+               )
+       );
+```
+   4. The access token is valid for a predefined duration and can be used for seamless XO or for retrieving user information
+
+
+```php
+   $user = PPOpenIdUserinfo::getUserinfo(
+               array(
+                       'access_token' => $token->getAccessToken()
+               )       
+       );
+```
+   5. If the access token has expired, you can obtain a new access token using the refresh token from the 3'rd step.
+
+```php
+   $token->createFromRefreshToken(array('openid', 'address'));
+```
+   6. Redirect your buyer to `PPOpenIdSession::getLogoutUrl($redirectUri, $idToken);` to log him out of paypal. 
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/build.xml b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/build.xml
new file mode 100644 (file)
index 0000000..0496420
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE project>
+<project name="PayPal_Core_SDK" default="build">
+
+       <property name="tests.dir" value="tests"/>
+       <property name="tests.out.dir" value="tests\reports"/>
+       
+       <condition property="PHPUNIT_BIN" value="phpunit.bat" else="phpunit">
+               <os family="windows" />
+       </condition>
+
+       <target name="clean">
+               <delete dir="${tests.out.dir}" />
+       </target>
+
+       <target name="test">
+               <mkdir dir="${tests.out.dir}" />
+               <exec dir="${basedir}" executable="${PHPUNIT_BIN}" failonerror="true">
+                       <arg line="--testdox --bootstrap ${tests.dir}\PPBootStrap.php --log-junit ${tests.out.dir}\phpunit.xml ${tests.dir}" />
+               </exec>
+       </target>
+
+       <target name="build" depends="clean, test" />
+</project>
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/composer.json b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/composer.json
new file mode 100644 (file)
index 0000000..961fb47
--- /dev/null
@@ -0,0 +1,23 @@
+{
+    "name": "paypal/sdk-core-php",
+    "description": "PayPal Core SDK for PHP",
+    "keywords": ["paypal", "php", "sdk"],
+    "type": "library",
+    "homepage": "https://github.com/paypal/sdk-core-php",
+    "license": "Apache2",
+    "authors": [
+        {
+            "name": "PayPal",
+            "homepage": "https://github.com/paypal/sdk-core-php/contributors"
+        }
+    ],
+    "require": {
+        "php": ">=5.3.0",
+        "ext-curl": "*"
+    },
+    "autoload": {
+        "psr-0": {
+            "PayPal": "lib/"
+        }
+    } 
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/IPPCredential.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/IPPCredential.php
new file mode 100644 (file)
index 0000000..da994c4
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+namespace PayPal\Auth;
+/**
+ * Interface that represents API credentials
+ */
+abstract class IPPCredential
+{
+       /**
+        * 
+        * @var IPPThirdPartyAuthorization
+        */
+       protected $thirdPartyAuthorization;
+       
+       public function setThirdPartyAuthorization($thirdPartyAuthorization) {
+               $this->thirdPartyAuthorization = $thirdPartyAuthorization;
+       }
+       
+       public function getThirdPartyAuthorization() {
+               return $this->thirdPartyAuthorization;
+       }
+       
+       public abstract function validate();
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/IPPThirdPartyAuthorization.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/IPPThirdPartyAuthorization.php
new file mode 100644 (file)
index 0000000..f019dfa
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+namespace PayPal\Auth;
+/**
+ * 
+ * Marker interface for implementations of third party authorization.
+ * Third-party authorization allows you to make an API call on some 
+ * other account\92s behalf 
+ */
+interface IPPThirdPartyAuthorization {
+       
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/AuthSignature.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/AuthSignature.php
new file mode 100644 (file)
index 0000000..22bf706
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+namespace PayPal\Auth\Oauth;
+//PayPal specific modification
+//Method to be called for generating signature
+
+class AuthSignature {
+
+       public function genSign($key, $secret, $token, $tokenSecret, $httpMethod, $endpoint) {
+
+               $authServer = new OAuthServer(new MockOAuthDataStore());
+               $hmac_method = new OAuthSignatureMethodHmacSha1();
+               $authServer->add_signature_method($hmac_method);
+
+               $sig_method = $hmac_method;
+               $authConsumer = new OAuthConsumer($key, $secret, NULL);
+               $authToken = NULL;
+               $authToken = new OAuthToken($token, $tokenSecret);
+
+               //$params is the query param array which is required only in the httpMethod is "GET"
+               $params = array();
+               //TODO: set the Query parameters to $params if httpMethod is "GET"
+
+               $acc_req = OAuthRequest::from_consumer_and_token($authConsumer, $authToken, $httpMethod, $endpoint, $params);
+               $acc_req->sign_request($sig_method,$authConsumer, $authToken);
+               return  OAuthutil::parseQueryString($acc_req);
+       }
+       
+       public static function generateFullAuthString($key, $secret, $token, $tokenSecret, $httpMethod, $endpoint) {
+               $authSignature = new AuthSignature();
+               $response = $authSignature->genSign($key, $secret, $token, $tokenSecret, $httpMethod, $endpoint);
+               return "token=" . $token . 
+                          ",signature=" . $response['oauth_signature'] .
+                      ",timestamp=" . $response['oauth_timestamp'];            
+       }
+       
+}
+?>
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/MockOAuthDataStore.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/MockOAuthDataStore.php
new file mode 100644 (file)
index 0000000..c9f0833
--- /dev/null
@@ -0,0 +1,54 @@
+<?php //vim: foldmethod=marker
+namespace PayPal\Auth\Oauth;
+class MockOAuthDataStore extends OAuthDataStore {/*{{{*/
+    private $consumer;
+    private $request_token;
+    private $access_token;
+    private $nonce;
+
+    function __construct() {/*{{{*/
+        $this->consumer = new OAuthConsumer("key", "secret", NULL);
+        $this->request_token = new OAuthToken("requestkey", "requestsecret", 1);
+        $this->access_token = new OAuthToken("accesskey", "accesssecret", 1);
+        $this->nonce = "nonce";
+    }/*}}}*/
+
+    function lookup_consumer($consumer_key) {/*{{{*/
+        if ($consumer_key == $this->consumer->key) return $this->consumer;
+        return NULL;
+    }/*}}}*/
+
+    function lookup_token($consumer, $token_type, $token) {/*{{{*/
+        $token_attrib = $token_type . "_token";
+        if ($consumer->key == $this->consumer->key
+            && $token == $this->$token_attrib->key) {
+            return $this->$token_attrib;
+        }
+        return NULL;
+    }/*}}}*/
+
+    function lookup_nonce($consumer, $token, $nonce, $timestamp) {/*{{{*/
+        if ($consumer->key == $this->consumer->key
+            && (($token && $token->key == $this->request_token->key)
+                || ($token && $token->key == $this->access_token->key))
+            && $nonce == $this->nonce) {
+            return $this->nonce;
+        }
+        return NULL;
+    }/*}}}*/
+
+    function new_request_token($consumer, $callback = NULL) {/*{{{*/
+        if ($consumer->key == $this->consumer->key) {
+            return $this->request_token;
+        }
+        return NULL;
+    }/*}}}*/
+
+    function new_access_token($token, $consumer, $verifier = NULL) {/*{{{*/
+        if ($consumer->key == $this->consumer->key
+            && $token->key == $this->request_token->key) {
+            return $this->access_token;
+        }
+        return NULL;
+    }/*}}}*/
+}/*}}}*/
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthConsumer.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthConsumer.php
new file mode 100644 (file)
index 0000000..95bb48e
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+namespace PayPal\Auth\Oauth;
+class OAuthConsumer {
+       public $key;
+       public $secret;
+
+       function __construct($key, $secret, $callback_url=NULL) {
+               $this->key = $key;
+               $this->secret = $secret;
+               $this->callback_url = $callback_url;
+       }
+
+       function __toString() {
+               return "OAuthConsumer[key=$this->key,secret=$this->secret]";
+       }
+}
+?>
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthDataStore.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthDataStore.php
new file mode 100644 (file)
index 0000000..2133acc
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+namespace PayPal\Auth\Oauth;
+class OAuthDataStore {
+       function lookup_consumer($consumer_key) {
+               // implement me
+       }
+
+       function lookup_token($consumer, $token_type, $token) {
+               // implement me
+       }
+
+       function lookup_nonce($consumer, $token, $nonce, $timestamp) {
+               // implement me
+       }
+
+       function new_request_token($consumer, $callback = null) {
+               // return a new token attached to this consumer
+       }
+
+       function new_access_token($token, $consumer, $verifier = null) {
+               // return a new access token attached to this consumer
+               // for the user associated with this token if the request token
+               // is authorized
+               // should also invalidate the request token
+       }
+
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthRequest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthRequest.php
new file mode 100644 (file)
index 0000000..fe86dd8
--- /dev/null
@@ -0,0 +1,297 @@
+<?php
+namespace PayPal\Auth\Oauth;
+class OAuthRequest {
+       public $parameters;
+       protected $http_method;
+       protected $http_url;
+       // for debug purposes
+       public $base_string;
+       public static $version = '1.0';
+       public static $POST_INPUT = 'php://input';
+
+       function __construct($http_method, $http_url, $parameters=NULL) {
+               $parameters = ($parameters) ? $parameters : array();
+               $parameters = array_merge( OAuthUtil::parse_parameters(parse_url($http_url, PHP_URL_QUERY)), $parameters);
+               $this->parameters = $parameters;
+               $this->http_method = $http_method;
+               $this->http_url = $http_url;
+       }
+
+
+       /**
+        * attempt to build up a request from what was passed to the server
+        */
+       public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {
+               $scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")
+               ? 'http'
+               : 'https';
+               $http_url = ($http_url) ? $http_url : $scheme .
+                              '://' . $_SERVER['HTTP_HOST'] .
+                              ':' .
+               $_SERVER['SERVER_PORT'] .
+               $_SERVER['REQUEST_URI'];
+               $http_method = ($http_method) ? $http_method : $_SERVER['REQUEST_METHOD'];
+
+               // We weren't handed any parameters, so let's find the ones relevant to
+               // this request.
+               // If you run XML-RPC or similar you should use this to provide your own
+               // parsed parameter-list
+               if (!$parameters) {
+                       // Find request headers
+                       $request_headers = OAuthUtil::get_headers();
+
+                       // Parse the query-string to find GET parameters
+                       $parameters = OAuthUtil::parse_parameters($_SERVER['QUERY_STRING']);
+
+                       // It's a POST request of the proper content-type, so parse POST
+                       // parameters and add those overriding any duplicates from GET
+                       if ($http_method == "POST"
+                       &&  isset($request_headers['Content-Type'])
+                       && strstr($request_headers['Content-Type'],
+                     'application/x-www-form-urlencoded')
+                       ) {
+                               $post_data = OAuthUtil::parse_parameters(
+                               file_get_contents(self::$POST_INPUT)
+                               );
+                               $parameters = array_merge($parameters, $post_data);
+                       }
+
+                       // We have a Authorization-header with OAuth data. Parse the header
+                       // and add those overriding any duplicates from GET or POST
+                       if (isset($request_headers['Authorization']) && substr($request_headers['Authorization'], 0, 6) == 'OAuth ') {
+                               $header_parameters = OAuthUtil::split_header(
+                               $request_headers['Authorization']
+                               );
+                               $parameters = array_merge($parameters, $header_parameters);
+                       }
+
+               }
+
+               return new OAuthRequest($http_method, $http_url, $parameters);
+       }
+
+       /**
+        * pretty much a helper function to set up the request
+        */
+       public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=NULL) {
+               $parameters = ($parameters) ?  $parameters : array();
+               $defaults = array("oauth_version" => OAuthRequest::$version,
+               // "oauth_nonce" => OAuthRequest::generate_nonce(),
+               "oauth_timestamp" => OAuthRequest::generate_timestamp(),
+
+                      "oauth_consumer_key" => $consumer->key);
+               if ($token)
+               $defaults['oauth_token'] = $token->key;
+
+               $parameters = array_merge($defaults, $parameters);
+               ksort($parameters);
+               return new OAuthRequest($http_method, $http_url, $parameters);
+       }
+
+       public function set_parameter($name, $value, $allow_duplicates = true) {
+               if ($allow_duplicates && isset($this->parameters[$name])) {
+                       // We have already added parameter(s) with this name, so add to the list
+                       if (is_scalar($this->parameters[$name])) {
+                               // This is the first duplicate, so transform scalar (string)
+                               // into an array so we can add the duplicates
+                               $this->parameters[$name] = array($this->parameters[$name]);
+                       }
+
+                       $this->parameters[$name][] = $value;
+               } else {
+                       $this->parameters[$name] = $value;
+               }
+       }
+
+       public function get_parameter($name) {
+               return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
+       }
+
+       public function get_parameters() {
+               return $this->parameters;
+       }
+
+       public function unset_parameter($name) {
+               unset($this->parameters[$name]);
+       }
+
+       /**
+        * The request parameters, sorted and concatenated into a normalized string.
+        * @return string
+        */
+       public function get_signable_parameters() {
+               // Grab all parameters
+               $params = $this->parameters;
+               ksort($params);
+               // Remove oauth_signature if present
+               // Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.")
+               if (isset($params['oauth_signature'])) {
+                       unset($params['oauth_signature']);
+               }
+               foreach($params as $key => $value)
+               {
+                       $res[]=$key."=".$value;
+               }
+
+               return implode('&', $res);
+               //return OAuthUtil::build_http_query($params);
+       }
+
+       /**
+        * Returns the base string of this request
+        *
+        * The base string defined as the method, the url
+        * and the parameters (normalized), each urlencoded
+        * and the concated with &.
+        */
+       public function get_signature_base_string() {
+               $parts = array(
+               $this->get_normalized_http_method(),
+               $this->get_normalized_http_url(),
+               $this->get_signable_parameters()
+               );
+
+               $parts = OAuthUtil::urlencode_rfc3986($parts);
+
+               return implode('&', $parts);
+       }
+
+       /**
+        * just uppercases the http method
+        */
+       public function get_normalized_http_method() {
+               return strtoupper($this->http_method);
+       }
+
+       /**
+        * parses the url and rebuilds it to be
+        * scheme://host/path
+        */
+       public function get_normalized_http_url() {
+               $parts = parse_url($this->http_url);
+
+               $scheme = (isset($parts['scheme'])) ? $parts['scheme'] : 'http';
+               $port = (isset($parts['port'])) ? $parts['port'] : (($scheme == 'https') ? '443' : '80');
+               $host = (isset($parts['host'])) ? $parts['host'] : '';
+               $path = (isset($parts['path'])) ? $parts['path'] : '';
+
+               if (($scheme == 'https' && $port != '443')
+               || ($scheme == 'http' && $port != '80')) {
+                       $host = "$host:$port";
+               }
+               return "$scheme://$host$path";
+       }
+
+       /**
+        * builds a url usable for a GET request
+        */
+       public function to_url() {
+               $post_data = $this->to_postdata();
+               $out = $this->get_normalized_http_url();
+               if ($post_data) {
+                       $out .= '?'.$post_data;
+               }
+               return $out;
+       }
+
+       /**
+        * builds the data one would send in a POST request
+        */
+       public function to_postdata() {
+               return OAuthUtil::build_http_query($this->parameters);
+       }
+
+       /**
+        * builds the Authorization: header
+        */
+       public function to_header($realm=null) {
+               $first = true;
+               if($realm) {
+                       $out = 'Authorization: OAuth realm="' . OAuthUtil::urlencode_rfc3986($realm) . '"';
+                       $first = false;
+               } else
+               $out = 'Authorization: OAuth';
+
+               $total = array();
+               foreach ($this->parameters as $k => $v) {
+                       if (substr($k, 0, 5) != "oauth") continue;
+                       if (is_array($v)) {
+                               throw new OAuthException('Arrays not supported in headers');
+                       }
+                       $out .= ($first) ? ' ' : ',';
+                       $out .= OAuthUtil::urlencode_rfc3986($k) .
+              '="' .
+                       OAuthUtil::urlencode_rfc3986($v) .
+              '"';
+                       $first = false;
+               }
+               return $out;
+       }
+
+       public function __toString() {
+               return $this->to_url();
+       }
+
+
+       public function sign_request($signature_method,$consumer, $token) {
+                       
+               $empty=false;
+               $msg=array();
+               if( $token->key==null){
+                       $msg[] = 'Token key';
+               }
+               if($token->secret==null){
+                       $msg[] = 'Token secret';
+               }
+               if($consumer->key == null){
+
+                       $msg[] = 'Consumer key';
+               }
+               if($consumer->secret == null){
+
+                       $msg[] = 'Consumer secret';
+               }
+               if($this->http_url == null){
+
+                       $msg[] ='Endpoint';
+               }
+               if($this->http_method == null){
+
+                       $msg[] ='HTTP method';
+               }
+               if(count($msg))
+               {
+                       throw new OAuthException('Enter valid '. implode(',',$msg));
+               }
+               $this->set_parameter(
+      "oauth_signature_method",
+               $signature_method->get_name(),
+               false );
+
+               $signature = $this->build_signature($signature_method, $consumer, $token);
+               $this->set_parameter("oauth_signature", $signature, false);
+
+       }
+
+       public function build_signature($signature_method, $consumer, $token) {
+               $signature = $signature_method->build_signature($this, $consumer, $token);
+               return $signature;
+       }
+
+       /**
+        * util function: current timestamp
+        */
+       private static function generate_timestamp() {
+               return time();
+       }
+
+       /**
+        * util function: current nonce
+        */
+       private static function generate_nonce() {
+               $mt = microtime();
+               $rand = mt_rand();
+
+               return md5($mt . $rand); // md5s look nicer than numbers
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthServer.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthServer.php
new file mode 100644 (file)
index 0000000..48c3257
--- /dev/null
@@ -0,0 +1,223 @@
+<?php
+namespace PayPal\Auth\Oauth;
+class OAuthServer {
+       protected $timestamp_threshold = 300; // in seconds, five minutes
+       protected $version = '1.0';             // hi blaine
+       protected $signature_methods = array();
+
+       protected $data_store;
+
+       function __construct($data_store) {
+               $this->data_store = $data_store;
+       }
+
+       public function add_signature_method($signature_method) {
+               $this->signature_methods[$signature_method->get_name()] =
+               $signature_method;
+       }
+
+       // high level functions
+
+       /**
+        * process a request_token request
+        * returns the request token on success
+        */
+       public function fetch_request_token(&$request) {
+               $this->get_version($request);
+
+               $consumer = $this->get_consumer($request);
+
+               // no token required for the initial token request
+               $token = NULL;
+
+               $this->check_signature($request, $consumer, $token);
+
+               // Rev A change
+               $callback = $request->get_parameter('oauth_callback');
+               $new_token = $this->data_store->new_request_token($consumer, $callback);
+
+               return $new_token;
+       }
+
+       /**
+        * process an access_token request
+        * returns the access token on success
+        */
+       public function fetch_access_token(&$request) {
+               $this->get_version($request);
+
+               $consumer = $this->get_consumer($request);
+
+               // requires authorized request token
+               $token = $this->get_token($request, $consumer, "request");
+
+               $this->check_signature($request, $consumer, $token);
+
+               // Rev A change
+               $verifier = $request->get_parameter('oauth_verifier');
+               $new_token = $this->data_store->new_access_token($token, $consumer, $verifier);
+
+               return $new_token;
+       }
+
+       /**
+        * verify an api call, checks all the parameters
+        */
+       public function verify_request(&$request) {
+               $this->get_version($request);
+               $consumer = $this->get_consumer($request);
+               $token = $this->get_token($request, $consumer, "access");
+               $this->check_signature($request, $consumer, $token);
+               return array($consumer, $token);
+       }
+
+       // Internals from here
+       /**
+        * version 1
+        */
+       private function get_version(&$request) {
+               $version = $request->get_parameter("oauth_version");
+               if (!$version) {
+                       // Service Providers MUST assume the protocol version to be 1.0 if this parameter is not present.
+                       // Chapter 7.0 ("Accessing Protected Ressources")
+                       $version = '1.0';
+               }
+               if ($version !== $this->version) {
+                       throw new OAuthException("OAuth version '$version' not supported");
+               }
+               return $version;
+       }
+
+       /**
+        * figure out the signature with some defaults
+        */
+       private function get_signature_method($request) {
+               $signature_method = $request instanceof OAuthRequest
+               ? $request->get_parameter("oauth_signature_method")
+               : NULL;
+
+               if (!$signature_method) {
+                       // According to chapter 7 ("Accessing Protected Ressources") the signature-method
+                       // parameter is required, and we can't just fallback to PLAINTEXT
+                       throw new OAuthException('No signature method parameter. This parameter is required');
+               }
+
+               if (!in_array($signature_method,
+               array_keys($this->signature_methods))) {
+                       throw new OAuthException(
+        "Signature method '$signature_method' not supported " .
+        "try one of the following: " .
+                       implode(", ", array_keys($this->signature_methods))
+                       );
+               }
+               return $this->signature_methods[$signature_method];
+       }
+
+       /**
+        * try to find the consumer for the provided request's consumer key
+        */
+       private function get_consumer($request) {
+               $consumer_key = $request instanceof OAuthRequest
+               ? $request->get_parameter("oauth_consumer_key")
+               : NULL;
+
+               if (!$consumer_key) {
+                       throw new OAuthException("Invalid consumer key");
+               }
+
+               $consumer = $this->data_store->lookup_consumer($consumer_key);
+               if (!$consumer) {
+                       throw new OAuthException("Invalid consumer");
+               }
+
+               return $consumer;
+       }
+
+       /**
+        * try to find the token for the provided request's token key
+        */
+       private function get_token($request, $consumer, $token_type="access") {
+               $token_field = $request instanceof OAuthRequest
+               ? $request->get_parameter('oauth_token')
+               : NULL;
+
+               $token = $this->data_store->lookup_token(
+               $consumer, $token_type, $token_field
+               );
+               if (!$token) {
+                       throw new OAuthException("Invalid $token_type token: $token_field");
+               }
+               return $token;
+       }
+
+       /**
+        * all-in-one function to check the signature on a request
+        * should guess the signature method appropriately
+        */
+       private function check_signature($request, $consumer, $token) {
+               // this should probably be in a different method
+               $timestamp = $request instanceof OAuthRequest
+               ? $request->get_parameter('oauth_timestamp')
+               : NULL;
+               $nonce = $request instanceof OAuthRequest
+               ? $request->get_parameter('oauth_nonce')
+               : NULL;
+
+               $this->check_timestamp($timestamp);
+               $this->check_nonce($consumer, $token, $nonce, $timestamp);
+
+               $signature_method = $this->get_signature_method($request);
+
+               $signature = $request->get_parameter('oauth_signature');
+               $valid_sig = $signature_method->check_signature(
+               $request,
+               $consumer,
+               $token,
+               $signature
+               );
+
+               if (!$valid_sig) {
+                       throw new OAuthException("Invalid signature");
+               }
+       }
+
+       /**
+        * check that the timestamp is new enough
+        */
+       private function check_timestamp($timestamp) {
+               if( ! $timestamp )
+               throw new OAuthException(
+        'Missing timestamp parameter. The parameter is required'
+        );
+
+        // verify that timestamp is recentish
+        $now = time();
+        if (abs($now - $timestamp) > $this->timestamp_threshold) {
+               throw new OAuthException(
+        "Expired timestamp, yours $timestamp, ours $now"
+               );
+        }
+       }
+
+       /**
+        * check that the nonce is not repeated
+        */
+       private function check_nonce($consumer, $token, $nonce, $timestamp) {
+               if( ! $nonce )
+               throw new OAuthException(
+        'Missing nonce parameter. The parameter is required'
+        );
+
+        // verify that the nonce is uniqueish
+        $found = $this->data_store->lookup_nonce(
+        $consumer,
+        $token,
+        $nonce,
+        $timestamp
+        );
+        if ($found) {
+               throw new OAuthException("Nonce already used: $nonce");
+        }
+       }
+
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthSignatureMethod.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthSignatureMethod.php
new file mode 100644 (file)
index 0000000..2e557d9
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+namespace PayPal\Auth\Oauth;
+/**
+ * A class for implementing a Signature Method
+ * See section 9 ("Signing Requests") in the spec
+ */
+abstract class OAuthSignatureMethod {
+       /**
+        * Needs to return the name of the Signature Method (ie HMAC-SHA1)
+        * @return string
+        */
+       abstract public function get_name();
+
+       /**
+        * Build up the signature
+        * NOTE: The output of this function MUST NOT be urlencoded.
+        * the encoding is handled in OAuthRequest when the final
+        * request is serialized
+        * @param OAuthRequest $request
+        * @param OAuthConsumer $consumer
+        * @param OAuthToken $token
+        * @return string
+        */
+       abstract public function build_signature($request, $consumer, $token);
+
+       /**
+        * Verifies that a given signature is correct
+        * @param OAuthRequest $request
+        * @param OAuthConsumer $consumer
+        * @param OAuthToken $token
+        * @param string $signature
+        * @return bool
+        */
+       public function check_signature($request, $consumer, $token, $signature) {
+               $built = $this->build_signature($request, $consumer, $token);
+               return $built == $signature;
+       }
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthSignatureMethodHmacSha1.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthSignatureMethodHmacSha1.php
new file mode 100644 (file)
index 0000000..2c35c97
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+namespace PayPal\Auth\Oauth;
+/**
+ * The HMAC-SHA1 signature method uses the HMAC-SHA1 signature algorithm as defined in [RFC2104]
+ * where the Signature Base String is the text and the key is the concatenated values (each first
+ * encoded per Parameter Encoding) of the Consumer Secret and Token Secret, separated by an '&'
+ * character (ASCII code 38) even if empty.
+ *   - Chapter 9.2 ("HMAC-SHA1")
+ */
+class OAuthSignatureMethodHmacSha1 extends OAuthSignatureMethod {
+       function get_name() {
+               return "HMAC-SHA1";
+       }
+
+       public function build_signature($request, $consumer, $token) {
+               $base_string = $request->get_signature_base_string();
+               $base_string=preg_replace("/(%[A-Za-z0-9]{2})/e", "strtolower('\\0')", $base_string);//convert base string to lowercase
+               $request->base_string = $base_string;
+
+               $key_parts = array(
+               $consumer->secret,
+               ($token) ? $token->secret : ""
+               );
+
+               $key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
+               $key = implode('&', $key_parts);
+               $key=preg_replace("/(%[A-Za-z0-9]{2})/e", "strtolower('\\0')", $key);//convert to lowercase
+               return base64_encode(hash_hmac('sha1', $base_string, $key, true));
+       }
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthSignatureMethodPLAINTEXT.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthSignatureMethodPLAINTEXT.php
new file mode 100644 (file)
index 0000000..c29ebf3
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+namespace PayPal\Auth\Oauth;
+/**
+ * The PLAINTEXT method does not provide any security protection and SHOULD only be used
+ * over a secure channel such as HTTPS. It does not use the Signature Base String.
+ *   - Chapter 9.4 ("PLAINTEXT")
+ */
+class OAuthSignatureMethodPLAINTEXT extends OAuthSignatureMethod {
+       public function get_name() {
+               return "PLAINTEXT";
+       }
+
+       /**
+        * oauth_signature is set to the concatenated encoded values of the Consumer Secret and
+        * Token Secret, separated by a '&' character (ASCII code 38), even if either secret is
+        * empty. The result MUST be encoded again.
+        *   - Chapter 9.4.1 ("Generating Signatures")
+        *
+        * Please note that the second encoding MUST NOT happen in the SignatureMethod, as
+        * OAuthRequest handles this!
+        */
+       public function build_signature($request, $consumer, $token) {
+               $key_parts = array(
+               $consumer->secret,
+               ($token) ? $token->secret : ""
+               );
+
+               $key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
+               $key = implode('&', $key_parts);
+               $request->base_string = $key;
+
+               return $key;
+       }
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthSignatureMethodRsaSha1.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthSignatureMethodRsaSha1.php
new file mode 100644 (file)
index 0000000..8dbcc5e
--- /dev/null
@@ -0,0 +1,68 @@
+<?php
+namespace PayPal\Auth\Oauth;
+/**
+ * The RSA-SHA1 signature method uses the RSASSA-PKCS1-v1_5 signature algorithm as defined in
+ * [RFC3447] section 8.2 (more simply known as PKCS#1), using SHA-1 as the hash function for
+ * EMSA-PKCS1-v1_5. It is assumed that the Consumer has provided its RSA public key in a
+ * verified way to the Service Provider, in a manner which is beyond the scope of this
+ * specification.
+ *   - Chapter 9.3 ("RSA-SHA1")
+ */
+abstract class OAuthSignatureMethodRsaSha1 extends OAuthSignatureMethod {
+       public function get_name() {
+               return "RSA-SHA1";
+       }
+
+       // Up to the SP to implement this lookup of keys. Possible ideas are:
+       // (1) do a lookup in a table of trusted certs keyed off of consumer
+       // (2) fetch via http using a url provided by the requester
+       // (3) some sort of specific discovery code based on request
+       //
+       // Either way should return a string representation of the certificate
+       protected abstract function fetch_public_cert(&$request);
+
+       // Up to the SP to implement this lookup of keys. Possible ideas are:
+       // (1) do a lookup in a table of trusted certs keyed off of consumer
+       //
+       // Either way should return a string representation of the certificate
+       protected abstract function fetch_private_cert(&$request);
+
+       public function build_signature($request, $consumer, $token) {
+               $base_string = $request->get_signature_base_string();
+               $request->base_string = $base_string;
+
+               // Fetch the private key cert based on the request
+               $cert = $this->fetch_private_cert($request);
+
+               // Pull the private key ID from the certificate
+               $privatekeyid = openssl_get_privatekey($cert);
+
+               // Sign using the key
+               $ok = openssl_sign($base_string, $signature, $privatekeyid);
+
+               // Release the key resource
+               openssl_free_key($privatekeyid);
+
+               return base64_encode($signature);
+       }
+
+       public function check_signature($request, $consumer, $token, $signature) {
+               $decoded_sig = base64_decode($signature);
+
+               $base_string = $request->get_signature_base_string();
+
+               // Fetch the public key cert based on the request
+               $cert = $this->fetch_public_cert($request);
+
+               // Pull the public key ID from the certificate
+               $publickeyid = openssl_get_publickey($cert);
+
+               // Check the computed signature against the one passed in the query
+               $ok = openssl_verify($base_string, $decoded_sig, $publickeyid);
+
+               // Release the key resource
+               openssl_free_key($publickeyid);
+
+               return $ok == 1;
+       }
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthToken.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthToken.php
new file mode 100644 (file)
index 0000000..50563e7
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+namespace PayPal\Auth\Oauth;
+class OAuthToken {
+       // access tokens and request tokens
+       public $key;
+       public $secret;
+
+       /**
+        * key = the token
+        * secret = the token secret
+        */
+       function __construct($key, $secret) {
+               $this->key = $key;
+               $this->secret = $secret;
+       }
+
+       /**
+        * generates the basic string serialization of a token that a server
+        * would respond to request_token and access_token calls with
+        */
+       function to_string() {
+               return "oauth_token=" .
+               OAuthUtil::urlencode_rfc3986($this->key) .
+           "&oauth_token_secret=" .
+               OAuthUtil::urlencode_rfc3986($this->secret);
+       }
+
+       function __toString() {
+               return $this->to_string();
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthUtil.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthUtil.php
new file mode 100644 (file)
index 0000000..8c7d34c
--- /dev/null
@@ -0,0 +1,169 @@
+<?php
+namespace PayPal\Auth\Oauth;
+class OAuthUtil {
+       public static function urlencode_rfc3986($input) {
+               if (is_array($input)) {
+                       return array_map(array('PayPal\Auth\Oauth\OAuthUtil', 'urlencode_rfc3986'), $input);
+               } else if (is_scalar($input)) {
+                       $tmp1=str_replace('%7E', '~', rawurlencode($input));
+                       $tmp2=str_replace(".","%2E",$tmp1);
+                       $tmp3=str_replace("*","%2A",$tmp2);
+                       $tmp4=str_replace( '+', ' ',$tmp3);
+                       $tmp=str_replace("-","%2D",$tmp4);
+                       return $tmp;
+                       /*$tmp1=str_replace('%7E', '~', rawurlencode($input));
+                        $tmp2= str_replace(".","%2E",$tmp1);
+                               
+                               
+                        return $tmp;*/
+               }
+               else {
+                       return '';
+               }
+       }
+       public static function parseQueryString($str) {
+               $op = array();
+               $pairs = explode("&", $str);
+               foreach ($pairs as $pair) {
+                       list($k, $v) = array_map("urldecode", explode("=", $pair));
+                       $op[$k] = $v;
+               }
+               return $op;
+       }
+       //parses string to associative array -modified for PayPal Signature
+
+
+       // This decode function isn't taking into consideration the above
+       // modifications to the encoding process. However, this method doesn't
+       // seem to be used anywhere so leaving it as is.
+       public static function urldecode_rfc3986($string) {
+               return urldecode($string);
+       }
+
+       // Utility function for turning the Authorization: header into
+       // parameters, has to do some unescaping
+       // Can filter out any non-oauth parameters if needed (default behaviour)
+       // May 28th, 2010 - method updated to tjerk.meesters for a speed improvement.
+       //                  see http://code.google.com/p/oauth/issues/detail?id=163
+       public static function split_header($header, $only_allow_oauth_parameters = true) {
+               $params = array();
+               if (preg_match_all('/('.($only_allow_oauth_parameters ? 'oauth_' : '').'[a-z_-]*)=(:?"([^"]*)"|([^,]*))/', $header, $matches)) {
+                       foreach ($matches[1] as $i => $h) {
+                               $params[$h] = OAuthUtil::urldecode_rfc3986(empty($matches[3][$i]) ? $matches[4][$i] : $matches[3][$i]);
+                       }
+                       if (isset($params['realm'])) {
+                               unset($params['realm']);
+                       }
+               }
+               return $params;
+       }
+
+       // helper to try to sort out headers for people who aren't running apache
+       public static function get_headers() {
+               if (function_exists('apache_request_headers')) {
+                       // we need this to get the actual Authorization: header
+                       // because apache tends to tell us it doesn't exist
+                       $headers = apache_request_headers();
+
+                       // sanitize the output of apache_request_headers because
+                       // we always want the keys to be Cased-Like-This and arh()
+                       // returns the headers in the same case as they are in the
+                       // request
+                       $out = array();
+                       foreach ($headers AS $key => $value) {
+                               $key = str_replace(
+            " ",
+            "-",
+                               ucwords(strtolower(str_replace("-", " ", $key)))
+                               );
+                               $out[$key] = $value;
+                       }
+               } else {
+                       // otherwise we don't have apache and are just going to have to hope
+                       // that $_SERVER actually contains what we need
+                       $out = array();
+                       if( isset($_SERVER['CONTENT_TYPE']) )
+                       $out['Content-Type'] = $_SERVER['CONTENT_TYPE'];
+                       if( isset($_ENV['CONTENT_TYPE']) )
+                       $out['Content-Type'] = $_ENV['CONTENT_TYPE'];
+
+                       foreach ($_SERVER as $key => $value) {
+                               if (substr($key, 0, 5) == "HTTP_") {
+                                       // this is chaos, basically it is just there to capitalize the first
+                                       // letter of every word that is not an initial HTTP and strip HTTP
+                                       // code from przemek
+                                       $key = str_replace(
+            " ",
+            "-",
+                                       ucwords(strtolower(str_replace("_", " ", substr($key, 5))))
+                                       );
+                                       $out[$key] = $value;
+                               }
+                       }
+               }
+               return $out;
+       }
+
+       // This function takes a input like a=b&a=c&d=e and returns the parsed
+       // parameters like this
+       // array('a' => array('b','c'), 'd' => 'e')
+       public static function parse_parameters( $input ) {
+               if (!isset($input) || !$input) return array();
+
+               $pairs = explode('&', $input);
+
+               $parsed_parameters = array();
+               foreach ($pairs as $pair) {
+                       $split = explode('=', $pair, 2);
+                       $parameter = OAuthUtil::urldecode_rfc3986($split[0]);
+                       $value = isset($split[1]) ? OAuthUtil::urldecode_rfc3986($split[1]) : '';
+
+                       if (isset($parsed_parameters[$parameter])) {
+                               // We have already recieved parameter(s) with this name, so add to the list
+                               // of parameters with this name
+
+                               if (is_scalar($parsed_parameters[$parameter])) {
+                                       // This is the first duplicate, so transform scalar (string) into an array
+                                       // so we can add the duplicates
+                                       $parsed_parameters[$parameter] = array($parsed_parameters[$parameter]);
+                               }
+
+                               $parsed_parameters[$parameter][] = $value;
+                       } else {
+                               $parsed_parameters[$parameter] = $value;
+                       }
+               }
+               return $parsed_parameters;
+       }
+
+       public static function build_http_query($params) {
+               if (!$params) return '';
+
+               // Urlencode both keys and values
+               $keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
+               $values = OAuthUtil::urlencode_rfc3986(array_values($params));
+               $params = array_combine($keys, $values);
+
+               // Parameters are sorted by name, using lexicographical byte value ordering.
+               // Ref: Spec: 9.1.1 (1)
+               uksort($params, 'strcmp');
+
+               $pairs = array();
+               foreach ($params as $parameter => $value) {
+                       if (is_array($value)) {
+                               // If two or more parameters share the same name, they are sorted by their value
+                               // Ref: Spec: 9.1.1 (1)
+                               // June 12th, 2010 - changed to sort because of issue 164 by hidetaka
+                               sort($value, SORT_STRING);
+                               foreach ($value as $duplicate_value) {
+                                       $pairs[] = $parameter . '=' . $duplicate_value;
+                               }
+                       } else {
+                               $pairs[] = $parameter . '=' . $value;
+                       }
+               }
+               // For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
+               // Each name-value pair is separated by an '&' character (ASCII code 38)
+               return implode('&', $pairs);
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Openid/PPOpenIdAddress.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Openid/PPOpenIdAddress.php
new file mode 100644 (file)
index 0000000..4cee501
--- /dev/null
@@ -0,0 +1,95 @@
+<?php
+namespace PayPal\Auth\Openid;
+use PayPal\Common\PPModel;
+/**
+ * End-User's preferred address.
+ */
+class PPOpenIdAddress extends PPModel {
+
+               /**
+                * Full street address component, which may include house number, street name.
+                * @param string $street_address
+                */
+                public function setStreetAddress($street_address) {
+                       $this->street_address = $street_address;
+                       return $this;
+                }
+               
+               /**
+                * Full street address component, which may include house number, street name.
+                * @return string
+                */
+                public function getStreetAddress() {
+                       return $this->street_address;
+                }
+                
+               /**
+                * City or locality component.
+                * @param string $locality
+                */
+                public function setLocality($locality) {
+                       $this->locality = $locality;
+                       return $this;
+                }
+               
+               /**
+                * City or locality component.
+                * @return string
+                */
+                public function getLocality() {
+                       return $this->locality;
+                }
+                
+               /**
+                * State, province, prefecture or region component.
+                * @param string $region
+                */
+                public function setRegion($region) {
+                       $this->region = $region;
+                       return $this;
+                }
+               
+               /**
+                * State, province, prefecture or region component.
+                * @return string
+                */
+                public function getRegion() {
+                       return $this->region;
+                }
+                
+               /**
+                * Zip code or postal code component.
+                * @param string $postal_code
+                */
+                public function setPostalCode($postal_code) {
+                       $this->postal_code = $postal_code;
+                       return $this;
+                }
+               
+               /**
+                * Zip code or postal code component.
+                * @return string
+                */
+                public function getPostalCode() {
+                       return $this->postal_code;
+                }
+                
+               /**
+                * Country name component.
+                * @param string $country
+                */
+                public function setCountry($country) {
+                       $this->country = $country;
+                       return $this;
+                }
+               
+               /**
+                * Country name component.
+                * @return string
+                */
+                public function getCountry() {
+                       return $this->country;
+                }
+                
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Openid/PPOpenIdError.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Openid/PPOpenIdError.php
new file mode 100644 (file)
index 0000000..1c5e051
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+namespace PayPal\Auth\Openid;
+namespace PayPal\Common\PPModel;
+/**
+ * Error resource
+ */
+class PPOpenIdError extends PPModel {
+
+               /**
+                * A single ASCII error code from the following enum.
+                * @param string $error
+                */
+                public function setError($error) {
+                       $this->error = $error;
+                       return $this;
+                }
+               
+               /**
+                * A single ASCII error code from the following enum.
+                * @return string
+                */
+                public function getError() {
+                       return $this->error;
+                }
+                
+               /**
+                * A resource ID that indicates the starting resource in the returned results.
+                * @param string $error_description
+                */
+                public function setErrorDescription($error_description) {
+                       $this->error_description = $error_description;
+                       return $this;
+                }
+               
+               /**
+                * A resource ID that indicates the starting resource in the returned results.
+                * @return string
+                */
+                public function getErrorDescription() {
+                       return $this->error_description;
+                }
+                
+               /**
+                * A URI identifying a human-readable web page with information about the error, used to provide the client developer with additional information about the error.
+                * @param string $error_uri
+                */
+                public function setErrorUri($error_uri) {
+                       $this->error_uri = $error_uri;
+                       return $this;
+                }
+               
+               /**
+                * A URI identifying a human-readable web page with information about the error, used to provide the client developer with additional information about the error.
+                * @return string
+                */
+                public function getErrorUri() {
+                       return $this->error_uri;
+                }
+                
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Openid/PPOpenIdSession.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Openid/PPOpenIdSession.php
new file mode 100644 (file)
index 0000000..ba76f0a
--- /dev/null
@@ -0,0 +1,79 @@
+<?php
+namespace PayPal\Auth\Openid;
+use PayPal\Core\PPConstants;
+use PayPal\Common\PPApiContext;
+use PayPal\Core\PPConstants;
+class PPOpenIdSession {
+
+       /**
+        * Returns the PayPal URL to which the user must be redirected to
+        * start the authentication / authorization process.
+        *
+        * @param string $redirectUri Uri on merchant website to where
+        *                              the user must be redirected to post paypal login
+        * @param array $scope The access privilges that you are requesting for
+        *                              from the user. Pass empty array for all scopes.
+        *                              See https://developer.paypal.com/webapps/developer/docs/classic/loginwithpaypal/ht_OpenIDConnect/#parameters for more
+        * @param PPApiContext $apiContext Optional API Context
+        */
+       public static function getAuthorizationUrl($redirectUri, $scope, $apiContext=null) {
+
+               if(is_null($apiContext)) {
+                       $apiContext = new PPApiContext();
+               }
+               $config = $apiContext->getConfig();
+
+               $scope = count($scope) != 0 ? $scope : array('openid', 'profile', 'address', 'email', 'phone', 'https://uri.paypal.com/services/paypalattributes');
+               if(!in_array('openid', $scope)) {
+                       $scope[] = 'openid';
+               }
+               $params = array(
+                               'client_id' => $config['acct1.ClientId'],
+                               'response_type' => 'code',
+                               'scope' => implode(" ", $scope),
+                               'redirect_uri' => $redirectUri
+               );
+               return sprintf("%s/v1/authorize?%s", self::getBaseUrl($config), http_build_query($params));
+       }
+
+
+       /**
+        * Returns the URL to which the user must be redirected to
+        * logout from the OpenID provider (i.e. PayPal)
+        *
+        * @param string $redirectUri Uri on merchant website to where
+        *                              the user must be redirected to post logout
+        * @param string $idToken id_token from the TokenInfo object
+        * @param PayPal/Rest/APIContext $apiContext Optional API Context
+        */
+       public static function getLogoutUrl($redirectUri, $idToken, $apiContext=null) {
+               
+               if(is_null($apiContext)) {
+                       $apiContext = new PPApiContext();
+               }
+               $config = $apiContext->getConfig();
+               
+               PPConstants::OPENID_REDIRECT_LIVE_URL;
+               $params = array(
+                               'id_token' => $idToken,
+                               'redirect_uri' => $redirectUri,
+                               'logout' => 'true'
+               );
+               return sprintf("%s/v1/endsession?%s", self::getBaseUrl($config), http_build_query($params));
+       }
+
+       private static function getBaseUrl($config) {
+
+               if(array_key_exists('openid.RedirectUri', $config)) {
+                       return $config['openid.RedirectUri'];
+               } else if (array_key_exists('mode', $config)) {
+                       switch(strtoupper($config['mode'])) {
+                               case 'SANDBOX':
+                                       return PPConstants::OPENID_REDIRECT_SANDBOX_URL;
+                               case 'LIVE':
+                                       return PPConstants::OPENID_REDIRECT_LIVE_URL;   
+                       }
+               }
+               return ;
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Openid/PPOpenIdTokeninfo.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Openid/PPOpenIdTokeninfo.php
new file mode 100644 (file)
index 0000000..cdb90d0
--- /dev/null
@@ -0,0 +1,181 @@
+<?php
+namespace PayPal\Auth\Openid;
+use PayPal\Common\PPModel;
+/**
+ * Token grant resource
+ */
+class PPOpenIdTokeninfo extends PPModel {
+
+               /**
+                * OPTIONAL, if identical to the scope requested by the client; otherwise, REQUIRED.
+                * @param string $scope
+                */
+                public function setScope($scope) {
+                       $this->scope = $scope;
+                       return $this;
+                }
+               
+               /**
+                * OPTIONAL, if identical to the scope requested by the client; otherwise, REQUIRED.
+                * @return string
+                */
+                public function getScope() {
+                       return $this->scope;
+                }
+                
+               /**
+                * The access token issued by the authorization server.
+                * @param string $access_token
+                */
+                public function setAccessToken($access_token) {
+                       $this->access_token = $access_token;
+                       return $this;
+                }
+               
+               /**
+                * The access token issued by the authorization server.
+                * @return string
+                */
+                public function getAccessToken() {
+                       return $this->access_token;
+                }
+                
+               /**
+                * The refresh token, which can be used to obtain new access tokens using the same authorization grant as described in OAuth2.0 RFC6749 in Section 6.
+                * @param string $refresh_token
+                */
+                public function setRefreshToken($refresh_token) {
+                       $this->refresh_token = $refresh_token;
+                       return $this;
+                }
+               
+               /**
+                * The refresh token, which can be used to obtain new access tokens using the same authorization grant as described in OAuth2.0 RFC6749 in Section 6.
+                * @return string
+                */
+                public function getRefreshToken() {
+                       return $this->refresh_token;
+                }
+                
+               /**
+                * The type of the token issued as described in OAuth2.0 RFC6749 (Section 7.1).  Value is case insensitive.
+                * @param string $token_type
+                */
+                public function setTokenType($token_type) {
+                       $this->token_type = $token_type;
+                       return $this;
+                }
+               
+               /**
+                * The type of the token issued as described in OAuth2.0 RFC6749 (Section 7.1).  Value is case insensitive.
+                * @return string
+                */
+                public function getTokenType() {
+                       return $this->token_type;
+                }
+                
+               /**
+                * The id_token is a session token assertion that denotes the user's authentication status
+                * @param string $id_token
+                */
+                public function setIdToken($id_token) {
+                       $this->id_token = $id_token;
+                       return $this;
+                }
+               
+               /**
+                * The id_token is a session token assertion that denotes the user's authentication status
+                * @return string
+                */
+                public function getIdToken() {
+                       return $this->id_token;
+                }
+                
+               /**
+                * The lifetime in seconds of the access token.
+                * @param integer $expires_in
+                */
+                public function setExpiresIn($expires_in) {
+                       $this->expires_in = $expires_in;
+                       return $this;
+                }
+               
+               /**
+                * The lifetime in seconds of the access token.
+                * @return integer
+                */
+                public function getExpiresIn() {
+                       return $this->expires_in;
+                }
+                
+
+        /**
+                * Creates an Access Token from an Authorization Code.
+                *
+                * @path /v1/identity/openidconnect/tokenservice
+                * @method POST
+                * @param array $params (allowed values are grant_type, code and redirect_uri)
+                *                              (optional) grant_type is the Token grant type. Defaults to authorization_code
+                *                              code is Authorization code previously received from the authorization server
+                *                              redirect_uri Redirection endpoint that must match the one provided during the 
+                *                                      authorization request that ended in receiving the authorization code.
+                * @param PPApiContext $apiContext Optional API Context   
+                * @return PPOpenIdTokeninfo
+                */
+               public static function createFromAuthorizationCode($params, $apiContext=null) {
+                       static $allowedParams = array('grant_type' => 1, 'code' => 1, 'redirect_uri' => 1);
+                       if(is_null($apiContext)) {
+                               $apiContext = new PPApiContext();
+                       }
+                       
+                       if(!array_key_exists('grant_type', $params)) {
+                               $params['grant_type'] = 'authorization_code';
+                       }       
+                       
+                       $call = new PPRestCall($apiContext);
+                       $token = new PPOpenIdTokeninfo();
+                       $token->fromJson(
+                               $call->execute(array('PPOpenIdHandler'),
+                                       "/v1/identity/openidconnect/tokenservice" , "POST", 
+                                       http_build_query(array_intersect_key($params, $allowedParams)),
+                                       array('Content-Type' => 'application/x-www-form-urlencoded')
+                       ));
+                       return $token;
+               }
+        /**
+                * Creates an Access Token from an Refresh Token.
+                *
+                * @path /v1/identity/openidconnect/tokenservice
+                * @method POST
+                * @param array $params (allowed values are grant_type and scope)
+                *                              (optional) refresh_token refresh token. If one is not passed, refresh token from the current object is used.
+                *                              (optional) grant_type is the Token grant type. Defaults to refresh_token
+                *                              scope is an array that either the same or a subset of the scope passed to the authorization request
+                * @param APIContext $apiContext Optional API Context   
+                * @return PPOpenIdTokeninfo
+                */
+               public function createFromRefreshToken($params, $apiContext=null) {
+                       
+                       static $allowedParams = array('grant_type' => 1, 'refresh_token' => 1, 'scope' => 1);
+                       if(is_null($apiContext)) {
+                               $apiContext = new PPApiContext();
+                       }
+                                                       
+                       if(!array_key_exists('grant_type', $params)) {
+                               $params['grant_type'] = 'refresh_token';
+                       }
+                       if(!array_key_exists('refresh_token', $params)) {
+                               $params['refresh_token'] = $this->getRefreshToken();
+                       }
+                                               
+                       
+                       $call = new PPRestCall($apiContext);                    
+                       $this->fromJson(
+                               $call->execute(array('PPOpenIdHandler'), 
+                                       "/v1/identity/openidconnect/tokenservice", "POST",
+                                       http_build_query(array_intersect_key($params, $allowedParams)),
+                                       array('Content-Type' => 'application/x-www-form-urlencoded')
+                       ));
+                       return $this;
+               }
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Openid/PPOpenIdUserinfo.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Openid/PPOpenIdUserinfo.php
new file mode 100644 (file)
index 0000000..29ff51f
--- /dev/null
@@ -0,0 +1,400 @@
+<?php
+namespace PayPal\Auth\Openid;
+use PayPal\Common\PPModel;
+/**
+ * OpenIdConnect UserInfo Resource
+ */
+class PPOpenIdUserinfo extends PPModel {
+
+               /**
+                * Subject - Identifier for the End-User at the Issuer.
+                * @param string $user_id
+                */
+                public function setUserId($user_id) {
+                       $this->user_id = $user_id;
+                       return $this;
+                }
+               
+               /**
+                * Subject - Identifier for the End-User at the Issuer.
+                * @return string
+                */
+                public function getUserId() {
+                       return $this->user_id;
+                }
+                
+               /**
+                * Subject - Identifier for the End-User at the Issuer.
+                * @param string $sub
+                */
+                public function setSub($sub) {
+                       $this->sub = $sub;
+                       return $this;
+                }
+               
+               /**
+                * Subject - Identifier for the End-User at the Issuer.
+                * @return string
+                */
+                public function getSub() {
+                       return $this->sub;
+                }
+                
+               /**
+                * End-User's full name in displayable form including all name parts, possibly including titles and suffixes, ordered according to the End-User's locale and preferences.
+                * @param string $name
+                */
+                public function setName($name) {
+                       $this->name = $name;
+                       return $this;
+                }
+               
+               /**
+                * End-User's full name in displayable form including all name parts, possibly including titles and suffixes, ordered according to the End-User's locale and preferences.
+                * @return string
+                */
+                public function getName() {
+                       return $this->name;
+                }
+                
+               /**
+                * Given name(s) or first name(s) of the End-User
+                * @param string $given_name
+                */
+                public function setGivenName($given_name) {
+                       $this->given_name = $given_name;
+                       return $this;
+                }
+               
+               /**
+                * Given name(s) or first name(s) of the End-User
+                * @return string
+                */
+                public function getGivenName() {
+                       return $this->given_name;
+                }
+                
+               /**
+                * Surname(s) or last name(s) of the End-User.
+                * @param string $family_name
+                */
+                public function setFamilyName($family_name) {
+                       $this->family_name = $family_name;
+                       return $this;
+                }
+               
+               /**
+                * Surname(s) or last name(s) of the End-User.
+                * @return string
+                */
+                public function getFamilyName() {
+                       return $this->family_name;
+                }
+                
+               /**
+                * Middle name(s) of the End-User.
+                * @param string $middle_name
+                */
+                public function setMiddleName($middle_name) {
+                       $this->middle_name = $middle_name;
+                       return $this;
+                }
+               
+               /**
+                * Middle name(s) of the End-User.
+                * @return string
+                */
+                public function getMiddleName() {
+                       return $this->middle_name;
+                }
+                
+               /**
+                * URL of the End-User's profile picture.
+                * @param string $picture
+                */
+                public function setPicture($picture) {
+                       $this->picture = $picture;
+                       return $this;
+                }
+               
+               /**
+                * URL of the End-User's profile picture.
+                * @return string
+                */
+                public function getPicture() {
+                       return $this->picture;
+                }
+                
+               /**
+                * End-User's preferred e-mail address.
+                * @param string $email
+                */
+                public function setEmail($email) {
+                       $this->email = $email;
+                       return $this;
+                }
+               
+               /**
+                * End-User's preferred e-mail address.
+                * @return string
+                */
+                public function getEmail() {
+                       return $this->email;
+                }
+                
+               /**
+                * True if the End-User's e-mail address has been verified; otherwise false.
+                * @param boolean $email_verified
+                */
+                public function setEmailVerified($email_verified) {
+                       $this->email_verified = $email_verified;
+                       return $this;
+                }
+               
+               /**
+                * True if the End-User's e-mail address has been verified; otherwise false.
+                * @return boolean
+                */
+                public function getEmailVerified() {
+                       return $this->email_verified;
+                }
+                
+               /**
+                * End-User's gender.
+                * @param string $gender
+                */
+                public function setGender($gender) {
+                       $this->gender = $gender;
+                       return $this;
+                }
+               
+               /**
+                * End-User's gender.
+                * @return string
+                */
+                public function getGender() {
+                       return $this->gender;
+                }
+                
+               /**
+                * End-User's birthday, represented as an YYYY-MM-DD format. They year MAY be 0000, indicating it is omited. To represent only the year, YYYY format would be used.
+                * @param string $birthday
+                */
+                public function setBirthday($birthday) {
+                       $this->birthday = $birthday;
+                       return $this;
+                }
+               
+               /**
+                * End-User's birthday, represented as an YYYY-MM-DD format. They year MAY be 0000, indicating it is omited. To represent only the year, YYYY format would be used.
+                * @return string
+                */
+                public function getBirthday() {
+                       return $this->birthday;
+                }
+                
+               /**
+                * Time zone database representing the End-User's time zone
+                * @param string $zoneinfo
+                */
+                public function setZoneinfo($zoneinfo) {
+                       $this->zoneinfo = $zoneinfo;
+                       return $this;
+                }
+               
+               /**
+                * Time zone database representing the End-User's time zone
+                * @return string
+                */
+                public function getZoneinfo() {
+                       return $this->zoneinfo;
+                }
+                
+               /**
+                * End-User's locale.
+                * @param string $locale
+                */
+                public function setLocale($locale) {
+                       $this->locale = $locale;
+                       return $this;
+                }
+               
+               /**
+                * End-User's locale.
+                * @return string
+                */
+                public function getLocale() {
+                       return $this->locale;
+                }
+                
+               /**
+                * End-User's language.
+                * @param string $language
+                */
+                public function setLanguage($language) {
+                       $this->language = $language;
+                       return $this;
+                }
+               
+               /**
+                * End-User's language.
+                * @return string
+                */
+                public function getLanguage() {
+                       return $this->language;
+                }
+                
+               /**
+                * End-User's verified status.
+                * @param boolean $verified
+                */
+                public function setVerified($verified) {
+                       $this->verified = $verified;
+                       return $this;
+                }
+               
+               /**
+                * End-User's verified status.
+                * @return boolean
+                */
+                public function getVerified() {
+                       return $this->verified;
+                }
+                
+               /**
+                * End-User's preferred telephone number.
+                * @param string $phone_number
+                */
+                public function setPhoneNumber($phone_number) {
+                       $this->phone_number = $phone_number;
+                       return $this;
+                }
+               
+               /**
+                * End-User's preferred telephone number.
+                * @return string
+                */
+                public function getPhoneNumber() {
+                       return $this->phone_number;
+                }
+                
+               /**
+                * End-User's preferred address.
+                * @param PPOpenIdAddress $address
+                */
+                public function setAddress($address) {
+                       $this->address = $address;
+                       return $this;
+                }
+               
+               /**
+                * End-User's preferred address.
+                * @return PPOpenIdAddress
+                */
+                public function getAddress() {
+                       return $this->address;
+                }
+                
+               /**
+                * Verified account status.
+                * @param boolean $verified_account
+                */
+                public function setVerifiedAccount($verified_account) {
+                       $this->verified_account = $verified_account;
+                       return $this;
+                }
+               
+               /**
+                * Verified account status.
+                * @return boolean
+                */
+                public function getVerifiedAccount() {
+                       return $this->verified_account;
+                }
+                
+               /**
+                * Account type.
+                * @param string $account_type
+                */
+                public function setAccountType($account_type) {
+                       $this->account_type = $account_type;
+                       return $this;
+                }
+               
+               /**
+                * Account type.
+                * @return string
+                */
+                public function getAccountType() {
+                       return $this->account_type;
+                }
+                
+               /**
+                * Account holder age range.
+                * @param string $age_range
+                */
+                public function setAgeRange($age_range) {
+                       $this->age_range = $age_range;
+                       return $this;
+                }
+               
+               /**
+                * Account holder age range.
+                * @return string
+                */
+                public function getAgeRange() {
+                       return $this->age_range;
+                }
+                
+               /**
+                * Account payer identifier.
+                * @param string $payer_id
+                */
+                public function setPayerId($payer_id) {
+                       $this->payer_id = $payer_id;
+                       return $this;
+                }
+               
+               /**
+                * Account payer identifier.
+                * @return string
+                */
+                public function getPayerId() {
+                       return $this->payer_id;
+                }
+                
+
+        /**
+                * returns user details
+                *
+                * @path /v1/identity/openidconnect/userinfo
+                * @method GET
+                * @param array $params (allowed values are access_token)
+                *                                      access_token - access token from the createFromAuthorizationCode / createFromRefreshToken calls  
+                * @param PPApiContext $apiContext Optional API Context
+                * @return PPOpenIdUserinfo
+                */
+               public static function getUserinfo($params, $apiContext=null) {
+                       static $allowedParams = array( 'schema' => 1);
+                       if(is_null($apiContext)) {
+                               $apiContext = new PPApiContext();
+                       }
+                                               
+                       if(!array_key_exists('schema', $params)) {
+                               $params['schema'] = 'openid';
+                       }                       
+                       $requestUrl = "/v1/identity/openidconnect/userinfo?"
+                                       . http_build_query(array_intersect_key($params, $allowedParams));                       
+                       $call = new PPRestCall($apiContext);
+                       $ret = new PPOpenIdUserinfo();
+                       $ret->fromJson(
+                               $call->execute(array('PPOpenIdHandler'), $requestUrl, "GET", "", 
+                                       array(
+                                               'Authorization' => "Bearer " . $params['access_token'],
+                                               'Content-Type'=> 'x-www-form-urlencoded'
+                                       )
+                               )
+                       );
+                       return $ret;
+               }
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/PPCertificateCredential.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/PPCertificateCredential.php
new file mode 100644 (file)
index 0000000..a33ab96
--- /dev/null
@@ -0,0 +1,103 @@
+<?php
+namespace PayPal\Auth;
+use PayPal\Exception\PPMissingCredentialException;
+use PayPal\Auth\IPPCredential;
+/**
+ * 
+ * Client certificate based credentials
+ */
+class PPCertificateCredential extends IPPCredential {
+       
+       /**
+        * API username
+        * @var string
+        */
+       protected $userName;
+       
+       /**
+        * API password
+        * @var string
+        */
+       protected $password;
+
+       /**
+        * Path to PEM encoded API certificate on local filesystem
+        * @var string
+        */
+       protected $certificatePath;
+
+       /**
+        * Password used to protect the API certificate
+        * @var string
+        */
+       protected $certificatePassPhrase;
+       
+       /**
+        * Application Id that uniquely identifies an application that uses the
+        * Platform APIs - Not required for Express Checkout / MassPay / DCC etc
+        * The application Id is issued by PayPal.
+        * Test application Ids are available for the sandbox environment
+        * @var string
+        */
+       protected $applicationId;       
+       
+       /**
+        * Constructs a new certificate credential object
+        * 
+        * @param string $userName      API username
+        * @param string $password      API password
+        * @param string $certPath      Path to PEM encoded client certificate file
+        * @param string $certificatePassPhrase password need to use the certificate
+        */
+       public function __construct($userName, $password, $certPath, $certificatePassPhrase=NULL) {
+               $this->userName = trim($userName);
+               $this->password = trim($password);
+               $this->certificatePath = trim($certPath);
+               $this->certificatePassPhrase = $certificatePassPhrase; 
+               $this->validate();
+       }
+       
+       public function validate() {
+               
+               if (empty($this->userName)) {
+                       throw new PPMissingCredentialException("username cannot be empty");
+               }
+               if (empty($this->password)) {
+                       throw new PPMissingCredentialException("password cannot be empty");
+               }               
+               if (empty($this->certificatePath)) {
+                       throw new PPMissingCredentialException("certificate cannot be empty");
+               }
+       }
+
+       public function getUserName() {
+               return $this->userName;
+       }
+
+       public function getPassword() {
+               return $this->password;
+       }
+       
+       public function getCertificatePath() {
+               if (realpath($this->certificatePath)) {
+                       return realpath($this->certificatePath);
+               } else if(defined('PP_CONFIG_PATH')) {
+                       return constant('PP_CONFIG_PATH') . DIRECTORY_SEPARATOR . $this->certificatePath;
+               } else {
+                       return realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . ".."  .DIRECTORY_SEPARATOR . ".."     . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . $this->certificatePath);
+               }
+       }
+
+       public function getCertificatePassPhrase() {
+               return $this->certificatePassPhrase;
+       }
+       
+       public function setApplicationId($applicationId) {
+               $this->applicationId = trim($applicationId);
+       }
+       
+       public function getApplicationId() {
+               return $this->applicationId;
+       }
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/PPSignatureCredential.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/PPSignatureCredential.php
new file mode 100644 (file)
index 0000000..d1e6f49
--- /dev/null
@@ -0,0 +1,69 @@
+<?php
+namespace PayPal\Auth;
+use PayPal\Exception\PPMissingCredentialException;
+/**
+ * API signature (3-token) based credentials
+ */
+class PPSignatureCredential extends IPPCredential {
+
+       /**
+        * API username
+        * @var string
+        */
+       protected $userName;
+
+       /**
+        * API password
+        * @var string
+        */
+       protected $password;
+       /**
+        * API Signature
+        * @var string
+        */
+       protected $signature;
+
+       /**
+        * Application Id that uniquely identifies an application that uses the
+        * Platform APIs - Not required for Express Checkout / MassPay / DCC etc
+        * Application Ids are issued by PayPal.
+        * Test application Ids are available for the sandbox environment
+        * @var string
+        */
+       protected $applicationId;
+
+       public function __construct($userName, $password, $signature) {
+               $this->userName = trim($userName);
+               $this->password = trim($password);
+               $this->signature = trim($signature);
+               $this->validate();
+       }
+
+       public function validate() {
+
+               if (empty($this->userName)) {
+                       throw new PPMissingCredentialException("username cannot be empty");
+               }
+               if (empty($this->password)) {
+                       throw new PPMissingCredentialException("password cannot be empty");
+               }
+               // Signature can be empty if using 3-rd party auth tokens from permissions API
+       }
+
+       public function getUserName() {
+               return $this->userName;
+       }
+       public function getPassword() {
+               return $this->password;
+       }
+       public function getSignature() {
+               return $this->signature;
+       }
+
+       public function setApplicationId($applicationId) {
+               $this->applicationId = trim($applicationId);
+       }
+       public function getApplicationId() {
+               return $this->applicationId;
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/PPSubjectAuthorization.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/PPSubjectAuthorization.php
new file mode 100644 (file)
index 0000000..27f1f8f
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+namespace PayPal\Auth;
+/**
+ *
+ * Represents the older subject based "third party authorization"
+ * New apps can use the more flexible token based authorization
+ */
+class PPSubjectAuthorization implements IPPThirdPartyAuthorization {
+
+       /**
+        * Paypal emailid of the party who has granted API rights
+        * to the API caller. Your API username must have been 
+        * granted permission by this third-party to make any particular 
+        * PayPal API request.
+        * @var string
+        */
+       private $subject;
+       
+       public function __construct($subject) {
+               $this->subject = $subject;
+       }
+       
+       public function getSubject() {
+               return $this->subject;
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/PPTokenAuthorization.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/PPTokenAuthorization.php
new file mode 100644 (file)
index 0000000..d9a80e7
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+namespace PayPal\Auth;
+use PayPal\Auth\IPPThirdPartyAuthorization;
+/**
+ *
+ * Represents token based third party authorization
+ * Token based authorization credentials are obtained using
+ * the Permissions API
+ */
+class PPTokenAuthorization implements IPPThirdPartyAuthorization {
+       
+       /**
+        * Permanent access token that identifies the relationship 
+        * between the authorizing user and the API caller.
+        * @var string
+        */
+       private $accessToken;
+       
+       /**
+        * The token secret/password that will need to be used when 
+        * generating the signature.
+        * @var string
+        */
+       private $tokenSecret;
+       
+       public function __construct($accessToken, $tokenSecret) {
+               $this->accessToken = $accessToken;
+               $this->tokenSecret = $tokenSecret;
+       }
+       
+       public function getAccessToken() {
+               return $this->accessToken;
+       }
+       
+       public function getTokenSecret() {
+               return $this->tokenSecret;
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Common/PPApiContext.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Common/PPApiContext.php
new file mode 100644 (file)
index 0000000..5affd24
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+namespace PayPal\Common;
+use PayPal\Core\PPConfigManager;
+/**
+ * 
+ * Container for Call level parameters such as
+ * SDK configuration 
+ */
+class PPApiContext {
+       
+       /**
+        * 
+        * @var array Dynamic SDK configuration
+        */
+       protected $config;
+       
+       public function setConfig($config) {
+               $this->config = $config;
+       }
+       
+       public function getConfig() {
+               if(!isset($this->config)) {
+                       $this->config = PPConfigManager::getInstance()->getConfigHashmap();
+               }
+               return $this->config;
+       }
+       
+       public function __construct($config=null) {
+               if(!is_null($config)) {
+                       $this->config = $config;
+               }
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Common/PPArrayUtil.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Common/PPArrayUtil.php
new file mode 100644 (file)
index 0000000..a93fe19
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+namespace PayPal\Common;
+class PPArrayUtil {
+       
+       /**
+        * 
+        * @param array $arr
+        * @return true if $arr is an associative array
+        */
+       public static function isAssocArray(array $arr) {
+               foreach($arr as $k => $v) {
+                       if(is_int($k)) {
+                               return false;
+                       }
+               }
+               return true;
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Common/PPModel.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Common/PPModel.php
new file mode 100644 (file)
index 0000000..ec4ae90
--- /dev/null
@@ -0,0 +1,84 @@
+<?php 
+namespace PayPal\Common;
+
+/**
+ * Generic Model class that all API domain classes extend
+ * Stores all member data in a hashmap that enables easy 
+ * JSON encoding/decoding
+ */
+class PPModel {
+
+       private $_propMap = array();    
+               
+       public function __get($key) {
+               return $this->_propMap[$key];
+       }
+       
+       public function __set($key, $value) {
+               $this->_propMap[$key] = $value;
+       }
+       
+       public function __isset($key) {
+               return isset($this->_propMap[$key]);
+       }
+       
+       public function __unset($key) {
+               unset($this->_propMap[$key]);
+       }
+       
+       
+       private function _convertToArray($param) {
+               $ret = array();         
+               foreach($param as $k => $v) {
+                       if($v instanceof PPModel ) {                            
+                               $ret[$k] = $v->toArray();
+                       } else if (is_array($v)) {
+                               $ret[$k] = $this->_convertToArray($v);
+                       } else {
+                               $ret[$k] = $v;
+                       }
+               }
+               return $ret;
+       }
+       
+       public function fromArray($arr) {
+               
+               foreach($arr as $k => $v) {
+                       if(is_array($v)) {
+                               $clazz = PPReflectionUtil::getPropertyClass(get_class($this), $k);
+                               
+                               if(PPArrayUtil::isAssocArray($v)) {
+                                       $o = new $clazz();
+                                       $o->fromArray($v);
+                                       $this->__set($k, $o);
+                               } else {
+                                       $arr =  array();                
+                                       foreach($v as $nk => $nv) {
+                                               if(is_array($nv)) {
+                                                       $o = new $clazz();
+                                                       $o->fromArray($nv);
+                                                       $arr[$nk] = $o;
+                                               } else {
+                                                       $arr[$nk] = $nv;
+                                               }
+                                       }
+                                       $this->__set($k, $arr);
+                               } 
+                       }else {
+                               $this->$k = $v;
+                       }
+               }
+       }
+       
+       public function fromJson($json) {
+               $this->fromArray(json_decode($json, true));
+       }
+       
+       public function toArray() {             
+               return $this->_convertToArray($this->_propMap);
+       }
+       
+       public function toJSON() {              
+               return json_encode($this->toArray());
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Common/PPReflectionUtil.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Common/PPReflectionUtil.php
new file mode 100644 (file)
index 0000000..83bfd8f
--- /dev/null
@@ -0,0 +1,74 @@
+<?php
+namespace PayPal\Common;
+class PPReflectionUtil {
+       
+       
+       /**
+        * @var array|ReflectionMethod[]
+        */
+       private static $propertiesRefl = array();
+       
+       /**
+        * @var array|string[]
+        */
+       private static $propertiesType = array();
+       
+       
+       /**
+        * 
+        * @param string $class
+        * @param string $propertyName
+        */
+       public static function getPropertyClass($class, $propertyName) {
+               
+               if (($annotations = self::propertyAnnotations($class, $propertyName)) && isset($annotations['return'])) {               
+//                     if (substr($annotations['param'], -2) === '[]') {
+//                             $param = substr($annotations['param'], 0, -2);
+//                     }
+                       $param = $annotations['return'];
+               }
+               
+               if(isset($param)) {
+                       $anno = explode(' ', $param);
+                       return $anno[0];
+               } else {
+                       return 'string';
+               }
+       }
+       
+       
+       /**
+        * @param string $class
+        * @param string $propertyName
+        * @throws RuntimeException
+        * @return string
+        */
+       public static function propertyAnnotations($class, $propertyName)
+       {
+               $class = is_object($class) ? get_class($class) : $class;
+               if (!class_exists('ReflectionProperty')) {
+                       throw new \RuntimeException("Property type of " . $class . "::{$propertyName} cannot be resolved");
+               }
+       
+               if ($annotations =& self::$propertiesType[$class][$propertyName]) {
+                       return $annotations;
+               }
+               
+               if (!($refl =& self::$propertiesRefl[$class][$propertyName])) {
+                       $getter = method_exists($class, "get" . ucfirst($propertyName)) ? "get". ucfirst($propertyName)
+                               : "get". preg_replace("/([_-\s]?([a-z0-9]+))/e", "ucwords('\\2')", $propertyName);
+                       $refl = new \ReflectionMethod($class, $getter);
+                       self::$propertiesRefl[$class][$propertyName] = $refl;
+               }
+       
+               // todo: smarter regexp
+               if (!preg_match_all('~\@([^\s@\(]+)[\t ]*(?:\(?([^\n@]+)\)?)?~i', $refl->getDocComment(), $annots, PREG_PATTERN_ORDER)) {
+                       return NULL;
+               }
+               foreach ($annots[1] as $i => $annot) {
+                       $annotations[strtolower($annot)] = empty($annots[2][$i]) ? TRUE : rtrim($annots[2][$i], " \t\n\r)");
+               }
+       
+               return $annotations;
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Common/PPUserAgent.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Common/PPUserAgent.php
new file mode 100644 (file)
index 0000000..551c93b
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+namespace PayPal\Common;
+class PPUserAgent {
+
+       /**
+        * Returns the value of the User-Agent header
+        * Add environment values and php version numbers
+        * @param string $sdkName
+        * @param string $sdkVersion
+        */
+       public static function getValue($sdkName, $sdkVersion) {
+               
+               $featureList = array(
+                       'lang=PHP',
+                       'v=' . PHP_VERSION,
+                       'bit=' . self::_getPHPBit(),
+                       'os=' . str_replace(' ' , '_', php_uname('s') . ' ' . php_uname('r')),
+                       'machine=' . php_uname('m')
+               );
+               if(defined('OPENSSL_VERSION_TEXT')) {
+                       $opensslVersion = explode(' ', OPENSSL_VERSION_TEXT);
+                       $featureList[] = 'openssl='. $opensslVersion[1];
+               }
+               if(function_exists('curl_version')) {
+                       $curlVersion = curl_version();
+                       $featureList[] = 'curl=' . $curlVersion['version'];
+               }
+               return sprintf("PayPalSDK/%s %s (%s)", $sdkName, $sdkVersion, implode(';', $featureList));
+       }
+       
+       private static function _getPHPBit() {
+               switch(PHP_INT_SIZE) {
+                       case 4:
+                               return '32';
+                       case 8:
+                               return '64';
+                       default:
+                               return PHP_INT_SIZE;
+               }
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPAPIService.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPAPIService.php
new file mode 100644 (file)
index 0000000..876b408
--- /dev/null
@@ -0,0 +1,92 @@
+<?php
+namespace PayPal\Core;
+use PayPal\Core\PPLoggingManager;
+use PayPal\Formatter\FormatterFactory;
+use PayPal\Core\PPRequest;
+use PayPal\Core\PPHttpConfig;
+use PayPal\Handler\PPAuthenticationHandler;
+use PayPal\Auth\PPTokenAuthorization;
+
+class PPAPIService {
+
+       public $endpoint;
+       public $config;
+       public $options = array();
+       public $serviceName;
+       private $logger;
+       private $handlers = array();
+       private $serviceBinding;
+       private $port;
+       private $apiMethod;
+       public function __construct($port, $serviceName, $serviceBinding, $handlers=array(), $config) {
+               
+               $this->config = $config;
+               $this->serviceName = $serviceName;
+               $this->port = $port;
+
+               $this->logger = new PPLoggingManager(__CLASS__, $this->config);
+               $this->handlers = $handlers;
+               $this->serviceBinding = $serviceBinding;
+               
+       }
+
+       public function setServiceName($serviceName) {
+               $this->serviceName = $serviceName;
+       }
+
+       public function addHandler($handler) {
+               $this->handlers[] = $handler;
+       }
+
+       public function makeRequest($apiMethod, $params, $apiUsername = null) {
+               
+               $this->apiMethod = $apiMethod;
+               if(is_string($apiUsername) || is_null($apiUsername)) {
+                       // $apiUsername is optional, if null the default account in config file is taken
+                       $credMgr = PPCredentialManager::getInstance($this->config);
+                       $apiCredential = clone($credMgr->getCredentialObject($apiUsername ));
+               } else {
+                       $apiCredential = $apiUsername; //TODO: Aargh
+               }
+           if((isset($this->config['accessToken']) && isset($this->config['tokenSecret']))) {
+                       $apiCredential->setThirdPartyAuthorization(
+                                       new PPTokenAuthorization($this->config['accessToken'], $this->config['tokenSecret']));
+               }
+
+
+               $request = new PPRequest($params, $this->serviceBinding);
+               $request->setCredential($apiCredential);
+               $httpConfig = new PPHttpConfig(null, PPHttpConfig::HTTP_POST);
+               $this->runHandlers($httpConfig, $request);
+
+               $formatter = FormatterFactory::factory($this->serviceBinding);
+               $payload = $formatter->toString($request);
+               $connection = PPConnectionManager::getInstance()->getConnection($httpConfig, $this->config);
+               $this->logger->info("Request: $payload");
+               $response = $connection->execute($payload);
+               $this->logger->info("Response: $response");
+
+               return array('request' => $payload, 'response' => $response);
+       }
+
+       private function runHandlers($httpConfig, $request) {
+       
+               $this->getOptions();
+               
+               foreach($this->handlers as $handlerClass) {
+                       $handler = new $handlerClass();
+                       $handler->handle($httpConfig, $request, $this->options);
+               }
+               $handler = new PPAuthenticationHandler();
+               $handler->handle($httpConfig, $request, $this->options);
+       }
+       
+       private function getOptions()
+       {
+               $this->options['port'] = $this->port;
+               $this->options['serviceName'] = $this->serviceName;
+               $this->options['serviceBinding'] = $this->serviceBinding;
+               $this->options['config'] = $this->config;
+               $this->options['apiMethod'] = $this->apiMethod;
+       }       
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPBaseService.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPBaseService.php
new file mode 100644 (file)
index 0000000..fc6de3f
--- /dev/null
@@ -0,0 +1,87 @@
+<?php
+namespace PayPal\Core;
+use PayPal\Core\PPAPIService;
+class PPBaseService {
+
+    // SDK Name
+       protected  static $SDK_NAME = "paypal-php-sdk";
+       // SDK Version
+       protected static $SDK_VERSION = "2.1.96";
+       
+       private $serviceName;
+       private $serviceBinding;
+       private $handlers;
+       
+   /*
+    * Setters and getters for Third party authentication (Permission Services)
+    */
+       protected $accessToken;
+       protected $tokenSecret;
+       
+       protected $lastRequest;
+       protected $lastResponse;
+       
+       
+       
+       // config hash map
+       public $config;
+
+       /**
+        * Compute the value that needs to sent for the PAYPAL_REQUEST_SOURCE
+        * parameter when making API calls
+        */
+       public static function getRequestSource()
+       {
+               return str_replace(" ", "-", self::$SDK_NAME) . "-" . self::$SDK_VERSION;
+       }
+       
+
+    public function getLastRequest() {
+               return $this->lastRequest;
+       }
+    public function setLastRequest($lastRqst) {
+               $this->lastRequest = $lastRqst;
+       }
+    public function getLastResponse() {
+               return $this->lastResponse;
+       }
+    public function setLastResponse($lastRspns) {
+               $this->lastResponse = $lastRspns;
+       }
+
+       public function __construct($serviceName, $serviceBinding, $handlers=array(), $config = null) {
+               $this->serviceName = $serviceName;
+               $this->serviceBinding = $serviceBinding;
+               $this->handlers = $handlers;
+               if($config == null)
+               {
+                       $configFile = PPConfigManager::getInstance();
+                       $this->config = $configFile->getConfigHashmap();
+               }
+               else 
+               {
+                       $this->config = PPConfigManager::mergrDefaults($config);
+               }
+       }
+
+       public function getServiceName() {
+               return $this->serviceName;
+       }
+
+       /**
+        * 
+        * @param string $method - API method to call
+        * @param object $requestObject Request object 
+        * @param mixed $apiCredential - Optional API credential - can either be
+        *              a username configured in sdk_config.ini or a ICredential object
+        *      created dynamically             
+        */
+       public function call($port, $method, $requestObject, $apiUserName = NULL) {             
+               $service = new PPAPIService($port, $this->serviceName, 
+                               $this->serviceBinding, $this->handlers,$this->config);          
+               $ret = $service->makeRequest($method, $requestObject, $apiUserName);
+               $this->lastRequest = $ret['request'];
+               $this->lastResponse = $ret['response'];
+               return $this->lastResponse;
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPConfigManager.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPConfigManager.php
new file mode 100644 (file)
index 0000000..f03560e
--- /dev/null
@@ -0,0 +1,123 @@
+<?php
+namespace PayPal\Core;
+use PayPal\Core\PPConfigManager;
+use PayPal\Exception\PPConfigurationException;
+/**
+ * PPConfigManager loads the SDK configuration file and
+ * hands out appropriate config params to other classes
+ */
+
+
+class PPConfigManager {
+
+       public $config;
+       /**
+        * @var PPConfigManager
+        */
+       
+       //default config values
+       public static $defaults = array(
+               "http.ConnectionTimeOut" => "30",
+               "http.Retry" => "5",
+       );
+       
+       private static $instance;
+
+       private function __construct(){
+               if(defined('PP_CONFIG_PATH')) {
+                       $configFile = constant('PP_CONFIG_PATH') . '/sdk_config.ini';
+               } else {                
+                       $configFile = implode(DIRECTORY_SEPARATOR,
+                               array(dirname(__FILE__), "..", "config", "sdk_config.ini"));
+               }
+               $this->load($configFile);
+       }
+
+       // create singleton object for PPConfigManager
+       public static function getInstance()
+       {
+               if ( !isset(self::$instance) ) {
+                       self::$instance = new PPConfigManager();
+               }
+               return self::$instance;
+       }
+
+       //used to load the file
+       private function load($fileName) {
+
+               $this->config = @parse_ini_file($fileName);
+               if($this->config == NULL || count($this->config) == 0) {
+                       throw new PPConfigurationException("Config file $fileName not found","303");
+               }
+       }
+
+       /**
+        * simple getter for configuration params
+        * If an exact match for key is not found,
+        * does a "contains" search on the key
+        */
+       public function get($searchKey){
+
+               if(array_key_exists($searchKey, $this->config))
+               {
+                       return $this->config[$searchKey];
+               }
+               else {
+                       $arr = array();
+                       foreach ($this->config as $k => $v){
+                               if(strstr($k, $searchKey)){
+                                       $arr[$k] = $v;
+                               }
+                       }
+                       
+                       return $arr;
+               }
+
+       }
+
+       /**
+        * Utility method for handling account configuration
+        * return config key corresponding to the API userId passed in
+        *
+        * If $userId is null, returns config keys corresponding to
+        * all configured accounts
+        */
+       public function getIniPrefix($userId = null) {
+
+               if($userId == null) {
+                       $arr = array();
+                       foreach ($this->config as $key => $value) {
+                               $pos = strpos($key, '.');
+                               if(strstr($key, "acct")){
+                                       $arr[] = substr($key, 0, $pos);
+                               }
+                       }
+                       return array_unique($arr);
+               } else {
+                       $iniPrefix = array_search($userId, $this->config);
+                       $pos = strpos($iniPrefix, '.');
+                       $acct = substr($iniPrefix, 0, $pos);
+                       
+                       return $acct;
+               }
+       }
+       
+       /**
+        * returns the config file hashmap
+        * 
+        */
+       public function getConfigHashmap()
+       {
+               return $this->config;
+       }
+       
+       /**
+        * use  the default configuration if it is not passed in hashmap
+        */
+       public static function mergrDefaults($config)
+       {
+               return array_merge(PPConfigManager::$defaults, $config);
+       }
+}
+
+    
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPConnectionManager.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPConnectionManager.php
new file mode 100644 (file)
index 0000000..0b4a93c
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+namespace PayPal\Core;
+use PayPal\Core\PPConnectionManager;
+use PayPal\Core\PPHttpConnection;
+class PPConnectionManager
+{
+       /**
+        * reference to singleton instance
+        * @var PPConnectionManager
+        */
+       private static $instance;
+
+       private function __construct()
+       {
+       }
+
+       public static function getInstance() {
+               if( self::$instance == null ) {
+                       self::$instance = new PPConnectionManager();
+               }
+               return self::$instance;
+       }
+
+       /**
+        * This function returns a new PPHttpConnection object
+        */
+       public function getConnection($httpConfig, $config) {
+               if(isset( $config["http.ConnectionTimeOut"] )) {
+                       $httpConfig->setHttpTimeout( $config["http.ConnectionTimeOut"] );
+               }
+               if(isset( $config["http.Proxy"] )) {
+                       $httpConfig->setHttpProxy($config["http.Proxy"] );
+               }
+               if(isset( $config["http.Retry"] )) {
+                       $retry =  $config["http.Retry"];
+                       $httpConfig->setHttpRetryCount($retry ) ;
+               }
+               
+               return new PPHttpConnection($httpConfig, $config);
+       }
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPConstants.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPConstants.php
new file mode 100644 (file)
index 0000000..da09c92
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+namespace PayPal\Core;
+class PPConstants
+{
+    const MERCHANT_SANDBOX_SIGNATURE_ENDPOINT = "https://api-3t.sandbox.paypal.com/2.0";
+    const MERCHANT_SANDBOX_CERT_ENDPOINT = "https://api.sandbox.paypal.com/2.0";
+    const PLATFORM_SANDBOX_ENDPOINT = "https://svcs.sandbox.paypal.com/";
+    const REST_SANDBOX_ENDPOINT = "https://api.sandbox.paypal.com/";
+    const IPN_SANDBOX_ENDPOINT = "https://www.sandbox.paypal.com/cgi-bin/webscr";
+    const OPENID_REDIRECT_SANDBOX_URL = "https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect";
+
+    const MERCHANT_LIVE_SIGNATURE_ENDPOINT = "https://api-3t.paypal.com/2.0";
+    const MERCHANT_LIVE_CERT_ENDPOINT = "https://api.paypal.com/2.0";
+    const PLATFORM_LIVE_ENDPOINT = "https://svcs.paypal.com/";
+    const REST_LIVE_ENDPOINT = "https://api.paypal.com/";
+    const IPN_LIVE_ENDPOINT = "https://ipnpb.paypal.com/cgi-bin/webscr";
+    const OPENID_REDIRECT_LIVE_URL = "https://www.paypal.com/webapps/auth/protocol/openidconnect";
+}
+
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPCredentialManager.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPCredentialManager.php
new file mode 100644 (file)
index 0000000..c9b1a43
--- /dev/null
@@ -0,0 +1,155 @@
+<?php
+namespace PayPal\Core;
+use PayPal\Core\PPCredentialManager;
+use PayPal\Auth\PPSignatureCredential;
+use PayPal\Auth\PPCertificateCredential;
+use PayPal\Auth\PPSubjectAuthorization;
+use PayPal\Exception\PPInvalidCredentialException;
+use PayPal\Exception\PPMissingCredentialException;
+
+class PPCredentialManager
+{
+       private static $instance;
+       //hashmap to contain credentials for accounts.
+       private $credentialHashmap = array();
+       /**
+        * Contains the API username of the default account to use
+        * when authenticating API calls.
+        * @var string
+        */
+       private $defaultAccountName;
+       
+       /*
+        * Constructor initialize credential for multiple accounts specified in property file.
+        */
+       private function __construct($config){
+               try {
+                       $this->initCredential($config);
+               } catch (Exception $e) {
+                       $this->credentialHashmap = array();
+                       throw $e;
+               }               
+       }
+       
+       /*
+        * Create singleton instance for this class.
+        */
+       public static function getInstance($config)
+       {
+               
+                       return self::$instance = new PPCredentialManager($config);
+               
+       }
+       
+       /*
+        * Load credentials for multiple accounts, with priority given to Signature credential. 
+        */
+       private function initCredential($config){
+       //      $configMgr = PPConfigManager::getInstance();
+               $suffix = 1;
+               $prefix = "acct";
+
+       //      $credArr = $configMgr->get($prefix);
+       //      $arrayPartKeys = $configMgr->getIniPrefix();
+               
+               if(array_key_exists($prefix, $config))
+               {
+                       $credArr =  $this->config[$searchKey];
+               }
+               else {
+                       $arr = array();
+                       foreach ($config as $k => $v){
+                               if(strstr($k, $prefix)){
+                                       $arr[$k] = $v;
+                               }
+                       }
+                               
+                       $credArr =  $arr;
+               }
+               
+               $arr = array();
+               foreach ($config as $key => $value) {
+                       $pos = strpos($key, '.');
+                       if(strstr($key, "acct")){
+                               $arr[] = substr($key, 0, $pos);
+                       }
+               }
+               $arrayPartKeys =  array_unique($arr);
+               
+               if(count($arrayPartKeys) == 0)
+                       throw new PPMissingCredentialException("No valid API accounts have been configured");
+
+               $key = $prefix.$suffix;
+               while (in_array($key, $arrayPartKeys)){
+                                                       
+                       if(isset($credArr[$key.".Signature"]) 
+                                       && $credArr[$key.".Signature"] != null && $credArr[$key.".Signature"] != ""){
+                                       
+                               $userName = isset($credArr[$key.'.UserName']) ? $credArr[$key.'.UserName'] : "";
+                               $password = isset($credArr[$key.'.Password']) ? $credArr[$key.'.Password'] : "";
+                               $signature = isset($credArr[$key.'.Signature']) ? $credArr[$key.'.Signature'] : "";
+                               
+                               $this->credentialHashmap[$userName] = new PPSignatureCredential($userName, $password, $signature);
+                               if (isset($credArr[$key.'.AppId'])) {                           
+                                       $this->credentialHashmap[$userName]->setApplicationId($credArr[$key.'.AppId']);
+                               }
+                               
+                       } elseif (isset($credArr[$key.".CertPath"]) 
+                                       && $credArr[$key.".CertPath"] != null && $credArr[$key.".CertPath"] != ""){
+                                               
+                               $userName = isset($credArr[$key.'.UserName']) ? $credArr[$key.'.UserName'] : "";
+                               $password = isset($credArr[$key.'.Password']) ? $credArr[$key.'.Password'] : "";
+                               $certPassPhrase = isset($credArr[$key.'.CertKey']) ? $credArr[$key.'.CertKey'] : "";    
+                               $certPath = isset($credArr[$key.'.CertPath']) ? $credArr[$key.'.CertPath'] : "";                                
+                               
+                               $this->credentialHashmap[$userName] = new PPCertificateCredential($userName, $password, $certPath, $certPassPhrase);
+                               if (isset($credArr[$key.'.AppId'])) {
+                                       $this->credentialHashmap[$userName]->setApplicationId($credArr[$key.'.AppId']);
+                               }                               
+                       } elseif (isset($credArr[$key.".ClientId"]) && isset($credArr[$key.".ClientId"]) ){
+                               $userName = $key;
+                               $this->credentialHashmap[$userName] = array('clientId' => $credArr[$key.".ClientId"], 
+                                               'clientSecret' => $credArr[$key.".ClientSecret"]);
+                       }
+                       if($userName && isset($credArr[$key . ".Subject"]) && trim($credArr[$key . ".Subject"]) != "" ) {
+                               $this->credentialHashmap[$userName]->setThirdPartyAuthorization(
+                                               new PPSubjectAuthorization($credArr[$key . ".Subject"]));
+                       }
+                       
+                       if ($userName && $this->defaultAccountName == null) {
+                               if(array_key_exists($key. '.UserName', $credArr)) {
+                                       $this->defaultAccountName = $credArr[$key . '.UserName'];
+                               } else {
+                                       $this->defaultAccountName = $key;
+                               }
+                       }
+                       $suffix++;
+                       $key = $prefix.$suffix;
+               }
+
+       }
+
+       /*
+        * Obtain Credential Object based on UserId provided.
+        */
+       public function getCredentialObject($userId = null){
+               
+               if($userId == null) {                   
+                       $credObj = $this->credentialHashmap[$this->defaultAccountName];
+               } else if (array_key_exists($userId, $this->credentialHashmap)) {
+                       $credObj = $this->credentialHashmap[$userId];
+               }
+                       
+               if (empty($credObj)) {
+                       throw new PPInvalidCredentialException("Invalid userId $userId");
+               }
+               return $credObj;
+       }
+       
+       
+       public function __clone()
+       {
+               trigger_error('Clone is not allowed.', E_USER_ERROR);
+       }
+
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPHttpConfig.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPHttpConfig.php
new file mode 100644 (file)
index 0000000..a8523bc
--- /dev/null
@@ -0,0 +1,158 @@
+<?php
+namespace PayPal\Core;
+use PayPal\Exception\PPConfigurationException;
+class PPHttpConfig {
+
+       /**
+        * Some default options for curl
+        * These are typically overridden by PPConnectionManager
+        */
+       public static $DEFAULT_CURL_OPTS = array(
+               CURLOPT_SSLVERSION => 3,
+               CURLOPT_CONNECTTIMEOUT => 10,
+               CURLOPT_RETURNTRANSFER => TRUE,
+               CURLOPT_TIMEOUT        => 60,   // maximum number of seconds to allow cURL functions to execute
+               CURLOPT_USERAGENT      => 'PayPal-PHP-SDK',
+               CURLOPT_HTTPHEADER     => array(),
+               CURLOPT_SSL_VERIFYHOST => 2,
+               CURLOPT_SSL_VERIFYPEER => 1
+       );      
+       
+       const HEADER_SEPARATOR = ';';   
+       const HTTP_GET = 'GET';
+       const HTTP_POST = 'POST';
+
+       private $headers = array();
+
+       private $curlOptions;
+
+       private $url;
+
+       private $method;
+       /***
+        * Number of times to retry a failed HTTP call
+        */
+       private $retryCount;
+
+       /**
+        * 
+        * @param string $url
+        * @param string $method  HTTP method (GET, POST etc) defaults to POST
+        */
+       public function __construct($url=null, $method=self::HTTP_POST) {
+               $this->url = $url;
+               $this->method = $method;
+               $this->curlOptions = self::$DEFAULT_CURL_OPTS;
+       }
+       
+       public function getUrl() {
+               return $this->url;
+       }
+       
+       public function getMethod() {
+               return $this->method;
+       }
+       
+       public function getHeaders() {
+               return $this->headers;
+       }
+       
+       public function getHeader($name) {
+               if(array_key_exists($name, $this->headers)) {
+                       return $this->headers[$name];
+               }
+               return NULL;
+       }
+
+       public function setUrl($url) {
+               $this->url = $url;
+       }
+       
+       public function setHeaders(array $headers) {
+               $this->headers = $headers;
+       }
+
+       public function addHeader($name, $value, $overWrite=true) {
+               if(!array_key_exists($name, $this->headers) || $overWrite) {
+                       $this->headers[$name] = $value;
+               } else {
+                       $this->headers[$name] = $this->headers[$name] . HEADER_SEPARATOR . $value;                      
+               }
+       }
+       
+       public function removeHeader($name) {
+               unset($this->headers[$name]);
+       }
+
+       
+       
+       public function getCurlOptions() {
+               return $this->curlOptions;
+       }
+
+       public function addCurlOption($name, $value) {
+               $this->curlOptions[$name] = $value;
+       }
+
+       public function setCurlOptions($options) {
+               $this->curlOptions = $options;
+       }
+
+       
+
+       /**
+        * Set ssl parameters for certificate based client authentication
+        *
+        * @param string $certPath - path to client certificate file (PEM formatted file)
+        */
+       public function setSSLCert($certPath, $passPhrase=NULL) {               
+               $this->curlOptions[CURLOPT_SSLCERT] = realpath($certPath);
+               if(isset($passPhrase) && trim($passPhrase) != "") {
+                       $this->curlOptions[CURLOPT_SSLCERTPASSWD] = $passPhrase;
+               }
+       }
+
+       /**
+        * Set connection timeout in seconds
+        * @param integer $timeout
+        */
+       public function setHttpTimeout($timeout) {
+               $this->curlOptions[CURLOPT_CONNECTTIMEOUT] = $timeout;
+       }
+
+       /**
+        * Set HTTP proxy information
+        * @param string $proxy
+        * @throws PPConfigurationException
+        */
+       public function setHttpProxy($proxy) {
+               $urlParts = parse_url($proxy);
+               if($urlParts == false || !array_key_exists("host", $urlParts))
+                       throw new PPConfigurationException("Invalid proxy configuration ".$proxy);
+
+               $this->curlOptions[CURLOPT_PROXY] = $urlParts["host"];
+               if(isset($urlParts["port"]))
+                       $this->curlOptions[CURLOPT_PROXY] .=  ":" . $urlParts["port"];
+               if(isset($urlParts["user"]))
+                       $this->curlOptions[URLOPT_PROXYUSERPWD] = $urlParts["user"] . ":" . $urlParts["pass"];
+       }       
+       
+       /**
+        * @param integer $retry
+        */
+       public function setHttpRetryCount($retryCount) {
+               $this->retryCount = $retryCount;
+       }       
+
+       public function getHttpRetryCount() {
+               return $this->retryCount;
+       }
+       
+       /**
+        * Sets the User-Agent string on the HTTP request
+        * @param string $userAgentString
+        */
+       public function setUserAgent($userAgentString) {
+               $this->curlOptions[CURLOPT_USERAGENT] = $userAgentString;
+       }
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPHttpConnection.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPHttpConnection.php
new file mode 100644 (file)
index 0000000..2c39520
--- /dev/null
@@ -0,0 +1,112 @@
+<?php
+namespace PayPal\Core;
+use PayPal\Core\PPLoggingManager;
+use PayPal\Exception\PPConfigurationException;
+use PayPal\Exception\PPConnectionException;
+
+/**
+ * A wrapper class based on the curl extension.
+ * Requires the PHP curl module to be enabled.
+ * See for full requirements the PHP manual: http://php.net/curl
+ */
+
+
+class PPHttpConnection
+{
+
+       private $httpConfig;
+
+       /**
+        * HTTP status codes for which a retry must be attempted
+        */
+       private static $retryCodes = array('401', '403', '404', );
+
+       private $logger;
+
+       public function __construct($httpConfig, $config)
+       {
+               if( !function_exists("curl_init") ) {
+                       throw new PPConfigurationException("Curl module is not available on this system");
+               }
+               $this->httpConfig = $httpConfig;
+               $this->logger = new PPLoggingManager(__CLASS__, $config);
+       }       
+
+       private function getHttpHeaders() {
+               
+               $ret = array();
+               foreach($this->httpConfig->getHeaders() as $k=>$v) {
+                       $ret[] = "$k: $v";
+               }
+               return $ret;
+       }
+       
+       /**
+        * Executes an HTTP request
+        *
+        * @param string $data query string OR POST content as a string
+        * @throws PPConnectionException
+        */
+       public function execute($data) {
+               $this->logger->fine("Connecting to " . $this->httpConfig->getUrl());                    
+               $this->logger->fine("Payload " . $data);
+
+               $ch = curl_init($this->httpConfig->getUrl());
+               curl_setopt_array($ch, $this->httpConfig->getCurlOptions());            
+               curl_setopt($ch, CURLOPT_URL, $this->httpConfig->getUrl());             
+               curl_setopt($ch, CURLOPT_HEADER, false);
+               curl_setopt($ch, CURLOPT_HTTPHEADER, $this->getHttpHeaders());
+               
+               switch($this->httpConfig->getMethod()) {
+                       case 'POST':
+                               curl_setopt($ch, CURLOPT_POST, true);
+                               curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+                               break;
+               }
+               if($this->httpConfig->getMethod() != NULL) {
+                       curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->httpConfig->getMethod());
+               }
+               foreach($this->getHttpHeaders() as $header) {
+                       //TODO: Strip out credentials and other secure info when logging.
+                       $this->logger->info("Adding header $header");
+               }
+               $result = curl_exec($ch);
+               if ((curl_errno($ch) == 60) && ($this->httpConfig->getMethod() != "DELETE")) {
+                       $this->logger->info("Invalid or no certificate authority found - Retrying using bundled CA certs file");
+                       curl_setopt($ch, CURLOPT_CAINFO,
+                       dirname(__FILE__) . '/cacert.pem');
+                       $result = curl_exec($ch);
+               }
+               $httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+               $retries = 0;
+               if(in_array($httpStatus, self::$retryCodes) && $this->httpConfig->getHttpRetryCount() != null) {
+                       $this->logger->info("Got $httpStatus response from server. Retrying");
+
+                       do      {
+                               $result = curl_exec($ch);
+                               $httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+                       } while (in_array($httpStatus, self::$retryCodes) && (++$retries < $this->httpConfig->getHttpRetryCount()) );
+               }
+               if ( curl_errno($ch) ) {
+                       $ex = new PPConnectionException($this->httpConfig->getUrl(), curl_error($ch), curl_errno($ch));
+                       curl_close($ch);
+                       throw $ex;
+               }
+
+               curl_close($ch);
+
+               if(in_array($httpStatus, self::$retryCodes)) {
+                       $ex = new PPConnectionException($this->httpConfig->getUrl() , 
+                                       "Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}. Retried $retries times.");
+                       $ex->setData($result);
+                       throw $ex;
+               } else if($httpStatus < 200 || $httpStatus >=300) {
+                       $ex = new PPConnectionException($this->httpConfig->getUrl() , 
+                                       "Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}.");
+                       $ex->setData($result);
+                       throw $ex;
+               }
+               return $result;
+       }
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPLoggingManager.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPLoggingManager.php
new file mode 100644 (file)
index 0000000..cc817e3
--- /dev/null
@@ -0,0 +1,77 @@
+<?php
+namespace PayPal\Core;
+/**
+ * Simple Logging Manager.
+ * This does an error_log for now
+ * Potential frameworks to use are PEAR logger, log4php from Apache
+ */
+
+class PPLoggingLevel {
+
+       // FINE Logging Level
+       const FINE = 3;
+
+       // INFO Logging Level
+       const INFO = 2;
+
+       // WARN Logging Level
+       const WARN = 1;
+
+       // ERROR Logging Level
+       const ERROR = 0;
+}
+
+class PPLoggingManager {
+
+       // Default Logging Level
+       const DEFAULT_LOGGING_LEVEL = 0;
+
+       // Logger name
+       private $loggerName;
+
+       // Log enabled
+       private $isLoggingEnabled;
+
+       // Configured logging level
+       private $loggingLevel;
+
+       // Configured logging file
+       private $loggerFile;
+
+       public function __construct($loggerName, $config = null) {
+               $this->loggerName = $loggerName;
+               if($config == null) {
+                       $config = PPConfigManager::getInstance()->getConfigHashmap();
+               }               
+               $this->isLoggingEnabled = (array_key_exists('log.LogEnabled', $config) && $config['log.LogEnabled'] == '1');            
+                
+               if($this->isLoggingEnabled) {
+                       $this->loggerFile = ($config['log.FileName']) ? $config['log.FileName'] : ini_get('error_log');
+                       $loggingLevel = strtoupper($config['log.LogLevel']);
+                       $this->loggingLevel = (isset($loggingLevel) && defined(__NAMESPACE__."\\PPLoggingLevel::$loggingLevel")) ? constant(__NAMESPACE__."\\PPLoggingLevel::$loggingLevel") : PPLoggingManager::DEFAULT_LOGGING_LEVEL;
+               }
+       }
+
+       private function log($message, $level=PPLoggingLevel::INFO) {
+               if($this->isLoggingEnabled && ($level <= $this->loggingLevel)) {
+                       error_log( $this->loggerName . ": $message\n", 3, $this->loggerFile);
+               }
+       }
+
+       public function error($message) {
+               $this->log($message, PPLoggingLevel::ERROR);
+       }
+
+       public function warning($message) {
+               $this->log($message, PPLoggingLevel::WARN);
+       }
+
+       public function info($message) {
+               $this->log($message, PPLoggingLevel::INFO);
+       }
+
+       public function fine($message) {
+               $this->log($message, PPLoggingLevel::FINE);
+       }
+
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPMessage.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPMessage.php
new file mode 100644 (file)
index 0000000..82be10a
--- /dev/null
@@ -0,0 +1,117 @@
+<?php
+namespace PayPal\Core;
+use PayPal\Core\PPUtils;
+/**
+ * @author 
+ */
+abstract class PPMessage
+{
+
+       /**
+        * @param string $prefix
+        * @return string
+        */
+       public function toNVPString($prefix = '')
+       {
+               $nvp = array();
+               foreach (get_object_vars($this) as $property => $defaultValue) {
+                       
+                       if (($propertyValue = $this->{$property}) === NULL || $propertyValue == NULL) {
+                               continue;
+                       }
+
+                       if (is_object($propertyValue)) {
+                               $nvp[] = $propertyValue->toNVPString($prefix . $property . '.'); // prefix
+
+                       } elseif (is_array($defaultValue) || is_array($propertyValue)) {
+                               foreach (array_values($propertyValue) as $i => $item) {
+                                       if (!is_object($item)){
+                        $nvp[] = $prefix . $property . "($i)" . '=' . urlencode($item);
+                                       }else{
+                        $nvp[] = $item->toNVPString($prefix . $property . "($i).");
+                    }
+                               }
+
+                       } else {
+                               // Handle classes with attributes
+                               if($property == 'value' && ($anno = PPUtils::propertyAnnotations($this, $property)) != NULL && isset($anno['value']) ) {
+                                       $nvpKey = substr($prefix, 0, -1); // Remove the ending '.'
+                               } else {
+                                       $nvpKey = $prefix . $property ;
+                               }
+                               $nvp[] = $nvpKey . '=' . urlencode($propertyValue);
+                       }
+               }
+
+               return implode('&', $nvp);
+       }
+
+
+
+       /**
+        * @param array $map
+        * @param string $prefix
+        */
+       public function init(array $map = array(), $prefix = '')
+       {
+               if (empty($map)) {
+                       return;
+               }
+
+               $map = PPUtils::lowerKeys($map);
+
+               foreach (get_object_vars($this) as $property => $defaultValue) {
+                       if (array_key_exists($propKey = strtolower($prefix . $property), $map) &&
+                                       $this->isBuiltInType(($type = PPUtils::propertyType($this, $property)))){
+                               $type = PPUtils::propertyType($this, $property);                                
+                               $this->{$property} = urldecode($map[$propKey]);
+                               continue; // string
+
+                       } elseif (!$filtered = PPUtils::filterKeyPrefix($map, $propKey)) {
+                               continue; // NULL
+                       }
+               
+                       if (!class_exists($type = PPUtils::propertyType($this, $property)) && !$this->isBuiltInType($type)) {
+                               trigger_error("Class $type not found.", E_USER_NOTICE);
+                               continue; // just ignore
+                       }
+
+                       if (is_array($defaultValue) || PPUtils::isPropertyArray($this, $property)) { // array of objects                                
+                               if($this->isBuiltInType($type)) { // Array of simple types                                      
+                                       foreach($filtered as $key => $value) {
+                                               $this->{$property}[trim($key, "()")] = urldecode($value);
+                                       }
+                               } else { // Array of complex objects    
+                                       $delim = '.';                                   
+                                       for ($i = 0; $itemValues = PPUtils::filterKeyPrefix($filtered, "($i)") ;$i++) {                                 
+                                               $this->{$property}[$i] = $item = new $type();
+                                               $item->init(PPUtils::filterKeyPrefix($itemValues, "."));
+                                               if(array_key_exists("", $itemValues)) {
+                                                       $item->value = urldecode($itemValues[""]);
+                                               }
+                                       }
+                                       // Handle cases where we have a list of objects
+                                       // with just the value present and all attributes values are null 
+                                       foreach($filtered as $key => $value) {                                          
+                                               $idx = trim($key, "()");                                                
+                                               if(is_numeric($idx) && (is_null($this->{$property}) || !array_key_exists($idx, $this->{$property})) ) {
+                                                       $this->{$property}[$idx] = new $type;
+                                                       $this->{$property}[$idx]->value = urldecode($value);
+                                               }                                               
+                                       }
+                               }                               
+                       } else { // one object
+                               $this->{$property} = new $type();
+                               $this->{$property}->init(PPUtils::filterKeyPrefix($filtered, '.')); // unprefix
+                               if(array_key_exists("", $filtered)) {
+                                       $this->{$property}->value = urldecode($filtered[""]);
+                               }
+                       }
+               }
+       }
+
+       private function isBuiltInType($typeName) {
+               static $types = array('string', 'int', 'integer', 'bool', 'boolean', 'float', 'decimal', 'long', 'datetime', 'double');
+               return in_array(strtolower($typeName), $types);
+       }
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPRequest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPRequest.php
new file mode 100644 (file)
index 0000000..22e7f69
--- /dev/null
@@ -0,0 +1,73 @@
+<?php
+namespace PayPal\Core;
+/**
+ * Encapsulates API request information
+ *
+ */
+class PPRequest {
+       
+       /**
+        * Request Object
+        *
+        * @var object
+        */
+       private $requestObject;
+       
+       /**
+        * Optional credentials associated with
+        * the request
+        * @var ICredential
+        */
+       private $credential;
+               
+       /**
+        * Transport binding for this request.
+        * Can be NVP, SOAP etc
+        * @var string
+        */
+       private $bindingType;
+
+       /**
+        * 
+        * Holder for any binding specific info
+        * @var array
+        */
+       private $bindingInfo = array();
+       
+       public function __construct($requestObject, $bindingType) {
+               $this->requestObject = $requestObject;
+               $this->bindingType = $bindingType;
+       }
+
+       public function getRequestObject() {
+               return $this->requestObject;
+       }
+       
+       public function getBindingType() {
+               return $this->bindingType;
+       }
+       
+       public function getBindingInfo($name=NULL) {
+               if(isset($name)) {
+                       return $this->bindingInfo[$name];
+               }
+               return $this->bindingInfo;
+       }
+       
+       /**
+        * 
+        * @param string $name
+        * @param mixed $value
+        */
+       public function addBindingInfo($name, $value) {
+               $this->bindingInfo[$name] = $value;
+       }
+       
+       public function setCredential($credential) {
+               $this->credential = $credential;
+       }
+       
+       public function getCredential() {
+               return $this->credential;
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPUtils.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPUtils.php
new file mode 100644 (file)
index 0000000..3ef6d8b
--- /dev/null
@@ -0,0 +1,397 @@
+<?php
+namespace PayPal\Core;
+class PPUtils
+{
+
+       /**
+        *
+        * Convert a Name Value Pair (NVP) formatted string into
+        * an associative array taking care to urldecode array values
+        *
+        * @param string $nvpString
+        * @return array
+        */
+       public static function nvpToMap($nvpString)
+       {
+               $ret = array();
+               $params = explode("&", $nvpString);
+               foreach ($params as $p) {
+                       list($k, $v) = explode("=", $p);
+                       $ret[$k] = urldecode($v);
+               }
+               return $ret;
+       }
+
+
+
+       /**
+        * Returns true if the array contains a key like $key
+        *
+        * @param array $map
+        * @param string $key
+        * @return bool
+        */
+       public static function array_match_key($map, $key)
+       {
+               $replace = str_replace(array(
+                               '(',
+                               ')',
+                               '.'
+               ), array(
+                               '\(',
+                               '\)',
+                               '\.'
+               ), $key);
+
+               $pattern = "/$replace*/";
+
+               foreach ($map as $k => $v) {
+                       preg_match($pattern, $k, $matches);
+                       if (count($matches) > 0) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+
+
+       /**
+        * Get the local IP address. The client address is a required
+        * request parameter for some API calls
+        */
+       public static function getLocalIPAddress()
+       {
+               if (array_key_exists("SERVER_ADDR", $_SERVER)) {
+                       // SERVER_ADDR is available only if we are running the CGI SAPI
+                       return $_SERVER['SERVER_ADDR'];
+
+               } else {
+                       if (function_exists("gethostname")) {
+                               // gethostname is available only in PHP >= v5.3
+                               return gethostbyname(gethostname());
+
+                       } else {
+                               // fallback if nothing works
+                               return "127.0.0.1";
+                       }
+               }
+       }
+
+       public static function xmlToArray($xmlInput)
+       {
+               $xml = simplexml_load_string($xmlInput);
+
+               $ns = $xml->getNamespaces(true);
+               $soap = $xml->children($ns['SOAP-ENV']);
+               $getChild = $soap->Body->children();
+               $array = array();
+               $ret = PPUtils::convertXmlObjToArr($getChild, $array);
+               return $ret;
+       }
+
+
+
+       private static function convertXmlObjToArr($obj, &$arr)
+       {
+               $children = $obj->children();
+               foreach ($children as $elementName => $node) {
+                       $nextIdx = count($arr);
+                       $arr[$nextIdx] = array();
+                       $arr[$nextIdx]['name'] = strtolower((string)$elementName);
+                       $arr[$nextIdx]['attributes'] = array();
+                       $attributes = $node->attributes();
+                       foreach ($attributes as $attributeName => $attributeValue) {
+                               $attribName = strtolower(trim((string)$attributeName));
+                               $attribVal = trim((string)$attributeValue);
+                               $arr[$nextIdx]['attributes'][$attribName] = $attribVal;
+                       }
+                       $text = (string)$node;
+                       $text = trim($text);
+                       if (strlen($text) > 0) {
+                               $arr[$nextIdx]['text'] = $text;
+                       }
+                       $arr[$nextIdx]['children'] = array();
+                       PPutils::convertXmlObjToArr($node, $arr[$nextIdx]['children']);
+               }
+               return $arr;
+       }
+
+
+
+       /**
+        * Escapes invalid xml characters
+        *
+        * @param $textContent = xml data to be escaped
+        * @return string
+        */
+       public static function escapeInvalidXmlCharsRegex($textContent)
+       {
+               return htmlspecialchars($textContent, (1 | 2), 'UTF-8', false);
+       }
+
+
+
+       /**
+        * @param array $map
+        * @param string $keyPrefix
+        * @return array
+        */
+       public static function filterKeyPrefix(array $map, $keyPrefix)
+       {
+               $filtered = array();
+               foreach ($map as $key => $val) {
+                       if (($pos = stripos($key, $keyPrefix)) !== 0) {
+                               continue;
+                       }
+
+                       $filtered[substr_replace($key, '', 0, strlen($keyPrefix))] = $val;
+               }
+
+               return $filtered;
+       }
+
+
+
+       /**
+        * @var array|ReflectionProperty[]
+        */
+       private static $propertiesRefl = array();
+
+       /**
+        * @var array|string[]
+        */
+       private static $propertiesType = array();
+
+
+
+       /**
+        * @param string $class
+        * @param string $propertyName
+        * @throws RuntimeException
+        * @return string
+        */
+       public static function propertyAnnotations($class, $propertyName)
+       {
+               $class = is_object($class) ? get_class($class) : $class;
+               if (!class_exists('ReflectionProperty')) {
+                       throw new \RuntimeException("Property type of " . $class . "::{$propertyName} cannot be resolved");
+               }
+
+               if ($annotations =& self::$propertiesType[$class][$propertyName]) {
+                       return $annotations;
+               }
+
+               if (!($refl =& self::$propertiesRefl[$class][$propertyName])) {
+                       $refl = new \ReflectionProperty($class, $propertyName);
+               }
+
+               // todo: smarter regexp
+               if (!preg_match_all('~\@([^\s@\(]+)[\t ]*(?:\(?([^\n@]+)\)?)?~i', $refl->getDocComment(), $annots, PREG_PATTERN_ORDER)) {
+                       return NULL;
+               }
+               foreach ($annots[1] as $i => $annot) {
+                       $annotations[strtolower($annot)] = empty($annots[2][$i]) ? TRUE : rtrim($annots[2][$i], " \t\n\r)");
+               }
+
+               return $annotations;
+       }
+
+       /**
+        * @param string $class
+        * @param string $propertyName
+        * @return string
+        */
+       public static function isAttributeProperty($class, $propertyName) {
+               if (($annotations = self::propertyAnnotations($class, $property))) {
+                       return $annotations['attribute'];
+               }
+               return FALSE;
+       }
+
+       /**
+        * @param string $class
+        * @param string $propertyName
+        * @return string
+        */
+       public static function isPropertyArray($class, $propertyName) {
+               if (($annotations = self::propertyAnnotations($class, $propertyName))) {
+                       if (isset($annotations['var']) && substr($annotations['var'], -2) === '[]') {
+                               return TRUE;
+
+                       } elseif (isset($annotations['array'])) {
+                               return TRUE;
+                       }
+               }
+
+               return FALSE;
+       }
+
+
+
+       /**
+        * @param string $class
+        * @param string $propertyName
+        * @throws RuntimeException
+        * @return string
+        */
+       public static function propertyType($class, $propertyName)
+       {
+               if (($annotations = self::propertyAnnotations($class, $propertyName)) && isset($annotations['var'])) {
+                       if (substr($annotations['var'], -2) === '[]') {
+                               return substr($annotations['var'], 0, -2);
+                       }
+
+                       return $annotations['var'];
+               }
+
+               return 'string';
+       }
+
+       /**
+        * @param object $object
+        * @return array
+        */
+       public static function objectProperties($object)
+       {
+               $props = array();
+               foreach (get_object_vars($object) as $property => $default) {
+                       $annotations = self::propertyAnnotations($object, $property);
+                       if (isset($annotations['name'])) {
+                               $props[strtolower($annotations['name'])] = $property;
+                       }
+
+                       $props[strtolower($property)] = $property;
+               }
+
+               return $props;
+       }
+
+
+
+       /**
+        * @param array $array
+        * @return array
+        */
+       public static function lowerKeys(array $array)
+       {
+               $ret = array();
+               foreach ($array as $key => $value) {
+                       $ret[strtolower($key)] = $value;
+               }
+
+               return $ret;
+       }
+
+}
+
+
+
+/**
+ * XMLToArray Generator Class
+ *
+ * @author  :  MA Razzaque Rupom <rupom_315@yahoo.com>, <rupom.bd@gmail.com>
+ *             Moderator, phpResource (LINK1http://groups.yahoo.com/group/phpresource/LINK1)
+ *             URL: LINK2http://www.rupom.infoLINK2
+ * @version :  1.0
+ * @date       06/05/2006
+ * Purpose  : Creating Hierarchical Array from XML Data
+ * Released : Under GPL
+ */
+class XmlToArray
+{
+
+       var $xml = '';
+
+
+
+       /**
+        * Default Constructor
+        *
+        * @param $xml = xml data
+        * @return none
+        */
+       function XmlToArray($xml)
+       {
+               $this->xml = $xml;
+       }
+
+
+
+       /**
+        * _struct_to_array($values, &$i)
+        *
+        * This is adds the contents of the return xml into the array for easier processing.
+        * Recursive, Static
+        *
+        * @access    private
+        * @param    array  $values this is the xml data in an array
+        * @param    int    $i  this is the current location in the array
+        * @return    Array
+        */
+       function _struct_to_array($values, &$i)
+       {
+               $child = array();
+               if (isset($values[$i]['value'])) {
+                       array_push($child, $values[$i]['value']);
+               }
+
+               while ($i++ < count($values)) {
+                       switch ($values[$i]['type']) {
+                               case 'cdata':
+                                       array_push($child, $values[$i]['value']);
+                                       break;
+
+                               case 'complete':
+                                       $name = $values[$i]['tag'];
+                                       if (!empty($name)) {
+                                               $child[$name] = ($values[$i]['value']) ? ($values[$i]['value']) : '';
+                                               if (isset($values[$i]['attributes'])) {
+                                                       $child[$name] = $values[$i]['attributes'];
+                                               }
+                                       }
+                                       break;
+
+                               case 'open':
+                                       $name = $values[$i]['tag'];
+                                       $size = isset($child[$name]) ? sizeof($child[$name]) : 0;
+                                       $child[$name][$size] = $this->_struct_to_array($values, $i);
+                                       break;
+
+                               case 'close':
+                                       return $child;
+                                       break;
+                       }
+               }
+               return $child;
+       }
+
+
+
+       /**
+        * createArray($data)
+        *
+        * This is adds the contents of the return xml into the array for easier processing.
+        *
+        * @access    public
+        * @return    Array
+        */
+       function createArray()
+       {
+               $xml = $this->xml;
+               $values = array();
+               $index = array();
+               $array = array();
+               $parser = xml_parser_create();
+               xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
+               xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
+               xml_parse_into_struct($parser, $xml, $values, $index);
+               xml_parser_free($parser);
+               $i = 0;
+               $name = $values[$i]['tag'];
+               $array[$name] = isset($values[$i]['attributes']) ? $values[$i]['attributes'] : '';
+               $array[$name] = $this->_struct_to_array($values, $i);
+               return $array;
+       }
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPXmlMessage.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPXmlMessage.php
new file mode 100644 (file)
index 0000000..123bf4b
--- /dev/null
@@ -0,0 +1,186 @@
+<?php
+namespace PayPal\Core;
+/**
+ * @author 
+ */
+abstract class PPXmlMessage
+{
+
+       /**
+        * @return string
+        */
+       public function toSOAP()
+       {
+               return $this->toXMLString();
+       }
+
+
+
+       /**
+        * @return string
+        */
+       public function toXMLString()
+       {
+               if (count($properties = get_object_vars($this)) >= 2 && array_key_exists('value', $properties)) {
+                       $attributes = array();
+                       foreach (array_keys($properties) as $property) {
+                               if ($property === 'value') continue;
+                               if (($annots = PPUtils::propertyAnnotations($this, $property)) && isset($annots['attribute'])) {
+                                       if (($propertyValue = $this->{$property}) === NULL || $propertyValue == NULL) {
+                                               $attributes[] = NULL;
+                                               continue;
+                                       }
+
+                                       $attributes[] = $property . '="' . PPUtils::escapeInvalidXmlCharsRegex($propertyValue) . '"';
+                               }
+                       }
+
+                       if (count($attributes)) {
+                               return implode(' ', $attributes) . '>' . PPUtils::escapeInvalidXmlCharsRegex($this->value);
+                       }
+               }
+
+               $xml = array();
+               foreach ($properties as $property => $defaultValue) {
+                       if (($propertyValue = $this->{$property}) === NULL || $propertyValue == NULL) {
+                               continue;
+                       }
+
+                       if (is_array($defaultValue) || is_array($propertyValue)) {
+                               foreach ($propertyValue as $item) {
+                                       if (!is_object($item)) {
+                                               $xml[] = $this->buildProperty($property, $item);
+                                       }else{
+                                               $xml[] = $this->buildProperty($property, $item);
+                                       }
+                               }
+
+                       } else {
+                               $xml[] = $this->buildProperty($property, $propertyValue);
+                       }
+               }
+
+               return implode($xml);
+       }
+
+
+
+       /**
+        * @param string $property
+        * @param PPXmlMessage|string $value
+        * @param string $namespace
+        * @return string
+        */
+       private function buildProperty($property, $value, $namespace = 'ebl')
+       {
+               $annotations = PPUtils::propertyAnnotations($this, $property);
+               if (!empty($annotations['namespace'])) {
+                       $namespace = $annotations['namespace'];
+               }
+               if (!empty($annotations['name'])) {
+                       $property = $annotations['name'];
+               }
+
+               $el = '<' . $namespace . ':' . $property;
+               if (!is_object($value)) {
+                       $el .= '>' . PPUtils::escapeInvalidXmlCharsRegex($value);
+
+               } else {
+                       if (substr($value = $value->toXMLString(), 0, 1) === '<' || $value=='') {
+                               $el .= '>' . $value;
+
+                       } else {
+                               $el .= ' ' . $value;
+                       }
+               }
+
+               return $el . '</' . $namespace . ':' . $property . '>';
+       }
+
+
+
+       /**
+        * @param array $map
+        * @param string $prefix
+        */
+       public function init(array $map = array(), $prefix = '')
+       {
+               if (empty($map)) {
+                       return;
+               }
+
+               if (($first = reset($map)) && !is_array($first) && !is_numeric(key($map))) {
+                       parent::init($map, $prefix);
+                       return;
+               }
+
+               $propertiesMap = PPUtils::objectProperties($this);
+               $arrayCtr = array();            
+               foreach ($map as $element) {
+               
+                       if (empty($element) || empty($element['name'])) {
+                               continue;
+
+                       } elseif (!array_key_exists($property = strtolower($element['name']), $propertiesMap)) {
+                               if (!preg_match('~^(.+)[\[\(](\d+)[\]\)]$~', $property, $m)) {
+                                       continue;
+                               }
+
+                               $element['name'] = $m[1];
+                               $element['num'] = $m[2];
+                       }
+                       $element['name'] = $propertiesMap[strtolower($element['name'])];
+                       if(PPUtils::isPropertyArray($this, $element['name'])) {                         
+                               $arrayCtr[$element['name']] = isset($arrayCtr[$element['name']]) ? ($arrayCtr[$element['name']]+1) : 0;                         
+                               $element['num'] = $arrayCtr[$element['name']];
+                       } 
+                       if (!empty($element["attributes"]) && is_array($element["attributes"])) {
+                               foreach ($element["attributes"] as $key => $val) {
+                                       $element["children"][] = array(
+                                               'name' => $key,
+                                               'text' => $val,
+                                       );
+                               }
+
+                               if (isset($element['text'])) {
+                                       $element["children"][] = array(
+                                               'name' => 'value',
+                                               'text' => $element['text'],
+                                       );
+                               }
+
+                               $this->fillRelation($element['name'], $element);
+
+                       } elseif (!empty($element['text'])) {
+                               $this->{$element['name']} = $element['text'];
+
+                       } elseif (!empty($element["children"]) && is_array($element["children"])) {
+                               $this->fillRelation($element['name'], $element);
+                       }
+               }               
+       }
+
+
+
+       /**
+        * @param string $property
+        * @param array $element
+        */
+       private function fillRelation($property, array $element)
+       {
+               if (!class_exists($type = PPUtils::propertyType($this, $property))) {
+                       trigger_error("Class $type not found.", E_USER_NOTICE);
+                       return; // just ignore
+               }
+
+               if (isset($element['num'])) { // array of objects
+                       $this->{$property}[$element['num']] = $item = new $type();
+                       $item->init($element['children']);
+
+               } else {
+                       $this->{$property} = new $type();
+                       $this->{$property}->init($element["children"]);
+               }
+       }
+
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/cacert.pem b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/cacert.pem
new file mode 100644 (file)
index 0000000..1202c20
--- /dev/null
@@ -0,0 +1,171 @@
+Verisign Class 3 Public Primary Certification Authority
+=======================================================
+-----BEGIN CERTIFICATE-----
+MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkGA1UEBhMCVVMx
+FzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmltYXJ5
+IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVow
+XzELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAz
+IFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUA
+A4GNADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhEBarsAx94
+f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/isI19wKTakyYbnsZogy1Ol
+hec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0GCSqGSIb3DQEBAgUAA4GBALtMEivPLCYA
+TxQT3ab7/AoRhIzzKBxnki98tsX63/Dolbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59Ah
+WM1pF+NEHJwZRDmJXNycAA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2Omuf
+Tqj/ZA1k
+-----END CERTIFICATE-----
+
+Verisign Class 3 Public Primary Certification Authority - G2
+============================================================
+-----BEGIN CERTIFICATE-----
+MIIDAjCCAmsCEH3Z/gfPqB63EHln+6eJNMYwDQYJKoZIhvcNAQEFBQAwgcExCzAJBgNVBAYTAlVT
+MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMgUHJpbWFy
+eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2ln
+biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVz
+dCBOZXR3b3JrMB4XDTk4MDUxODAwMDAwMFoXDTI4MDgwMTIzNTk1OVowgcExCzAJBgNVBAYTAlVT
+MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMgUHJpbWFy
+eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2ln
+biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVz
+dCBOZXR3b3JrMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDMXtERXVxp0KvTuWpMmR9ZmDCO
+FoUgRm1HP9SFIIThbbP4pO0M8RcPO/mn+SXXwc+EY/J8Y8+iR/LGWzOOZEAEaMGAuWQcRXfH2G71
+lSk8UOg013gfqLptQ5GVj0VXXn7F+8qkBOvqlzdUMG+7AUcyM83cV5tkaWH4mx0ciU9cZwIDAQAB
+MA0GCSqGSIb3DQEBBQUAA4GBAFFNzb5cy5gZnBWyATl4Lk0PZ3BwmcYQWpSkU01UbSuvDV1Ai2TT
+1+7eVmGSX6bEHRBhNtMsJzzoKQm5EWR0zLVznxxIqbxhAe7iF6YM40AIOw7n60RzKprxaZLvcRTD
+Oaxxp5EJb+RxBrO6WVcmeQD2+A2iMzAo1KpYoJ2daZH9
+-----END CERTIFICATE-----
+
+
+Verisign Class 3 Public Primary Certification Authority - G3
+============================================================
+-----BEGIN CERTIFICATE-----
+MIIEGjCCAwICEQCbfgZJoz5iudXukEhxKe9XMA0GCSqGSIb3DQEBBQUAMIHKMQswCQYDVQQGEwJV
+UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv
+cmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl
+IG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNh
+dGlvbiBBdXRob3JpdHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQsw
+CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRy
+dXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhv
+cml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDMgUHVibGljIFByaW1hcnkg
+Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
+ggEBAMu6nFL8eB8aHm8bN3O9+MlrlBIwT/A2R/XQkQr1F8ilYcEWQE37imGQ5XYgwREGfassbqb1
+EUGO+i2tKmFZpGcmTNDovFJbcCAEWNF6yaRpvIMXZK0Fi7zQWM6NjPXr8EJJC52XJ2cybuGukxUc
+cLwgTS8Y3pKI6GyFVxEa6X7jJhFUokWWVYPKMIno3Nij7SqAP395ZVc+FSBmCC+Vk7+qRy+oRpfw
+EuL+wgorUeZ25rdGt+INpsyow0xZVYnm6FNcHOqd8GIWC6fJXwzw3sJ2zq/3avL6QaaiMxTJ5Xpj
+055iN9WFZZ4O5lMkdBteHRJTW8cs54NJOxWuimi5V5cCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEA
+ERSWwauSCPc/L8my/uRan2Te2yFPhpk0djZX3dAVL8WtfxUfN2JzPtTnX84XA9s1+ivbrmAJXx5f
+j267Cz3qWhMeDGBvtcC1IyIuBwvLqXTLR7sdwdela8wv0kL9Sd2nic9TutoAWii/gt/4uhMdUIaC
+/Y4wjylGsB49Ndo4YhYYSq3mtlFs3q9i6wHQHiT+eo8SGhJouPtmmRQURVyu565pF4ErWjfJXir0
+xuKhXFSbplQAz/DxwceYMBo7Nhbbo27q/a2ywtrvAkcTisDxszGtTxzhT5yvDwyd93gN2PQ1VoDa
+t20Xj50egWTh/sVFuq1ruQp6Tk9LhO5L8X3dEQ==
+-----END CERTIFICATE-----
+
+Verisign Class 4 Public Primary Certification Authority - G3
+============================================================
+-----BEGIN CERTIFICATE-----
+MIIEGjCCAwICEQDsoKeLbnVqAc/EfMwvlF7XMA0GCSqGSIb3DQEBBQUAMIHKMQswCQYDVQQGEwJV
+UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv
+cmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl
+IG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDQgUHVibGljIFByaW1hcnkgQ2VydGlmaWNh
+dGlvbiBBdXRob3JpdHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQsw
+CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRy
+dXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhv
+cml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDQgUHVibGljIFByaW1hcnkg
+Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
+ggEBAK3LpRFpxlmr8Y+1GQ9Wzsy1HyDkniYlS+BzZYlZ3tCD5PUPtbut8XzoIfzk6AzufEUiGXaS
+tBO3IFsJ+mGuqPKljYXCKtbeZjbSmwL0qJJgfJxptI8kHtCGUvYynEFYHiK9zUVilQhu0GbdU6LM
+8BDcVHOLBKFGMzNcF0C5nk3T875Vg+ixiY5afJqWIpA7iCXy0lOIAgwLePLmNxdLMEYH5IBtptiW
+Lugs+BGzOA1mppvqySNb247i8xOOGlktqgLw7KSHZtzBP/XYufTsgsbSPZUd5cBPhMnZo0QoBmrX
+Razwa2rvTl/4EYIeOGM0ZlDUPpNz+jDDZq3/ky2X7wMCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEA
+j/ola09b5KROJ1WrIhVZPMq1CtRK26vdoV9TxaBXOcLORyu+OshWv8LZJxA6sQU8wHcxuzrTBXtt
+mhwwjIDLk5Mqg6sFUYICABFna/OIYUdfA5PVWw3g8dShMjWFsjrbsIKr0csKvE+MW8VLADsfKoKm
+fjaF3H48ZwC15DtS4KjrXRX5xm3wrR0OhbepmnMUWluPQSjA1egtTaRezarZ7c7c2NU8Qh0XwRJd
+RTjDOPP8hS6DRkiy1yBfkjaP53kPmF6Z6PDQpLv1U70qzlmwr25/bLvSHgCwIe34QWKCudiyxLtG
+UPMxxY8BqHTr9Xgn2uf3ZkPznoM+IKrDNWCRzg==
+-----END CERTIFICATE-----
+VeriSign Class 3 Public Primary Certification Authority - G5
+============================================================
+-----BEGIN CERTIFICATE-----
+MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCByjELMAkGA1UE
+BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO
+ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk
+IHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRp
+ZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCB
+yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2ln
+biBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBh
+dXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmlt
+YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
+ggEKAoIBAQCvJAgIKXo1nmAMqudLO07cfLw8RRy7K+D+KQL5VwijZIUVJ/XxrcgxiV0i6CqqpkKz
+j/i5Vbext0uz/o9+B1fs70PbZmIVYc9gDaTY3vjgw2IIPVQT60nKWVSFJuUrjxuf6/WhkcIzSdhD
+Y2pSS9KP6HBRTdGJaXvHcPaz3BJ023tdS1bTlr8Vd6Gw9KIl8q8ckmcY5fQGBO+QueQA5N06tRn/
+Arr0PO7gi+s3i+z016zy9vA9r911kTMZHRxAy3QkGSGT2RT+rCpSx4/VBEnkjWNHiDxpg8v+R70r
+fk/Fla4OndTRQ8Bnc+MUCH7lP59zuDMKz10/NIeWiu5T6CUVAgMBAAGjgbIwga8wDwYDVR0TAQH/
+BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2Uv
+Z2lmMCEwHzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVy
+aXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFH/TZafC3ey78DAJ80M5+gKvMzEzMA0GCSqG
+SIb3DQEBBQUAA4IBAQCTJEowX2LP2BqYLz3q3JktvXf2pXkiOOzEp6B4Eq1iDkVwZMXnl2YtmAl+
+X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKE
+KQsTb47bDN0lAtukixlE0kF6BWlKWE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiC
+Km0oHw0LxOXnGiYZ4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vE
+ZV8NhnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq
+-----END CERTIFICATE-----
+VeriSign Universal Root Certification Authority
+===============================================
+-----BEGIN CERTIFICATE-----
+MIIEuTCCA6GgAwIBAgIQQBrEZCGzEyEDDrvkEhrFHTANBgkqhkiG9w0BAQsFADCBvTELMAkGA1UE
+BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO
+ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwOCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk
+IHVzZSBvbmx5MTgwNgYDVQQDEy9WZXJpU2lnbiBVbml2ZXJzYWwgUm9vdCBDZXJ0aWZpY2F0aW9u
+IEF1dGhvcml0eTAeFw0wODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIG9MQswCQYDVQQGEwJV
+UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv
+cmsxOjA4BgNVBAsTMShjKSAyMDA4IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl
+IG9ubHkxODA2BgNVBAMTL1ZlcmlTaWduIFVuaXZlcnNhbCBSb290IENlcnRpZmljYXRpb24gQXV0
+aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx2E3XrEBNNti1xWb/1hajCMj
+1mCOkdeQmIN65lgZOIzF9uVkhbSicfvtvbnazU0AtMgtc6XHaXGVHzk8skQHnOgO+k1KxCHfKWGP
+MiJhgsWHH26MfF8WIFFE0XBPV+rjHOPMee5Y2A7Cs0WTwCznmhcrewA3ekEzeOEz4vMQGn+HLL72
+9fdC4uW/h2KJXwBL38Xd5HVEMkE6HnFuacsLdUYI0crSK5XQz/u5QGtkjFdN/BMReYTtXlT2NJ8I
+AfMQJQYXStrxHXpma5hgZqTZ79IugvHw7wnqRMkVauIDbjPTrJ9VAMf2CGqUuV/c4DPxhGD5WycR
+tPwW8rtWaoAljQIDAQABo4GyMIGvMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMG0G
+CCsGAQUFBwEMBGEwX6FdoFswWTBXMFUWCWltYWdlL2dpZjAhMB8wBwYFKw4DAhoEFI/l0xqGrI2O
+a8PPgGrUSBgsexkuMCUWI2h0dHA6Ly9sb2dvLnZlcmlzaWduLmNvbS92c2xvZ28uZ2lmMB0GA1Ud
+DgQWBBS2d/ppSEefUxLVwuoHMnYH0ZcHGTANBgkqhkiG9w0BAQsFAAOCAQEASvj4sAPmLGd75JR3
+Y8xuTPl9Dg3cyLk1uXBPY/ok+myDjEedO2Pzmvl2MpWRsXe8rJq+seQxIcaBlVZaDrHC1LGmWazx
+Y8u4TB1ZkErvkBYoH1quEPuBUDgMbMzxPcP1Y+Oz4yHJJDnp/RVmRvQbEdBNc6N9Rvk97ahfYtTx
+P/jgdFcrGJ2BtMQo2pSXpXDrrB2+BxHw1dvd5Yzw1TKwg+ZX4o+/vqGqvz0dtdQ46tewXDpPaj+P
+wGZsY6rp2aQW9IHRlRQOfc2VNNnSj3BzgXucfr2YYdhFh5iQxeuGMMY1v/D/w1WIg0vvBZIGcfK4
+mJO37M2CYfE45k+XmCpajQ==
+-----END CERTIFICATE-----
+
+VeriSign Class 3 Public Primary Certification Authority - G4
+============================================================
+-----BEGIN CERTIFICATE-----
+MIIDhDCCAwqgAwIBAgIQL4D+I4wOIg9IZxIokYesszAKBggqhkjOPQQDAzCByjELMAkGA1UEBhMC
+VVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3
+b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVz
+ZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmlj
+YXRpb24gQXV0aG9yaXR5IC0gRzQwHhcNMDcxMTA1MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCByjEL
+MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBU
+cnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRo
+b3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5
+IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzQwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAASnVnp8
+Utpkmw4tXNherJI9/gHmGUo9FANL+mAnINmDiWn6VMaaGF5VKmTeBvaNSjutEDxlPZCIBIngMGGz
+rl0Bp3vefLK+ymVhAIau2o970ImtTR1ZmkGxvEeA3J5iw/mjgbIwga8wDwYDVR0TAQH/BAUwAwEB
+/zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2UvZ2lmMCEw
+HzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVyaXNpZ24u
+Y29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFLMWkf3upm7ktS5Jj4d4gYDs5bG1MAoGCCqGSM49BAMD
+A2gAMGUCMGYhDBgmYFo4e1ZC4Kf8NoRRkSAsdk1DPcQdhCPQrNZ8NQbOzWm9kA3bbEhCHQ6qQgIx
+AJw9SDkjOVgaFRJZap7v1VmyHVIsmXHNxynfGyphe3HR3vPA5Q06Sqotp9iGKt0uEA==
+-----END CERTIFICATE-----
+Verisign Class 3 Public Primary Certification Authority
+=======================================================
+-----BEGIN CERTIFICATE-----
+MIICPDCCAaUCEDyRMcsf9tAbDpq40ES/Er4wDQYJKoZIhvcNAQEFBQAwXzELMAkGA1UEBhMCVVMx
+FzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmltYXJ5
+IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2MDEyOTAwMDAwMFoXDTI4MDgwMjIzNTk1OVow
+XzELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAz
+IFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUA
+A4GNADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhEBarsAx94
+f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/isI19wKTakyYbnsZogy1Ol
+hec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0GCSqGSIb3DQEBBQUAA4GBABByUqkFFBky
+CEHwxWsKzH4PIRnN5GfcX6kb5sroc50i2JhucwNhkcV8sEVAbkSdjbCxlnRhLQ2pRdKkkirWmnWX
+bj9T/UWZYB2oK0z5XqcJ2HUw19JlYD1n1khVdWk/kfVIC0dpImmClr7JyDiGSnoscxlIaU5rfGW/
+D/xwzoiQ
+-----END CERTIFICATE-----
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Exception/OAuthException.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Exception/OAuthException.php
new file mode 100644 (file)
index 0000000..e10ea33
--- /dev/null
@@ -0,0 +1,8 @@
+<?php
+namespace PayPal\Exception;
+/* Generic exception class
+ */
+class OAuthException extends \Exception {
+       // pass
+}
+?>
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Exception/PPConfigurationException.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Exception/PPConfigurationException.php
new file mode 100644 (file)
index 0000000..60dfa57
--- /dev/null
@@ -0,0 +1,8 @@
+<?php
+namespace PayPal\Exception;
+class PPConfigurationException extends \Exception {
+
+       public function __construct($message=null,$code=0) {
+               parent::__construct($message, $code);
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Exception/PPConnectionException.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Exception/PPConnectionException.php
new file mode 100644 (file)
index 0000000..d0a0bf3
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+namespace PayPal\Exception;
+class PPConnectionException extends \Exception
+{
+       /**
+        * The url that was being connected to when the exception occured
+        * @var string
+        */
+       private $url;
+       
+       /**
+        * Any response data that was returned by the server
+        * @var string
+        */
+       private $data;
+
+       public function __construct($url, $message, $code = 0) {                
+               parent::__construct($message, $code);
+               $this->url = $url;              
+       }
+       
+       public function setData($data) {
+               $this->data = $data;
+       }
+       
+       public function getData() {
+               return $this->data;
+       }
+       
+       public function getUrl() {
+               return $this->url;
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Exception/PPInvalidCredentialException.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Exception/PPInvalidCredentialException.php
new file mode 100644 (file)
index 0000000..c492173
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+namespace PayPal\Exception;
+
+class PPInvalidCredentialException extends \Exception{
+
+       public function __construct($message = null, $code = 0) {
+               parent::__construct($message, $code);
+       }
+       
+       public function errorMessage()
+       {
+               $errorMsg = 'Error on line '.$this->getLine().' in '.$this->getFile()
+               .': <b>'.$this->getMessage().'</b>';
+               return $errorMsg;
+       }
+
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Exception/PPMissingCredentialException.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Exception/PPMissingCredentialException.php
new file mode 100644 (file)
index 0000000..a33ae8f
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+namespace PayPal\Exception;
+
+class PPMissingCredentialException extends \Exception{
+
+       public function __construct($message = null, $code = 0) {
+               parent::__construct($message, $code);
+       }
+
+       public function errorMessage()
+       {
+               $errorMsg = 'Error on line '.$this->getLine().' in '.$this->getFile()
+               .': <b>'.$this->getMessage().'</b>';
+
+               return $errorMsg;
+       }
+
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Exception/PPTransformerException.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Exception/PPTransformerException.php
new file mode 100644 (file)
index 0000000..616db00
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+namespace PayPal\Exception;
+class PPTransformerException extends \Exception{
+
+       public function __construct($message = null, $code = 0) {
+               parent::__construct($message, $code);
+       }
+
+       public function errorMessage()
+       {
+               $errorMsg = 'Error on line '.$this->getLine().' in '.$this->getFile()
+               .': <b>'.$this->getMessage().'</b>';
+
+               return $errorMsg;
+       }
+
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Formatter/FormatterFactory.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Formatter/FormatterFactory.php
new file mode 100644 (file)
index 0000000..9c26f46
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+namespace PayPal\Formatter;
+class FormatterFactory {
+       public static function factory($bindingType) {
+               switch ($bindingType) {
+                       case 'NV':
+                               return new PPNVPFormatter();
+                               break;
+                       case 'SOAP':
+                               return new PPSOAPFormatter();
+                               break;
+                       default:
+                               throw new InvalidArgumentException("Invalid value for bindingType. You passed $bindingType");   
+               }
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Formatter/IPPFormatter.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Formatter/IPPFormatter.php
new file mode 100644 (file)
index 0000000..28e19b7
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+namespace PayPal\Formatter;
+/**
+ * Interface for all classes that format objects to
+ * and from a on-wire representation
+ * 
+ * For every new payload format, write a new formatter
+ * class that implements this interface
+ *
+ */
+interface IPPFormatter {
+       
+       /**
+        * 
+        * @param PPRequest $request The request to format
+        * @param array $options Any formatter specific options 
+        *   to be passed in 
+        */
+       public function toString($request, $options=array());
+       
+       public function toObject($string, $options=array());
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Formatter/PPNVPFormatter.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Formatter/PPNVPFormatter.php
new file mode 100644 (file)
index 0000000..6a5a586
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+namespace PayPal\Formatter;
+class PPNVPFormatter implements IPPFormatter {
+       
+       public function toString($request, $options=array()) {          
+               return $request->getRequestObject()->toNVPString();
+       }
+       
+       public function toObject($string, $options=array()) {
+               throw new BadMethodCallException("Unimplemented");
+       }
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Formatter/PPSOAPFormatter.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Formatter/PPSOAPFormatter.php
new file mode 100644 (file)
index 0000000..1c2920b
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+namespace PayPal\Formatter;
+class PPSOAPFormatter implements IPPFormatter {
+       
+       private static $SOAP_NAMESPACE = ' xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" ';
+       
+       public function toString($request, $options=array()) {
+                               
+               $customNamespace = ( $request->getBindingInfo('namespace') != null ) ?  $request->getBindingInfo('namespace') : "";
+               $soapEnvelope = '<soapenv:Envelope ' . self::$SOAP_NAMESPACE . " $customNamespace >";
+
+               $soapHeader = '<soapenv:Header>';
+               if($request->getBindingInfo('securityHeader') != null) {
+                       $soapHeader .= $request->getBindingInfo('securityHeader');
+               }               
+               $soapHeader .= '</soapenv:Header>';
+                               
+               $soapBody = '<soapenv:Body>';
+               $soapBody .= $request->getRequestObject()->toXMLString();
+               $soapBody .= '</soapenv:Body>';
+               
+               return $soapEnvelope . $soapHeader . $soapBody . '</soapenv:Envelope>';
+       }
+       
+       public function toObject($string, $options=array()) {
+               throw new BadMethodCallException("Unimplemented");
+       }       
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/IPPHandler.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/IPPHandler.php
new file mode 100644 (file)
index 0000000..42b4216
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+namespace PayPal\Handler;
+interface IPPHandler {
+       /**
+        * 
+        * @param PPHttpConfig $httpConfig
+        * @param PPRequest $request 
+        */
+       public function handle($httpConfig, $request, $options);
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPAuthenticationHandler.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPAuthenticationHandler.php
new file mode 100644 (file)
index 0000000..427487f
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+namespace PayPal\Handler;
+use PayPal\Auth\PPSignatureCredential;
+use PayPal\Auth\PPCertificateCredential;
+use PayPal\Auth\PPTokenAuthorization;
+use PayPal\Auth\Oauth\AuthSignature;
+use PayPal\Handler\IPPHandler;
+use PayPal\Handler\PPSignatureAuthHandler;
+use PayPal\Handler\PPCertificateAuthHandler;
+use PayPal\Exception\PPInvalidCredentialException;
+
+
+class PPAuthenticationHandler implements IPPHandler {  
+       
+       public function handle($httpConfig, $request, $options) {
+               $credential = $request->getCredential();
+               if(isset($credential)) {
+                       $thirdPartyAuth = $credential->getThirdPartyAuthorization();
+                       if($thirdPartyAuth && $thirdPartyAuth instanceof PPTokenAuthorization) {
+                               $authSignature = AuthSignature::generateFullAuthString($credential->getUsername(), $credential->getPassword(), $thirdPartyAuth->getAccessToken(), $thirdPartyAuth->getTokenSecret(), $httpConfig->getMethod(), $httpConfig->getUrl());
+                               if($options['port'] == 'PayPalAPI' || $options['port'] == 'PayPalAPIAA') {
+                                       $httpConfig->addHeader('X-PP-AUTHORIZATION', $authSignature);
+                               }
+                               else {
+                                       $httpConfig->addHeader('X-PAYPAL-AUTHORIZATION', $authSignature);
+                               }
+                       }
+                       if($credential instanceof PPSignatureCredential) {
+                               $handler = new PPSignatureAuthHandler($credential);
+                       } else if($credential instanceof PPCertificateCredential) {
+                               $handler = new PPCertificateAuthHandler($credential);
+                       } else {
+                               throw new PPInvalidCredentialException();
+                       }
+                       $handler->handle($httpConfig, $request, $options);
+               }
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPCertificateAuthHandler.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPCertificateAuthHandler.php
new file mode 100644 (file)
index 0000000..4b24cba
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+namespace PayPal\Handler;
+use PayPal\Auth\PPTokenAuthorization;
+use PayPal\Auth\PPSubjectAuthorization;
+use PayPal\Auth\Oauth\AuthSignature;
+use PayPal\Handler\IPPHandler;
+class PPCertificateAuthHandler implements IPPHandler {
+
+       public function handle($httpConfig, $request, $options) {
+
+               $credential = $request->getCredential();
+               if(!isset($credential)) {
+                       return;
+               }
+               
+               $httpConfig->setSSLCert($credential->getCertificatePath(), $credential->getCertificatePassPhrase());
+               $thirdPartyAuth = $credential->getThirdPartyAuthorization();
+       
+               switch($request->getBindingType()) {
+                       case 'NV':
+                               if(!$thirdPartyAuth || !$thirdPartyAuth instanceof PPTokenAuthorization) {
+                                       $httpConfig->addHeader('X-PAYPAL-SECURITY-USERID', $credential->getUserName());
+                                       $httpConfig->addHeader('X-PAYPAL-SECURITY-PASSWORD', $credential->getPassword());                                       
+                                       if($thirdPartyAuth) {
+                                               $httpConfig->addHeader('X-PAYPAL-SECURITY-SUBJECT', $thirdPartyAuth->getSubject());
+                                       }
+                               }
+                               break;
+                       case 'SOAP':
+                               if($thirdPartyAuth && $thirdPartyAuth instanceof PPTokenAuthorization) {
+                                       $securityHeader = '<ns:RequesterCredentials/>';
+                               } else {
+                                       $securityHeader = '<ns:RequesterCredentials><ebl:Credentials>';
+                                       $securityHeader .= '<ebl:Username>' . $credential->getUserName() . '</ebl:Username>';
+                                       $securityHeader .= '<ebl:Password>' . $credential->getPassword() . '</ebl:Password>';                                   
+                                       if($thirdPartyAuth && $thirdPartyAuth instanceof PPSubjectAuthorization) {
+                                               $securityHeader .= '<ebl:Subject>' . $thirdPartyAuth->getSubject() . '</ebl:Subject>';
+                                       }
+                                       $securityHeader .= '</ebl:Credentials></ns:RequesterCredentials>';
+                                       $request->addBindingInfo('securityHeader' , $securityHeader);
+                               }
+                               break;  
+               }                               
+       }
+
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPGenericServiceHandler.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPGenericServiceHandler.php
new file mode 100644 (file)
index 0000000..51c1e0e
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+namespace PayPal\Handler;
+use PayPal\Handler\IPPHandler;
+use PayPal\Core\PPUtils;
+use PayPal\Core\PPBaseService;
+class PPGenericServiceHandler implements IPPHandler {
+
+       public function handle($httpConfig, $request, $options) {
+               $httpConfig->addHeader('X-PAYPAL-REQUEST-DATA-FORMAT', $request->getBindingType());
+               $httpConfig->addHeader('X-PAYPAL-RESPONSE-DATA-FORMAT', $request->getBindingType());
+               $httpConfig->addHeader('X-PAYPAL-DEVICE-IPADDRESS', PPUtils::getLocalIPAddress());
+               $httpConfig->addHeader('X-PAYPAL-REQUEST-SOURCE', PPBaseService::getRequestSource());
+                       if(isset($options['config']['service.SandboxEmailAddress']))
+                       {
+                               $httpConfig->addHeader('X-PAYPAL-SANDBOX-EMAIL-ADDRESS', $options['config']['service.SandboxEmailAddress']);
+                       }
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPMerchantServiceHandler.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPMerchantServiceHandler.php
new file mode 100644 (file)
index 0000000..8f56366
--- /dev/null
@@ -0,0 +1,64 @@
+<?php
+namespace PayPal\Handler;
+use PayPal\Exception\PPConfigurationException;
+use PayPal\Auth\PPSignatureCredential;
+use PayPal\Auth\PPCertificateCredential;
+use PayPal\Core\PPConstants;
+class PPMerchantServiceHandler extends PPGenericServiceHandler {
+       private $endpoint;
+       private $config;
+       public function handle($httpConfig, $request, $options) {
+               parent::handle($httpConfig, $request, $options);
+               $this->config = $options['config'];
+               $credential = $request->getCredential();
+               if($options['port'] != null && isset($this->config['service.EndPoint.'.$options['port']]))
+               {
+                       $this->endpoint = $this->config['service.EndPoint.'.$options['port']];
+               }
+               // for backward compatibilty (for those who are using old config files with 'service.EndPoint')
+               else if (isset($this->config['service.EndPoint']))
+               {
+                       $this->endpoint = $this->config['service.EndPoint'];
+               }
+               else if (isset($this->config['mode']))
+               {
+                       if(strtoupper($this->config['mode']) == 'SANDBOX')
+                       {
+                               if($credential instanceof PPSignatureCredential)
+                               {
+                                       $this->endpoint = PPConstants::MERCHANT_SANDBOX_SIGNATURE_ENDPOINT;
+                               }
+                               else if($credential instanceof PPCertificateCredential)
+                               {
+                                       $this->endpoint = PPConstants::MERCHANT_SANDBOX_CERT_ENDPOINT;
+                               }
+                       }
+                       else if(strtoupper($this->config['mode']) == 'LIVE')
+                       {
+                       if($credential instanceof PPSignatureCredential)
+                               {
+                                       $this->endpoint = PPConstants::MERCHANT_LIVE_SIGNATURE_ENDPOINT;
+                               }
+                               else if($credential instanceof PPCertificateCredential)
+                               {
+                                       $this->endpoint = PPConstants::MERCHANT_LIVE_CERT_ENDPOINT;
+                               }
+                       }
+               }
+               else
+               {
+                       throw new PPConfigurationException('endpoint Not Set');
+               }
+               
+               if($options['serviceBinding'] == 'SOAP' )
+               {
+                       $httpConfig->setUrl($this->endpoint);
+               }
+               else 
+               {
+                       throw new PPConfigurationException('expecting service binding to be SOAP');
+               }
+               
+               $request->addBindingInfo("namespace", "xmlns:ns=\"urn:ebay:api:PayPalAPI\" xmlns:ebl=\"urn:ebay:apis:eBLBaseComponents\" xmlns:cc=\"urn:ebay:apis:CoreComponentTypes\" xmlns:ed=\"urn:ebay:apis:EnhancedDataTypes\"");
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPOpenIdHandler.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPOpenIdHandler.php
new file mode 100644 (file)
index 0000000..b66ec5e
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+namespace PayPal\Handler;
+use PayPal\Exception\PPConfigurationException;
+use PayPal\Core\PPConstants;
+class PPOpenIdHandler implements IPPHandler {
+       
+       private $apiContext;
+       
+       private static $sdkName = "openid-sdk-php";     
+       private static $sdkVersion = "1.4.0";
+       
+       public function __construct($apiContext) {
+               $this->apiContext = $apiContext;
+       }
+
+       public function handle($httpConfig, $request, $options) {
+
+               $config = $this->apiContext->getConfig();
+               $httpConfig->setUrl(
+                       rtrim(trim($this->_getEndpoint($config)), '/') . 
+                               (isset($options['path']) ? $options['path'] : '')
+               );
+               
+               if(!array_key_exists("Authorization", $httpConfig->getHeaders())) {                     
+                       $auth = base64_encode($config['acct1.ClientId'] . ':' . $config['acct1.ClientSecret']);
+                       $httpConfig->addHeader("Authorization", "Basic $auth");
+               }
+               if(!array_key_exists("User-Agent", $httpConfig->getHeaders())) {
+                       $httpConfig->addHeader("User-Agent", PPUserAgent::getValue(self::$sdkName, self::$sdkVersion));
+               }
+       }
+       
+       private function _getEndpoint($config) {
+               if (isset($config['openid.EndPoint'])) {
+                       return $config['openid.EndPoint'];
+               } else if (isset($config['service.EndPoint'])) {
+                       return $config['service.EndPoint'];
+               } else if (isset($config['mode'])) {
+                       switch (strtoupper($config['mode'])) {
+                               case 'SANDBOX':
+                                       return PPConstants::REST_SANDBOX_ENDPOINT;
+                               case 'LIVE':
+                                       return PPConstants::REST_LIVE_ENDPOINT;
+                               default:
+                                       throw new PPConfigurationException('The mode config parameter must be set to either sandbox/live');
+                       }
+               } else {
+                       throw new PPConfigurationException('You must set one of service.endpoint or mode parameters in your configuration');
+               }
+       }
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPPlatformServiceHandler.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPPlatformServiceHandler.php
new file mode 100644 (file)
index 0000000..7b3c50e
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+namespace PayPal\Handler;
+use PayPal\Core\PPConstants;
+use PayPal\Handler\PPGenericServiceHandler;
+use PayPal\Exception\PPConfigurationException;
+
+
+class PPPlatformServiceHandler extends PPGenericServiceHandler {
+       private $endpoint;
+       private $config;
+       public function handle($httpConfig, $request, $options) {
+               parent::handle($httpConfig, $request, $options);
+               $this->config = $options['config'];
+               $credential = $request->getCredential();
+               //TODO: Assuming existence of getApplicationId
+               if($credential && $credential->getApplicationId() != NULL) {
+                       $httpConfig->addHeader('X-PAYPAL-APPLICATION-ID', $credential->getApplicationId());
+               }
+               if($options['port'] != null && isset($this->config['service.EndPoint.'.$options['port']]))
+               {
+                       $endpnt = 'service.EndPoint.'.$options['port']; 
+                       $this->endpoint = $this->config[$endpnt];
+               }
+               // for backward compatibilty (for those who are using old config files with 'service.EndPoint')
+               else if (isset($this->config['service.EndPoint']))
+               {
+                       $this->endpoint = $this->config['service.EndPoint'];
+               }
+               else if (isset($this->config['mode']))
+               {
+                       if(strtoupper($this->config['mode']) == 'SANDBOX')
+                       {
+                               $this->endpoint = PPConstants::PLATFORM_SANDBOX_ENDPOINT;
+                       }
+                       else if(strtoupper($this->config['mode']) == 'LIVE')
+                       {
+                               $this->endpoint = PPConstants::PLATFORM_LIVE_ENDPOINT;
+                       }
+               }
+               else
+               {
+                       throw new PPConfigurationException('endpoint Not Set');
+               }
+               $httpConfig->setUrl($this->endpoint . $options['serviceName'] . '/' .  $options['apiMethod']);
+       
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPSignatureAuthHandler.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPSignatureAuthHandler.php
new file mode 100644 (file)
index 0000000..428d5e4
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+namespace PayPal\Handler;
+use PayPal\Auth\PPTokenAuthorization;
+use PayPal\Auth\PPSubjectAuthorization;
+use PayPal\Auth\Oauth\AuthSignature;
+use PayPal\Core\PPConstants;
+use PayPal\Handler\IPPHandler;
+
+class PPSignatureAuthHandler implements IPPHandler {
+               
+       public function handle($httpConfig, $request, $options) {
+               
+               $credential = $request->getCredential();
+               if(!isset($credential)) {
+                       return;
+               }               
+               $thirdPartyAuth = $credential->getThirdPartyAuthorization();
+
+               switch($request->getBindingType()) {
+                       case 'NV':
+                               if(!$thirdPartyAuth || !$thirdPartyAuth instanceof PPTokenAuthorization) {
+                                       $httpConfig->addHeader('X-PAYPAL-SECURITY-USERID', $credential->getUserName());
+                                       $httpConfig->addHeader('X-PAYPAL-SECURITY-PASSWORD', $credential->getPassword());
+                                       $httpConfig->addHeader('X-PAYPAL-SECURITY-SIGNATURE', $credential->getSignature());
+                                       if($thirdPartyAuth) {
+                                               $httpConfig->addHeader('X-PAYPAL-SECURITY-SUBJECT', $thirdPartyAuth->getSubject());
+                                       }
+                               }
+                               break;
+                       case 'SOAP':
+                               if($thirdPartyAuth && $thirdPartyAuth instanceof PPTokenAuthorization) {
+                                       $request->addBindingInfo('securityHeader' , '<ns:RequesterCredentials/>');
+                               } else {
+                                       $securityHeader = '<ns:RequesterCredentials><ebl:Credentials>';
+                                       $securityHeader .= '<ebl:Username>' . $credential->getUserName() . '</ebl:Username>';
+                                       $securityHeader .= '<ebl:Password>' . $credential->getPassword() . '</ebl:Password>';
+                                       $securityHeader .= '<ebl:Signature>' . $credential->getSignature() . '</ebl:Signature>';                                        
+                                       if($thirdPartyAuth && $thirdPartyAuth instanceof PPSubjectAuthorization) {
+                                               $securityHeader .= '<ebl:Subject>' . $thirdPartyAuth->getSubject() . '</ebl:Subject>';
+                                       }
+                                       $securityHeader .= '</ebl:Credentials></ns:RequesterCredentials>';
+                                       $request->addBindingInfo('securityHeader' , $securityHeader);                                   
+                               }
+                               break;
+               }
+       }
+       
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/IPN/PPIPNMessage.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/IPN/PPIPNMessage.php
new file mode 100644 (file)
index 0000000..ffb2383
--- /dev/null
@@ -0,0 +1,172 @@
+<?php
+namespace PayPal\IPN;
+use PayPal\Core\PPHttpConfig;
+use PayPal\Exception\PPConfigurationException;
+use PayPal\Core\PPConfigManager;
+use PayPal\Core\PPConstants;
+use PayPal\Core\PPConnectionManager;
+/**
+ *
+ *
+ */
+class PPIPNMessage {
+
+       const IPN_CMD = 'cmd=_notify-validate';
+
+       /*
+        *@var boolian
+       *
+       */
+       private $isIpnVerified;
+
+       /*
+        *@var config
+       *
+       */
+       private $config;
+       /**
+        *
+        * @var array
+        */
+       private $ipnData = array();
+
+       /**
+        *
+        * @param string $postData OPTIONAL post data. If null,
+        *                              the class automatically reads incoming POST data
+        *                              from the input stream
+       */
+       public function __construct($postData='', $config = null) {
+               if($config == null)
+               {
+                       $conf = PPConfigManager::getInstance();
+                       $this->config = $conf->config;
+               }
+               else
+               {
+                       $this->config = $config;
+               }
+               if($postData == '') {
+                       // reading posted data from directly from $_POST may causes serialization issues with array data in POST
+                       // reading raw POST data from input stream instead.
+                       $postData = file_get_contents('php://input');
+               }
+
+               $rawPostArray = explode('&', $postData);
+               foreach ($rawPostArray as $keyValue) {
+                       $keyValue = explode ('=', $keyValue);
+                       if (count($keyValue) == 2)
+                               $this->ipnData[$keyValue[0]] = urldecode($keyValue[1]);
+               }
+               //var_dump($this->ipnData);
+       }
+
+       /**
+        * Returns a hashmap of raw IPN data
+        *
+        * @return array
+        */
+       public function getRawData() {
+               return $this->ipnData;
+       }
+
+       /**
+        * Validates a IPN message
+        *
+        * @return boolean
+        */
+       public function validate() {
+               if(isset($this->isIpnVerified))
+               {
+                       return $this->isIpnVerified;
+               }
+               else
+               {
+                       $request = self::IPN_CMD;
+                       if(function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() == 1) {
+                               $get_magic_quotes_exists = true;
+                       } else {
+                               $get_magic_quotes_exists = false;
+                       }
+                       foreach ($this->ipnData as $key => $value) {
+                               if($get_magic_quotes_exists) {
+                                       $value = urlencode(stripslashes($value));
+                               } else {
+                                       $value = urlencode($value);
+                               }
+                               $request .= "&$key=$value";
+                       }
+                               
+                       $httpConfig = new PPHttpConfig($this->setEndpoint());
+                       $httpConfig->addCurlOption(CURLOPT_FORBID_REUSE, 1);
+                       $httpConfig->addCurlOption(CURLOPT_HTTPHEADER, array('Connection: Close'));
+
+                       $connection = PPConnectionManager::getInstance()->getConnection($httpConfig, $this->config);
+                       $response = $connection->execute($request);
+                       if($response == 'VERIFIED') {
+                               $this->isIpnVerified = true;
+                               return true;
+                       }
+                       $this->isIpnVerified = false;
+                       return false; // value is 'INVALID'
+               }
+       }
+
+       /**
+        * Returns the transaction id for which
+        * this IPN was generated, if one is available
+        *
+        * @return string
+        */
+       public function getTransactionId() {
+               if(isset($this->ipnData['txn_id'])) {
+                       return $this->ipnData['txn_id'];
+               } else if(isset($this->ipnData['transaction[0].id'])) {
+                       $idx = 0;
+                       do {
+                               $transId[] =  $this->ipnData["transaction[$idx].id"];
+                               $idx++;
+                       } while(isset($this->ipnData["transaction[$idx].id"]));
+                       return $transId;
+               }
+       }
+
+       /**
+        * Returns the transaction type for which
+        * this IPN was generated
+        *
+        * @return string
+        */
+       public function getTransactionType() {
+               return $this->ipnData['transaction_type'];
+       }
+       
+       private function setEndpoint()
+       {
+               if(isset($this->config['service.EndPoint.IPN']))
+               {
+                       $url = $this->config['service.EndPoint.IPN'];
+               }
+               else if(isset($this->config['mode']))
+               {
+                       if(strtoupper($this->config['mode']) == 'SANDBOX')
+                       {
+                               $url = PPConstants::IPN_SANDBOX_ENDPOINT;
+                       }
+                       else if (strtoupper($this->config['mode']) == 'LIVE')
+                       {
+                               $url = PPConstants::IPN_LIVE_ENDPOINT;
+                       }
+                       else
+                       {
+                               throw new PPConfigurationException('mode should be LIVE or SANDBOX');
+                       }
+               }
+               else
+               {
+                       throw new PPConfigurationException('No COnfig file found');
+               }
+               return $url;
+       }
+
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Transport/PPRestCall.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Transport/PPRestCall.php
new file mode 100644 (file)
index 0000000..cb8910e
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+namespace PayPal\Transport;
+use PayPal\Core\PPLoggingManager;
+use PayPal\Core\PPHttpConfig;
+use PayPal\Core\PPHttpConnection;
+class PPRestCall {
+
+       
+       /**
+        * 
+        * @var PPLoggingManager logger interface
+        */
+       private $logger;
+       
+       private $apiContext;
+
+       public function __construct($apiContext) {
+               $this->apiContext = $apiContext;
+               $this->logger = new PPLoggingManager(__CLASS__, $apiContext->getConfig());
+       }
+
+       /**
+        * @param array $handlers array of handlers
+        * @param string $path   Resource path relative to base service endpoint
+        * @param string $method HTTP method - one of GET, POST, PUT, DELETE, PATCH etc
+        * @param string $data   Request payload
+        * @param array $headers HTTP headers
+        */
+       public function execute($handlers, $path, $method, $data='', $headers=array()) {
+
+               $config = $this->apiContext->getConfig();               
+               $httpConfig = new PPHttpConfig(null, $method);
+               $httpConfig->setHeaders($headers + 
+                       array(
+                               'Content-Type' => 'application/json'
+                       )       
+               );
+               
+               foreach($handlers as $handler) {
+                       $handler = new $handler($this->apiContext);
+                       $handler->handle($httpConfig, $data, array('path' => $path));
+               }
+               $connection = new PPHttpConnection($httpConfig, $config);
+               $response = $connection->execute($data);
+               $this->logger->fine($response);
+               
+               return $response;
+       }
+       
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/Openid/PPOpenIdAddressTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/Openid/PPOpenIdAddressTest.php
new file mode 100644 (file)
index 0000000..87475c4
--- /dev/null
@@ -0,0 +1,39 @@
+<?php 
+use PayPal\Auth\Openid\PPOpenIdAddress;
+/**
+ * Test class for PPOpenIdAddress.
+ *
+ */
+class PPOpenIdAddressTest extends \PHPUnit_Framework_TestCase {
+       
+       public $addr;
+
+       /**
+        * Sets up the fixture, for example, opens a network connection.
+        * This method is called before a test is executed.
+        */
+       protected function setUp() {
+               $this->addr = new PPOpenIdAddress();
+               $this->addr->setCountry("US")->setLocality("San Jose")
+               ->setPostalCode("95112")->setRegion("CA")
+               ->setStreetAddress("1, North 1'st street");
+       }
+       
+       /**
+        * Tears down the fixture, for example, closes a network connection.
+        * This method is called after a test is executed.
+        */
+       protected function tearDown()
+       {
+       }
+       
+       /**
+        * @test
+        */
+       public function testSerializationDeserialization() {                            
+               $addrCopy = new PPOpenIdAddress();
+               $addrCopy->fromJson($this->addr->toJson());
+               
+               $this->assertEquals($this->addr, $addrCopy);
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/Openid/PPOpenIdSessionTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/Openid/PPOpenIdSessionTest.php
new file mode 100644 (file)
index 0000000..46e84d1
--- /dev/null
@@ -0,0 +1,84 @@
+<?php
+use PayPal\Common\PPApiContext;
+use PayPal\Auth\Openid\PPOpenIdSession;
+/**
+ * Test class for PPOpenIdSession.
+ *
+ */
+class PPOpenIdSessionTest extends \PHPUnit_Framework_TestCase {
+       
+       private $context;
+       /**
+        * Sets up the fixture, for example, opens a network connection.
+        * This method is called before a test is executed.
+        */
+       protected function setUp()
+       {
+               $this->context = new PPApiContext(
+                       array(
+                               'acct1.ClientId' => 'DummyId',
+                               'acct1.ClientSecret' => 'A8VERY8SECRET8VALUE0',
+                               'mode' => 'live'
+                       )
+               );
+       }
+       
+       /**
+        * Tears down the fixture, for example, closes a network connection.
+        * This method is called after a test is executed.
+        */
+       protected function tearDown()
+       {
+       }
+       
+
+       /**
+        * @test
+        */
+       public function testLoginUrlForMultipleScopes() {
+       
+               $redirectUri = 'http://mywebsite.com';
+               $scope = array('this', 'that', 'and more');
+       
+               $expectedBaseUrl = "https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize";
+       
+               $this->assertEquals($expectedBaseUrl . "?client_id=ProxyRP-01&response_type=code&scope=this+that+and+more+openid&redirect_uri=" . urlencode($redirectUri),
+                               PPOpenIdSession::getAuthorizationUrl($redirectUri, $scope), "Failed case - custom scope");
+       
+               $scope = array();
+               $this->assertEquals($expectedBaseUrl . "?client_id=ProxyRP-01&response_type=code&scope=openid+profile+address+email+phone+" . urlencode("https://uri.paypal.com/services/paypalattributes") . "&redirect_uri=" . urlencode($redirectUri),
+                               PPOpenIdSession::getAuthorizationUrl($redirectUri, $scope), "Failed case - default scope");
+       
+               $scope = array('openid');
+               $this->assertEquals($expectedBaseUrl . "?client_id=ProxyRP-01&response_type=code&scope=openid&redirect_uri=" . urlencode($redirectUri),
+                               PPOpenIdSession::getAuthorizationUrl($redirectUri, $scope), "Failed case - openid scope");
+       }
+       
+       /**
+        * @test
+        */
+       public function testLoginWithCustomConfig() {
+       
+               $redirectUri = 'http://mywebsite.com';
+               $scope = array('this', 'that', 'and more');
+       
+               $expectedBaseUrl = "https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize";
+                       
+               $this->assertEquals($expectedBaseUrl . "?client_id=DummyId&response_type=code&scope=this+that+and+more+openid&redirect_uri=" . urlencode($redirectUri),
+                               PPOpenIdSession::getAuthorizationUrl($redirectUri, $scope, $this->context), "Failed case - custom config");
+       }
+       
+       /**
+        * @test
+        */
+       public function testLogoutWithCustomConfig() {
+               
+               $redirectUri = 'http://mywebsite.com';
+               $idToken = 'abc';
+               
+               $expectedBaseUrl = "https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/endsession";
+                       
+               $this->assertEquals($expectedBaseUrl . "?id_token=$idToken&redirect_uri=" . urlencode($redirectUri) . "&logout=true",
+                               PPOpenIdSession::getLogoutUrl($redirectUri, $idToken, $this->context), "Failed case - custom config");
+       }
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/Openid/PPOpenIdTokeninfoTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/Openid/PPOpenIdTokeninfoTest.php
new file mode 100644 (file)
index 0000000..999145d
--- /dev/null
@@ -0,0 +1,41 @@
+<?php 
+use PayPal\Auth\Openid\PPOpenIdTokeninfo;
+/**
+ * Test class for PPOpenIdTokeninfo.
+ *
+ */
+class PPOpenIdTokeninfoTest extends \PHPUnit_Framework_TestCase {
+       
+       public $token;
+
+       /**
+        * Sets up the fixture, for example, opens a network connection.
+        * This method is called before a test is executed.
+        */
+       protected function setUp() {
+               $this->token = new PPOpenIdTokeninfo();
+               $this->token->setAccessToken("Access token")
+                                       ->setExpiresIn(900)
+                                       ->setRefreshToken("Refresh token")
+                                       ->setScope("openid address")
+                                       ->setTokenType("Bearer");
+       }
+       
+       /**
+        * Tears down the fixture, for example, closes a network connection.
+        * This method is called after a test is executed.
+        */
+       protected function tearDown()
+       {
+       }
+       
+       /**
+        * @test
+        */
+       public function testSerializationDeserialization() {                            
+               $tokenCopy = new PPOpenIdTokeninfo();
+               $tokenCopy->fromJson($this->token->toJson());
+               
+               $this->assertEquals($this->token, $tokenCopy);
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/Openid/PPOpenIdUserinfoTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/Openid/PPOpenIdUserinfoTest.php
new file mode 100644 (file)
index 0000000..330d843
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+use PayPal\Auth\Openid\PPOpenIdUserinfo;
+/**
+ * Test class for PPOpenIdUserinfo.
+ *
+ */
+class PPOpenIdUserinfoTest extends \PHPUnit_Framework_TestCase {
+       
+
+       /**
+        * Sets up the fixture, for example, opens a network connection.
+        * This method is called before a test is executed.
+        */
+       protected function setUp()
+       {
+       }
+       
+       /**
+        * Tears down the fixture, for example, closes a network connection.
+        * This method is called after a test is executed.
+        */
+       protected function tearDown()
+       {
+       }
+       
+
+       /**
+        * @test
+        */
+       public function testSerializationDeserialization() {
+               $user = new PPOpenIdUserinfo();
+               $user->setAccountType("PERSONAL")->setAgeRange("20-30")->setBirthday("1970-01-01")
+                       ->setEmail("me@email.com")->setEmailVerified(true)
+                       ->setFamilyName("Doe")->setMiddleName("A")->setGivenName("John")
+                       ->setLocale("en-US")->setGender("male")->setName("John A Doe")
+                       ->setPayerId("A-XZASASA")->setPhoneNumber("1-408-111-1111")
+                       ->setPicture("http://gravatar.com/me.jpg")
+                       ->setSub("me@email.com")->setUserId("userId")
+                       ->setVerifiedAccount(true)->setZoneinfo("America/PST");
+               
+               $userCopy = new PPOpenIdUserinfo();
+               $userCopy->fromJson($user->toJSON());
+               
+               $this->assertEquals($user, $userCopy);
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPAPIServiceTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPAPIServiceTest.php
new file mode 100644 (file)
index 0000000..4d7cca9
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+use PayPal\Core\PPAPIService;
+/**
+ * Test class for PPAPIService.
+ *
+ */
+class PPAPIServiceTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var PPAPIService
+     */
+    protected $object;
+    
+    private $config = array(
+               'acct1.UserName' => 'jb-us-seller_api1.paypal.com'      ,
+               'acct1.Password' => 'WX4WTU3S8MY44S7F'  ,
+               'acct1.Signature' =>    'AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy'      ,
+               'acct1.AppId' =>        'APP-80W284485P519543T' ,
+               'acct2.UserName' =>     'certuser_biz_api1.paypal.com'  ,
+               'acct2.Password' =>     'D6JNKKULHN3G5B8A'      ,
+               'acct2.CertPath' =>     'cert_key.pem'  ,
+               'acct2.AppId' =>        'APP-80W284485P519543T' ,
+               'http.ConnectionTimeOut' =>     '30'    ,
+               'http.Retry' =>         '5'     ,
+               'service.RedirectURL' =>        'https://www.sandbox.paypal.com/webscr&cmd='    ,
+               'service.DevCentralURL' => 'https://developer.paypal.com'       ,
+               'service.EndPoint.IPN' => 'https://www.sandbox.paypal.com/cgi-bin/webscr'       ,
+               'service.EndPoint.AdaptivePayments' => 'https://svcs.sandbox.paypal.com/'       ,
+               'service.SandboxEmailAddress' => 'platform_sdk_seller@gmail.com',
+               'log.FileName' => 'PayPal1.log' ,
+               'log.LogLevel' =>       'INFO'  ,
+               'log.LogEnabled' =>     '1'     ,
+    
+    
+    );
+
+    /**
+     * Sets up the fixture, for example, opens a network connection.
+     * This method is called before a test is executed.
+     */
+    protected function setUp()
+    {
+        $this->object = new PPAPIService(null,'AdaptiveAccounts', 'SOAP', null, $this->config);
+    }
+
+    /**
+     * Tears down the fixture, for example, closes a network connection.
+     * This method is called after a test is executed.
+     */
+    protected function tearDown()
+    {
+    }
+
+    /**
+     * @test
+     */
+    public function testSetServiceName()
+    {  
+       $this->assertEquals('AdaptiveAccounts',$this->object->serviceName);
+       $this->object->setServiceName('Invoice');
+        $this->assertEquals('Invoice',$this->object->serviceName);
+    }
+
+    /**
+     * @test
+     */
+    public function testMakeRequest()
+    {
+
+    }
+}
+?>
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPBaseServiceTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPBaseServiceTest.php
new file mode 100644 (file)
index 0000000..0b2b592
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+use PayPal\Core\PPBaseService;
+/**
+ * Test class for PPBaseService.
+ *
+ */
+class PPBaseServiceTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var PPBaseService
+     */
+    protected $object;
+
+    /**
+     * Sets up the fixture, for example, opens a network connection.
+     * This method is called before a test is executed.
+     */
+    protected function setUp()
+    {
+        $this->object = new PPBaseService('serviceName', 'serviceBinding', null);
+    }
+
+    /**
+     * Tears down the fixture, for example, closes a network connection.
+     * This method is called after a test is executed.
+     */
+    protected function tearDown()
+    {
+    }
+
+    /**
+     * @test
+     */
+    public function testGetServiceName()
+    {
+        $this->assertEquals('serviceName',$this->object->getServiceName() );
+    }
+
+
+}
+?>
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPBootStrap.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPBootStrap.php
new file mode 100644 (file)
index 0000000..dd5d70f
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+/**
+ * Please run composer update from the root folder to run test cases
+ */
+
+if(file_exists(dirname(__FILE__) . '/../PPBootstrap.php')) {
+    require dirname(__FILE__) . '/../PPBootstrap.php';
+} else if(file_exists(dirname(__FILE__) . '/../vendor/autoload.php')) {
+       define('PP_CONFIG_PATH', dirname(__FILE__));
+    require dirname(__FILE__) . '/../vendor/autoload.php';
+}
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPCertificateCredentialTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPCertificateCredentialTest.php
new file mode 100644 (file)
index 0000000..6716e40
--- /dev/null
@@ -0,0 +1,106 @@
+<?php
+use PayPal\Auth\PPCertificateCredential;
+use PayPal\Exception\PPMissingCredentialException;
+/**
+ * Test class for PPCertificateCredential.
+ *
+ */
+class PPCertificateCredentialTest extends \PHPUnit_Framework_TestCase
+{
+       /**
+        * @var PPCertificateCredential
+        */
+       protected $credential;
+
+       /**
+        * Sets up the fixture, for example, opens a network connection.
+        * This method is called before a test is executed.
+        */
+       protected function setUp()
+       {
+               $this->credential = new PPCertificateCredential("platfo_1255077030_biz_api1.gmail.com", "1255077037", "cacert.pem");
+               $this->credential->setApplicationId('APP-80W284485P519543T');
+       }
+
+       /**
+        * Tears down the fixture, for example, closes a network connection.
+        * This method is called after a test is executed.
+        */
+       protected function tearDown()
+       {
+       }
+
+       /**@test
+        */
+       public function testValidateUname()
+       {
+               $this->setExpectedException('PayPal\Exception\PPMissingCredentialException');
+               $credUname = new PPCertificateCredential("", "1255077037", "cacert.pem");
+               $credUname->validate();
+               $setNotExpectedException('PPMissingCredentialException');
+               $credCorrect = new PPCertificateCredential("platfo_1255077030_biz_api1.gmail.com", "1255077037", "cacert.pem");
+               $var = $credCorrect->validate();
+               $this->assertNull($var);
+       }
+       /**
+        * @test
+        */
+       public function testValidatePwd()
+       {
+               $this->setExpectedException('PayPal\Exception\PPMissingCredentialException');
+               $credpwd = new PPCertificateCredential("platfo_1255077030_biz_api1.gmail.com", "", "cacert.pem");
+               $credpwd->validate();
+
+       }
+       /**
+        * @test
+        */
+       public function testValidateCertPath()
+       {
+               $this->setExpectedException('PayPal\Exception\PPMissingCredentialException');
+               $credCertPath = new PPCertificateCredential("platfo_1255077030_biz_api1.gmail.com", "1255077037", "");
+               $credCertPath->validate();
+       }
+       /**
+        * @test
+        */
+       public function testGetAppId()
+       {
+               $credAppid = new PPCertificateCredential("platfo_1255077030_biz_api1.gmail.com", "1255077037", "cacert.pem");
+               $credAppid->setApplicationId("APP-ID");
+               $this->assertEquals($credAppid->getApplicationId(), "APP-ID");
+       }
+
+       /**
+        * @test
+        */
+       public function testGetUserName()
+       {
+               $this->assertEquals('platfo_1255077030_biz_api1.gmail.com', $this->credential->getUserName());
+
+       }
+
+       /**
+        * @test
+        */
+       public function testGetPassword()
+       {
+               $this->assertEquals('1255077037', $this->credential->getPassword());
+       }
+
+       /**
+        * @test
+        */
+       public function testGetCertificatePath()
+       {
+               $this->assertStringEndsWith(dirname(__FILE__). DIRECTORY_SEPARATOR .'cacert.pem', $this->credential->getCertificatePath());
+       }
+
+       /**@test
+        */
+       public function testGetApplicationId()
+       {
+               $this->assertEquals('APP-80W284485P519543T', $this->credential->getApplicationId());
+       }
+}
+?>
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPConfigManagerTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPConfigManagerTest.php
new file mode 100644 (file)
index 0000000..eda5d38
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+use PayPal\Core\PPConfigManager;
+/**
+ * Test class for PPConfigManager.
+ *
+ */
+class PPConfigManagerTest extends \PHPUnit_Framework_TestCase
+{
+       /**
+        * @var PPConfigManager
+        */
+       protected $object;
+
+       /**
+        * Sets up the fixture, for example, opens a network connection.
+        * This method is called before a test is executed.
+        */
+       protected function setUp()
+       {
+               $this->object = PPConfigManager::getInstance();
+       }
+
+       /**
+        * Tears down the fixture, for example, closes a network connection.
+        * This method is called after a test is executed.
+        */
+       protected function tearDown()
+       {
+       }
+
+
+
+       /**
+        * @test
+        */
+       public function testGetInstance()
+       {
+               $instance = $this->object->getInstance();
+               $this->assertTrue($instance instanceof PPConfigManager);
+       }
+
+       /**
+        * @test
+        */
+       public function testGetIniPrefix()
+       {
+               $ret = $this->object->getIniPrefix();
+               $this->assertContains('acct1', $ret);
+               $this->assertEquals(sizeof($ret), 2);
+               
+               $ret = $this->object->getIniPrefix('jb-us-seller_api1.paypal.com');
+               $this->assertEquals('acct1', $ret);
+       }
+}
+?>
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPConfigurationExceptionTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPConfigurationExceptionTest.php
new file mode 100644 (file)
index 0000000..420cd11
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+use PayPal\Exception\PPConfigurationException;
+/**
+ * Test class for PPConfigurationException.
+ *
+ */
+class PPConfigurationExceptionTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var PPConfigurationException
+     */
+    protected $object;
+
+    /**
+     * Sets up the fixture, for example, opens a network connection.
+     * This method is called before a test is executed.
+     */
+    protected function setUp()
+    {
+        $this->object = new PPConfigurationException('Test PPConfigurationException');
+    }
+
+    /**
+     * Tears down the fixture, for example, closes a network connection.
+     * This method is called after a test is executed.
+     */
+    protected function tearDown()
+    {
+    }
+    public function testPPConfigurationException()
+    {
+       $this->setExpectedException('PayPal\Exception\PPConfigurationException');
+       throw new PPConfigurationException('Test PPConfigurationException');
+
+    }
+}
+?>
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPConnectionExceptionTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPConnectionExceptionTest.php
new file mode 100644 (file)
index 0000000..d01550a
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+use PayPal\Exception\PPConnectionException;
+/**
+ * Test class for PPConnectionException.
+ *
+ */
+class PPConnectionExceptionTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var PPConnectionException
+     */
+    protected $object;
+
+    /**
+     * Sets up the fixture, for example, opens a network connection.
+     * This method is called before a test is executed.
+     */
+    protected function setUp()
+    {
+        $this->object = new PPConnectionException('http://testURL', 'test message');
+    }
+
+    /**
+     * Tears down the fixture, for example, closes a network connection.
+     * This method is called after a test is executed.
+     */
+    protected function tearDown()
+    {
+    }
+
+    /**
+     * @test
+     */
+    public function testGetUrl()
+    {
+       $this->assertEquals('http://testURL',$this->object->getUrl());
+    }
+    /**
+     * @test
+     */
+ public function testPPConnectionException()
+    {
+       $this->setExpectedException('PayPal\Exception\PPConnectionException');
+       throw new PPConnectionException('http://testURL','Test msg PPConnectionException');
+       
+    }
+}
+?>
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPConnectionManagerTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPConnectionManagerTest.php
new file mode 100644 (file)
index 0000000..999c464
--- /dev/null
@@ -0,0 +1,76 @@
+<?php
+use PayPal\Core\PPConnectionManager;
+use PayPal\Core\PPHttpConnection;
+use PayPal\Core\PPHttpConfig;
+/**
+ * Test class for PPConnectionManager.
+ *
+ */
+class PPConnectionManagerTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var PPConnectionManager
+     */
+    protected $object;
+    
+    private $config = array(
+               'acct1.UserName' => 'jb-us-seller_api1.paypal.com'      ,
+               'acct1.Password' => 'WX4WTU3S8MY44S7F'  ,
+               'acct1.Signature' =>    'AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy'      ,
+               'acct1.AppId' =>        'APP-80W284485P519543T' ,
+               'acct2.UserName' =>     'certuser_biz_api1.paypal.com'  ,
+               'acct2.Password' =>     'D6JNKKULHN3G5B8A'      ,
+               'acct2.CertPath' =>     'cert_key.pem'  ,
+               'acct2.AppId' =>        'APP-80W284485P519543T' ,
+               'http.ConnectionTimeOut' =>     '30'    ,
+               'http.Retry' =>         '5'     ,
+               'service.RedirectURL' =>        'https://www.sandbox.paypal.com/webscr&cmd='    ,
+               'service.DevCentralURL' => 'https://developer.paypal.com'       ,
+               'service.EndPoint.IPN' => 'https://www.sandbox.paypal.com/cgi-bin/webscr'       ,
+               'service.EndPoint.AdaptivePayments' => 'https://svcs.sandbox.paypal.com/'       ,
+               'service.SandboxEmailAddress' => 'platform_sdk_seller@gmail.com',
+               'log.FileName' => 'PayPal1.log' ,
+               'log.LogLevel' =>       'INFO'  ,
+               'log.LogEnabled' =>     '1'     ,
+    
+    
+    );
+
+    /**
+     * Sets up the fixture, for example, opens a network connection.
+     * This method is called before a test is executed.
+     */
+    protected function setUp()
+    {
+        $this->object =  PPConnectionManager::getInstance();
+    }
+
+    /**
+     * Tears down the fixture, for example, closes a network connection.
+     * This method is called after a test is executed.
+     */
+    protected function tearDown()
+    {
+    }
+
+    /**
+     * @test
+     */
+    public function testGetInstance()
+    {
+        $instance = $this->object->getInstance();
+               $this->assertTrue($instance instanceof PPConnectionManager);
+    }
+
+    /**
+     * @test
+     */
+    public function testGetConnection()
+    {
+        $conn = $this->object->getConnection(new PPHttpConfig("http://domain.com"), $this->config);
+        $this->assertNotNull($conn);
+        $this->assertTrue($conn instanceof PPHttpConnection);
+        $this->assertEquals(get_class($conn), "PayPal\Core\PPHttpConnection");
+    }
+}
+?>
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPCredentialManagerTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPCredentialManagerTest.php
new file mode 100644 (file)
index 0000000..81cf5c8
--- /dev/null
@@ -0,0 +1,104 @@
+<?php
+use PayPal\Core\PPCredentialManager;
+/**
+ * Test class for PPCredentialManager.
+ *
+ */
+class PPCredentialManagerTest extends \PHPUnit_Framework_TestCase
+{
+       /**
+        * @var PPCredentialManager
+        */
+       protected $object;
+
+       private $config = array(
+                       'acct1.UserName' => 'jb-us-seller_api1.paypal.com'      ,
+                       'acct1.Password' => 'WX4WTU3S8MY44S7F'  ,
+                       'acct1.Signature' =>    'AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy'      ,
+                       'acct1.AppId' =>        'APP-80W284485P519543T' ,
+                       'acct2.UserName' =>     'certuser_biz_api1.paypal.com'  ,
+                       'acct2.Password' =>     'D6JNKKULHN3G5B8A'      ,
+                       'acct2.CertPath' =>     'cert_key.pem'  ,
+                       'acct2.AppId' =>        'APP-80W284485P519543T' ,
+                       'http.ConnectionTimeOut' =>     '30'    ,
+                       'http.Retry' =>         '5'     ,
+                       'service.RedirectURL' =>        'https://www.sandbox.paypal.com/webscr&cmd='    ,
+                       'service.DevCentralURL' => 'https://developer.paypal.com'       ,
+                       'service.EndPoint.IPN' => 'https://www.sandbox.paypal.com/cgi-bin/webscr'       ,
+                       'service.EndPoint.AdaptivePayments' => 'https://svcs.sandbox.paypal.com/'       ,
+                       'service.SandboxEmailAddress' => 'platform_sdk_seller@gmail.com',
+                       'log.FileName' => 'PayPal1.log' ,
+                       'log.LogLevel' =>       'INFO'  ,
+                       'log.LogEnabled' =>     '1'     ,
+       
+       
+       );
+       /**
+        * Sets up the fixture, for example, opens a network connection.
+        * This method is called before a test is executed.
+        */
+       protected function setUp()
+       {
+               $this->object = PPCredentialManager::getInstance($this->config);
+       }
+
+       /**
+        * Tears down the fixture, for example, closes a network connection.
+        * This method is called after a test is executed.
+        */
+       protected function tearDown()
+       {
+       }
+
+       /**
+        * @test
+        */
+       public function testGetInstance()
+       {
+               $instance = $this->object->getInstance($this->config);
+               $this->assertTrue($instance instanceof PPCredentialManager);
+       }
+
+       /**
+        * @test
+        */
+       public function testGetSpecificCredentialObject()
+       {
+               $cred = $this->object->getCredentialObject('jb-us-seller_api1.paypal.com');
+               $this->assertNotNull($cred);
+               $this->assertEquals('jb-us-seller_api1.paypal.com', $cred->getUsername());
+               
+               $cred = $this->object->getCredentialObject('certuser_biz_api1.paypal.com');
+               $this->assertNotNull($cred);
+               $this->assertEquals('certuser_biz_api1.paypal.com', $cred->getUsername());
+               $this->assertStringEndsWith('cert_key.pem', $cred->getCertificatePath());               
+       }
+       
+       /**
+        * @test
+        */
+       public function testGetInvalidCredentialObject()
+       {
+               $this->setExpectedException('PayPal\Exception\PPInvalidCredentialException');
+               $cred = $this->object->getCredentialObject('invalid_biz_api1.gmail.com');
+       }
+               
+       /**
+        * @test
+        */
+       public function testGetDefaultCredentialObject()
+       {
+               $cred = $this->object->getCredentialObject();
+               $this->assertEquals('jb-us-seller_api1.paypal.com', $cred->getUsername());
+       }       
+       
+       /**
+        * @test
+        */
+       public function testGetPlatformCredentialObject()
+       {
+               $cred = $this->object->getCredentialObject();
+               $this->assertEquals('APP-80W284485P519543T', $cred->getApplicationId());
+       }       
+}
+?>
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPIPNMessageTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPIPNMessageTest.php
new file mode 100644 (file)
index 0000000..9da5007
--- /dev/null
@@ -0,0 +1,58 @@
+<?php
+use PayPal\IPN\PPIPNMessage;
+/**
+ * Test class for PPIPNMessage.
+ *
+ */
+class PPIPNMessageTest extends \PHPUnit_Framework_TestCase {
+       /**
+        * @test
+        */
+       
+       public function passGoodIPN() {
+               
+       }
+       
+       
+       /**
+        * @test
+        */
+       
+       public function failOnBadIPN() {
+               $ipn = new PPIPNMessage();
+               $this->assertEquals(false, $ipn->validate());
+       }
+       
+       
+       /**
+        * @test
+        */
+       
+       public function processIPNWithArrayElements() {
+               $ipnData = 'transaction[0].id=6WM123443434&transaction[0].status=Completed&transaction[1].id=2F12129812A1&transaction[1].status=Pending';
+               $ipn = new PPIPNMessage($ipnData);
+               
+               $rawData = $ipn->getRawData();
+               $this->assertEquals(4, count($rawData));
+               $this->assertEquals('6WM123443434', $rawData['transaction[0].id']);
+       }
+       
+       /**
+        * @test
+        */     
+       public function processIPNWithSpecialCharacters() {
+               $ipnData = "description=Jake's store";
+               
+               ini_set('get_magic_quotes_gpc', true);
+               $ipn = new PPIPNMessage($ipnData);
+               $rawData = $ipn->getRawData();          
+               $this->assertEquals($rawData['description'], "Jake's store");
+               
+               ini_set('get_magic_quotes_gpc', false);
+               $ipn = new PPIPNMessage($ipnData);
+               $rawData = $ipn->getRawData();
+               $this->assertEquals($rawData['description'], "Jake's store");
+               $this->assertEquals($rawData['description'], "Jake's store");
+       }
+       
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPInvalidCredentialExceptionTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPInvalidCredentialExceptionTest.php
new file mode 100644 (file)
index 0000000..7ed7c5a
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+use PayPal\Exception\PPInvalidCredentialException;
+/**
+ * Test class for PPInvalidCredentialException.
+ *
+ */
+class PPInvalidCredentialExceptionTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var PPInvalidCredentialException
+     */
+    protected $object;
+
+    /**
+     * Sets up the fixture, for example, opens a network connection.
+     * This method is called before a test is executed.
+     */
+    protected function setUp()
+    {
+        $this->object = new PPInvalidCredentialException;
+    }
+
+    /**
+     * Tears down the fixture, for example, closes a network connection.
+     * This method is called after a test is executed.
+     */
+    protected function tearDown()
+    {
+    }
+
+    /**
+     * @test
+     */
+    public function testErrorMessage()
+    {
+      $msg = $this->object->errorMessage();
+      $this->assertContains('Error on line', $msg);
+    }
+}
+?>
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPLoggingManagerTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPLoggingManagerTest.php
new file mode 100644 (file)
index 0000000..5285ed8
--- /dev/null
@@ -0,0 +1,64 @@
+<?php
+use PayPal\Core\PPLoggingManager;
+/**
+ * Test class for PPLoggingManager.
+ *
+ */
+class PPLoggingManagerTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var PPLoggingManager
+     */
+    protected $object;
+
+    /**
+     * Sets up the fixture, for example, opens a network connection.
+     * This method is called before a test is executed.
+     */
+    protected function setUp()
+    {
+        $this->object = new PPLoggingManager('InvoiceTest');
+    }
+
+    /**
+     * Tears down the fixture, for example, closes a network connection.
+     * This method is called after a test is executed.
+     */
+    protected function tearDown()
+    {
+    }
+
+    /**
+     * @test
+     */
+    public function testError()
+    {
+        $this->object->error('Test Error Message');
+
+    }
+
+    /**
+     * @test
+     */
+    public function testWarning()
+    {
+         $this->object->warning('Test Warning Message');
+    }
+
+    /**
+     * @test
+     */
+    public function testInfo()
+    {
+        $this->object->info('Test info Message');
+    }
+
+    /**
+     * @test
+     */
+    public function testFine()
+    {
+       $this->object->fine('Test fine Message');
+    }
+}
+?>
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPMessageTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPMessageTest.php
new file mode 100644 (file)
index 0000000..8f29a7f
--- /dev/null
@@ -0,0 +1,441 @@
+<?php
+use PayPal\Core\PPMessage;
+use PayPal\Core\PPUtils;
+
+class SimpleTestClass extends PPMessage {
+       /**
+        *
+        * @access public
+        * @var string
+        */
+       public $field1;
+       
+       /**
+        *
+        * @access public
+        * @var string
+        */
+       public $field2;
+}
+
+class SimpleContainerTestClass extends PPMessage {
+       
+       /**
+        * @access public
+        * @var string
+        */
+       public $field1;
+       
+       /**
+        * @array
+        * @access public
+        * @var string
+        */
+       public $list1;
+       
+       /**
+        * @array
+        * @access public
+        * @var SimpleTestClass
+        */
+       public $list2;
+       
+       /**
+        * @array
+        * @access public
+        * @var AttributeTestClass
+        */
+       public $list3;
+       
+       /**
+        * @access public
+        * @var SimpleTestClass
+        */
+       public $nestedField;
+}
+
+class AttributeTestClass extends PPMessage {
+       
+       /**
+        *
+        * @access public
+        * @attribute
+        * @var string
+        */
+       public $attrib1;
+
+       /**
+        *
+        * @access public
+        * @attribute
+        * @var string
+        */
+       public $attrib2;
+       
+       /**
+        *
+        * @access public
+        * @value
+        * @var string
+        */
+       public $value;
+       
+}
+
+/**
+ * @hasAttribute
+ *
+ */
+class AttributeContainerTestClass extends PPMessage {
+       /**
+        *
+        * @access public
+        * @var AttributeTestClass
+        */
+       public $member;
+       
+               /**
+        * 
+     * @array
+        * @access public
+        * @var AttributeTestClass
+        */ 
+       public $arrayMember;
+
+}
+
+
+/**
+ * Test class for PPMessage.
+ *
+ */
+class PPMessageTest extends PHPUnit_Framework_TestCase
+{
+       /**
+        * Sets up the fixture, for example, opens a network connection.
+        * This method is called before a test is executed.
+        */
+       protected function setUp() {
+               
+       }
+       
+       /**
+        * Tears down the fixture, for example, closes a network connection.
+        * This method is called after a test is executed.
+        */
+       protected function tearDown() {
+       }
+       
+       /**
+        * @test
+        */
+       public function attributeSerialization() {
+               $o = new AttributeTestClass();
+               $o->attrib1 = "abc";
+               $o->attrib2 = "random value";
+               $c = new AttributeContainerTestClass();
+               $c->member = $o;
+               
+               $this->assertEquals("attrib1=abc&attrib2=random+value", $o->toNVPString());             
+               $this->assertEquals("member.attrib1=abc&member.attrib2=random+value", $c->toNVPString());               
+               
+               $o->value = "value";
+               $this->assertEquals("attrib1=abc&attrib2=random+value&=value", $o->toNVPString());
+               $this->assertEquals("member.attrib1=abc&member.attrib2=random+value&member=value", $c->toNVPString());
+
+                               
+       }
+       
+       /**
+        * @test
+        */
+       public function attributeSerializationInArrays() {
+               $o = new AttributeTestClass();
+               $o->attrib1 = "abc";
+               $o->attrib2 = "random value";
+               $o->value = "value";
+               
+               $c = new AttributeContainerTestClass();
+               $c->member = $o;
+               
+               $o = new AttributeTestClass();
+               $o->attrib1 = "abc";
+               $o->attrib2 = "random value";
+               $c->arrayMember = array($o);
+               
+               $this->assertEquals("member.attrib1=abc&member.attrib2=random+value&member=value&arrayMember(0).attrib1=abc&arrayMember(0).attrib2=random+value", 
+                               $c->toNVPString());
+               
+               $c->arrayMember[0]->value = "value";
+               $this->assertEquals("member.attrib1=abc&member.attrib2=random+value&member=value&arrayMember(0).attrib1=abc&arrayMember(0).attrib2=random+value&arrayMember(0)=value",
+                               $c->toNVPString());
+               
+       }
+       
+       /**
+        * @test
+        */
+       public function attributeDeserialization() {
+               
+               // Attributes and value present
+               $responseMap = array(
+                       "member.attrib1" => "abc",
+                       "member.attrib2" => "random+value",
+                       "member" => "value"
+               );      
+               $c = new AttributeContainerTestClass();
+               $c->init($responseMap);
+               
+               $this->assertNotNull($c->member);
+               $this->assertEquals("abc", $c->member->attrib1);
+               $this->assertEquals("random value", $c->member->attrib2);
+               $this->assertEquals("value", $c->member->value);
+
+               // Only value present           
+               $responseMap = array(
+                       "member" => "value"
+               );              
+               $c = new AttributeContainerTestClass();
+               $c->init($responseMap);
+               
+               $this->assertNotNull($c->member);
+               $this->assertEquals("value", $c->member->value);
+               
+
+               // Only attributes present              
+               $responseMap = array(
+                       "member.attrib1" => "abc",
+                       "member.attrib2" => "random+value"
+               );
+               $c = new AttributeContainerTestClass();
+               $c->init($responseMap);
+               
+               $this->assertNotNull($c->member);
+               $this->assertEquals("abc", $c->member->attrib1);
+               $this->assertEquals("random value", $c->member->attrib2);               
+       
+       }
+       
+       /**
+        * @test
+        */
+       public function attributeDeserializationInArrays() {
+       
+               // Only value present. Single item in list
+               $responseMap = array(
+                               "arrayMember(0)" => "value+1"
+               );
+               $c = new AttributeContainerTestClass();
+               $c->init($responseMap);
+               $this->assertNotNull($c->arrayMember[0]);
+               $this->assertEquals("value 1", $c->arrayMember[0]->value);
+               
+               
+               // Only attributes present. Single item in list
+               $responseMap = array(
+                       "arrayMember(0).attrib1" => "abc",
+                       "arrayMember(0).attrib2" => "random+value",                             
+               );
+               $c = new AttributeContainerTestClass();
+               $c->init($responseMap);
+               
+               $this->assertNotNull($c->arrayMember[0]);
+               $this->assertEquals("abc", $c->arrayMember[0]->attrib1);
+               $this->assertEquals("random value", $c->arrayMember[0]->attrib2);               
+               
+               
+               // Attributes and value present. Mulitple items in list
+               $responseMap = array(
+                       "arrayMember(0).attrib1" => "abc",
+                       "arrayMember(0).attrib2" => "random+value",
+                       "arrayMember(0)" => "value",
+                       "arrayMember(0).attrib1" => "xyz",
+                       "arrayMember(1).attrib1" => "attribute1"
+               );
+               $c->init($responseMap);
+
+               $this->assertEquals("value", $c->arrayMember[0]->value);
+               $this->assertEquals("xyz", $c->arrayMember[0]->attrib1);
+               $this->assertEquals("random value", $c->arrayMember[0]->attrib2);
+               
+               $this->assertEquals("attribute1", $c->arrayMember[1]->attrib1);
+               $this->assertNull($c->arrayMember[1]->value);
+               
+       }
+
+
+       /**
+        * @test
+        */
+       public function simpleSerialization() {
+               
+               $o = new SimpleTestClass();
+               $o->field1 = "fieldvalue1";
+               $o->field2 = "fieldvalue2";
+               
+               $this->assertEquals("field1=fieldvalue1&field2=fieldvalue2", $o->toNVPString(''));
+       }
+       
+       
+       /**
+        * @test
+        */
+       public function simpleDeserialization() {
+       
+               $map = array(
+                       "field1" => "fieldvalue1",
+                       "field2" => "field+value2"
+               );
+               $o = new SimpleTestClass();
+               $o->init($map);
+       
+               $this->assertEquals("fieldvalue1", $o->field1);
+               $this->assertEquals("field value2", $o->field2);
+       }
+       
+       
+       /**
+        * @test
+        */
+       public function nestedSerialization() {
+       
+               $o = new SimpleTestClass();
+               $o->field1 = "fieldvalue1";
+               $o->field2 = "fieldvalue2";
+       
+               $c = new SimpleContainerTestClass();
+               $c->nestedField = $o;
+               $c->field1 = "abc";
+       
+               $this->assertEquals("field1=abc&nestedField.field1=fieldvalue1&nestedField.field2=fieldvalue2", $c->toNVPString(''));
+       }
+
+       
+       /**
+        * @test
+        */
+       public function nestedDeserialization() {
+               
+               $map = array(
+                       "field1" => "abc",
+                       "nestedField.field1" => "fieldvalue1",
+                       "nestedField.field2" => "field+value2"
+               );
+       
+               $c = new SimpleContainerTestClass();
+               $c->init($map);
+
+               $this->assertEquals("abc", $c->field1);
+               $this->assertEquals("fieldvalue1", $c->nestedField->field1);
+               $this->assertEquals("field value2", $c->nestedField->field2);
+       }
+       
+       
+       /**
+        * @test
+        */
+       public function simpleListSerialization() {
+       
+               $c = new SimpleContainerTestClass();
+               $c->list1 = array('Array', "of", "some strings");
+               $c->field1 = "abc";
+       
+               $this->assertEquals("field1=abc&list1(0)=Array&list1(1)=of&list1(2)=some+strings", $c->toNVPString(''));
+       }
+       
+       /**
+        * @test
+        */
+       public function simpleListDeserialization() {
+       
+               $map = array(
+                       "field1" => "abc",
+                       "list1(0)" => "Array",
+                       "list1(1)" => "of",
+                       "list1(2)" => "some+strings"
+               );
+                               
+               $c = new SimpleContainerTestClass();
+               $c->init($map);
+       
+               $this->assertEquals("abc", $c->field1);
+               $this->assertEquals(3, count($c->list1));
+               $this->assertEquals("some strings", $c->list1[2]);
+       }
+       
+       /**
+        * @test
+        */
+       public function complexListSerialization() {
+       
+               $o1 = new SimpleTestClass();
+               $o1->field1 = "somevalue1";
+               $o1->field2 = "somevalue2";
+       
+               $o2 = new SimpleTestClass();
+               $o2->field1 = "another value1";
+               $o2->field2 = "anothervalue2";
+               
+               $c = new SimpleContainerTestClass();
+               $c->list2 = array($o1, $o2);
+       
+               $this->assertEquals("list2(0).field1=somevalue1&list2(0).field2=somevalue2&list2(1).field1=another+value1&list2(1).field2=anothervalue2", 
+                               $c->toNVPString(''));
+       }
+       
+       /**
+        * @test
+        */
+       public function complexListDeserialization() {
+               
+               $map = array(
+                       "list2(0).field1" => "somevalue1",
+                       "list2(0).field2" => "somevalue2",
+                       "list2(1).field1" => "another+value1",
+                       "list2(1).field2" => "anothervalue2"
+               );
+               
+               $c = new SimpleContainerTestClass();
+               $c->init($map);
+       
+               $this->assertEquals(2, count($c->list2));
+               $this->assertEquals("somevalue1", $c->list2[0]->field1);
+               $this->assertEquals("another value1", $c->list2[1]->field1);
+       }
+       
+       
+       /**
+        * @test
+        */
+       public function serializeAndDeserialize() {
+               
+               $o1 = new AttributeTestClass();
+               $o1->value = "some value";
+               $o1->attrib1 = "someattrib";
+               
+               $o2 = new AttributeTestClass();
+               $o2->value = "some value2";
+               
+               $o3 = new AttributeTestClass();
+               $o3->attrib1 = "attribute";
+               $o3->value = "some value3";
+               
+               $c = new SimpleContainerTestClass();
+               $c->list3 = array($o1, $o2, $o3);
+               
+               $newC = new SimpleContainerTestClass();
+               $newC->init(PPUtils::nvpToMap($c->toNVPString(''))); //TODO: Mock nvpToMap
+               
+               $this->assertEquals($c, $newC);
+       }
+
+       /**
+        * @test
+        */
+       public function deserializeAndSerialize() {             
+               $nvpString = "list2(0).field1=somevalue1&list2(0).field2=somevalue2&list2(1).field1=another+value1&list2(1).field2=anothervalue2&list3(0).attrib1=somevalue1&list3(0).attrib2=somevalue2&list3(0)=value+field&list3(1).attrib1=another+value1&list3(2)=anothervalue2";
+               $newC = new SimpleContainerTestClass();
+               $newC->init(PPUtils::nvpToMap($nvpString)); //TODO: Mock nvpToMap               
+               $this->assertEquals($nvpString, $newC->toNVPString());
+       }
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPMissingCredentialExceptionTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPMissingCredentialExceptionTest.php
new file mode 100644 (file)
index 0000000..ec8e752
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+use PayPal\Exception\PPMissingCredentialException;
+
+/**
+ * Test class for PPMissingCredentialException.
+ *
+ */
+class PPMissingCredentialExceptionTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var PPMissingCredentialException
+     */
+    protected $object;
+
+    /**
+     * Sets up the fixture, for example, opens a network connection.
+     * This method is called before a test is executed.
+     */
+    protected function setUp()
+    {
+        $this->object = new PPMissingCredentialException;
+    }
+
+    /**
+     * Tears down the fixture, for example, closes a network connection.
+     * This method is called after a test is executed.
+     */
+    protected function tearDown()
+    {
+    }
+
+    /**
+     * @test
+     */
+    public function testErrorMessage()
+    {
+               $msg = $this->object->errorMessage();
+               $this->assertContains('Error on line', $msg);
+    }
+}
+?>
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPSignatureCredentialTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPSignatureCredentialTest.php
new file mode 100644 (file)
index 0000000..2d48a9d
--- /dev/null
@@ -0,0 +1,103 @@
+<?php
+use PayPal\Auth\PPSignatureCredential;
+use PayPal\Auth\PPTokenAuthorization;
+use PayPal\Auth\PPSubjectAuthorization;
+/**
+ * Test class for PPSignatureCredential.
+ *
+ */
+class PPSignatureCredentialTest extends PHPUnit_Framework_TestCase
+{
+       /**
+        * @var PPSignatureCredential
+        */
+       protected $merchantCredential;
+
+       protected $platformCredential;
+
+       /**
+        * Sets up the fixture, for example, opens a network connection.
+        * This method is called before a test is executed.
+        */
+       protected function setUp()
+       {
+               $this->merchantCredential = new PPSignatureCredential("platfo_1255077030_biz_api1.gmail.com", "1255077037","Abg0gYcQyxQvnf2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf");
+
+               $this->platformCredential = new PPSignatureCredential("platfo_1255077030_biz_api1.gmail.com", "1255077037","Abg0gYcQyxQvnf2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf");
+               $this->platformCredential->setApplicationId("APP-80W284485P519543T");
+       }
+
+       /**
+        * Tears down the fixture, for example, closes a network connection.
+        * This method is called after a test is executed.
+        */
+       protected function tearDown()
+       {
+       }
+
+       /**
+        * @test
+        */
+       public function testValidateUsername()
+       {
+               $this->setExpectedException('PayPal\Exception\PPMissingCredentialException');
+               $cred = new PPSignatureCredential("", "1255077037","Abg0gYcQyxQvnf2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf");
+               $cred->validate();
+       }
+
+       /**
+        * @test
+        */
+       public function testValidatepwd()
+       {
+               $this->setExpectedException('PayPal\Exception\PPMissingCredentialException');
+               $cred = new PPSignatureCredential("platfo_1255077030_biz_api1.gmail.com", "","Abg0gYcQyxQvnf2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf");
+               $cred->validate();
+       }
+
+       /**
+        * @test
+        */
+       public function testGetSignature()
+       {
+               $this->assertEquals('Abg0gYcQyxQvnf2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf', $this->merchantCredential->getSignature());
+       }
+       /**
+        * @test
+        */
+       public function testGetUserName()
+       {
+               $this->assertEquals('platfo_1255077030_biz_api1.gmail.com', $this->merchantCredential->getUserName());
+       }
+       /**
+        * @test
+        */
+       public function testGetPassword()
+       {
+               $this->assertEquals('1255077037', $this->merchantCredential->getPassword());
+       }
+       /**
+        * @test
+        */
+       public function testGetAppId()
+       {
+               $this->assertEquals('APP-80W284485P519543T', $this->platformCredential->getApplicationId());
+       }
+       
+       public function testThirdPartyAuthorization() {
+               $authorizerEmail = "merchant@domain.com";
+               $thirdPartyAuth = new PPSubjectAuthorization($authorizerEmail);         
+               $cred = new PPSignatureCredential("username", "pwd", "signature");
+               $cred->setThirdPartyAuthorization($thirdPartyAuth);             
+               $this->assertEquals($cred->getThirdPartyAuthorization()->getSubject(), $authorizerEmail);
+               
+               $accessToken = "atoken";
+               $tokenSecret = "asecret";
+               $thirdPartyAuth = new PPTokenAuthorization($accessToken, $tokenSecret);
+               $cred->setThirdPartyAuthorization($thirdPartyAuth);
+               $this->assertEquals($cred->getThirdPartyAuthorization()->getAccessToken(), $accessToken);
+               $this->assertEquals($cred->getThirdPartyAuthorization()->getTokenSecret(), $tokenSecret);
+       }
+
+}
+?>
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPUtilsTest.php b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPUtilsTest.php
new file mode 100644 (file)
index 0000000..7ad664d
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+use PayPal\Core\PPUtils;
+/**
+ * Test class for PPUtils.
+ *
+ */
+class PPUtilsTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var PPUtils
+     */
+    protected $object;
+
+    /**
+     * Sets up the fixture, for example, opens a network connection.
+     * This method is called before a test is executed.
+     */
+    protected function setUp()
+    {
+        $this->object = new PPUtils();
+    }
+
+    /**
+     * Tears down the fixture, for example, closes a network connection.
+     * This method is called after a test is executed.
+     */
+    protected function tearDown()
+    {
+    }
+
+    /**
+     * @test
+     */
+    public function testNvpToMap()
+    {
+       $arr = $this->object->nvpToMap('requestEnvelope.detailLevel=ReturnAll&requestEnvelope.errorLanguage=en_US&invoice.merchantEmail=jb-us-seller1@paypal.com&invoice.payerEmail=jbui-us-personal1@paypal.com&invoice.items[0].name=product1&invoice.items[0].quantity=10.0&invoice.items[0].unitPrice=1.2&invoice.currencyCode=USD&invoice.paymentTerms=DueOnReceipt');
+       $this->assertArrayHasKey('requestEnvelope.detailLevel', $arr);
+       $this->assertArrayHasKey('requestEnvelope.errorLanguage', $arr);
+       $this->assertEquals(is_array($arr),true);
+    }
+
+    /**
+     * @test
+     */
+    public function testArray_match_key()
+    {
+       $arr = array('key1' => 'somevalue', 'key2' => 'someothervalue');
+               $this->assertEquals(PPUtils::array_match_key($arr, "key"), true);
+               $arr = unserialize('a:10:{s:26:"responseEnvelope.timestamp";s:35:"2011-04-19T04%3A32%3A29.469-07%3A00";s:20:"responseEnvelope.ack";s:7:"Failure";s:30:"responseEnvelope.correlationId";s:13:"c2514f258ddf1";s:22:"responseEnvelope.build";s:7:"1829457";s:16:"error(0).errorId";s:6:"580027";s:15:"error(0).domain";s:8:"PLATFORM";s:17:"error(0).severity";s:5:"Error";s:17:"error(0).category";s:11:"Application";s:16:"error(0).message";s:44:"Prohibited+request+parameter%3A+businessInfo";s:21:"error(0).parameter(0)";s:12:"businessInfo";}');
+               $this->assertEquals(PPUtils::array_match_key($arr, "error(0)."), true);
+    }
+
+    /**
+     * @test
+     */
+    public function testGetLocalIPAddress()
+    {
+        $ip = $this->object->getLocalIPAddress();
+        //$this->assertEquals('127.0.0.1',$ip);
+    }
+
+}
+?>
diff --git a/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/sdk_config.ini b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/sdk_config.ini
new file mode 100644 (file)
index 0000000..37e11b4
--- /dev/null
@@ -0,0 +1,33 @@
+;Account credentials
+[Account]
+
+acct1.ClientId = ProxyRP-01
+acct1.ClientSecret = A8VERY8SECRET8VALUE0   
+acct1.UserName = jb-us-seller_api1.paypal.com
+acct1.Password = WX4WTU3S8MY44S7F
+acct1.Signature = AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy
+acct1.AppId = APP-80W284485P519543T
+# Subject is optional and is required only in case of third party authorization 
+acct1.Subject = 
+
+; Certificate Credentials Test Account
+acct2.UserName = platfo_1255170694_biz_api1.gmail.com
+acct2.Password = 2DPPKUPKB7DQLXNR
+; Certificate path relative to config folder or absolute path in file system
+acct2.CertPath = cacert.pem
+
+
+;Connection Information
+[Http]
+http.ConnectionTimeOut = 30
+http.Retry = 5
+;http.Proxy
+
+;Logging Information
+[Log]
+log.FileName=../PayPal.log
+log.LogLevel=INFO
+log.LogEnabled=true
+
+mode = sandbox
\ No newline at end of file
diff --git a/lib/paymentProcessors/PayPal/test.php b/lib/paymentProcessors/PayPal/test.php
new file mode 100755 (executable)
index 0000000..141c75a
--- /dev/null
@@ -0,0 +1,111 @@
+<?php
+
+define('PAYPAL_DEBUG', true);
+
+// Setup some info that will be provided by the cart application
+$thisScript = 'http://'.$_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'];
+$account = array(
+               'clientID' => 'AY2IlhCAFCgTaYSgrGfBQ0h5WKKgpLwU-jd2QkKsEbDpGEWtCDZKtp2VLhu1',
+               'secret' => 'EOWLsBDrkvdOKUlfhAKJ47aXHBr5xzw-2o7JdLCcLVciGqNGXlhMayP1WKhe',
+               'returnURL' => $thisScript.'?PayPalAction=Approved',
+               'cancelURL' => $thisScript.'?PayPalAction=Canceled',
+               'test' => 3
+);
+$payment = array(
+               'name' => 'Gaslight Media',
+               'charge' =>  22.4,
+               'invoice' => '123abc',
+               'description' => 'Event Tickets Purchase',
+               'items' => array(
+                               array(
+                                               'quantity' => '2',
+                                               'name' => 'Fancy Dancy Dance',
+                                               'price' => 5.6,
+                                               'sku' => '123ABC1'
+                               ),
+                               array(
+                                               'quantity' => '1',
+                                               'name' => 'TuTu Tango',
+                                               'price' => 11.2,
+                                               'sku' => '123ABC2'
+                               )
+               )
+);
+$contact = array();
+
+// Load the PayPal class file
+require_once dirname(__FILE__).'/PayPal.php';
+
+// Start session
+session_start();
+
+
+// Check for certain actions related to sending user to PayPal site for approval
+switch ($_REQUEST['PayPalAction']) {
+
+       case 'GetApproval':
+
+               // Use browser redirect 302 to send user to PayPal.
+               // This is proper way to do so according to the API documentation.
+               $trans = $_SESSION['trans'];
+               header('Location: '.$trans->urls->approval_url->href);
+               exit;
+
+               break;
+
+       case 'Approved':
+
+               echo "Return link followed.<P>";
+
+               // Save Payer ID
+               $_SESSION['payerID'] = $_REQUEST['PayerID']; // NEED TO FILTER THIS FOR PRODUCTION
+
+               // Create PayPal object with existing access object from the session
+               $PayPal = new PayPalPaymentGateway($account, $_SESSION['access'], $_SESSION['trans']);
+
+               // Execute the PayPal payment
+               $r = $PayPal->executePayment($_SESSION['payerID']);
+
+               echo "Payment Executed Successfully<P>";
+
+               exit;
+
+               break;
+
+       case 'Canceled':
+
+               echo "Payment Cancelled<P>";
+               exit;
+
+               break;
+}
+
+// Create the PayPal object (note no previous access object)
+$PayPal = new PayPalPaymentGateway($account, false, false);
+
+// Was there an error?
+if (!$PayPal->status) {
+       echo "Received an error: ".$PayPal->error;
+       exit;
+}
+
+// Store access information
+$_SESSION['access'] = $PayPal->access;
+
+// Try to enter Payment
+$PayPal->processPayment($payment, $contact);
+
+// Was there an error?
+if (!$PayPal->status) {
+       echo "Received an error: ".$PayPal->error;
+       exit;
+}
+
+// Store Transaction data to session
+$_SESSION['trans'] = $PayPal->trans;
+
+// Show user link to PayPal for them to approve payment
+// Note that uses a target to create a new window/tab
+echo '<a href="'.$this_script.'?PayPalAction=GetApproval" target="PayPal">Proceed to PayPal</a>';
+
+?>
\ No newline at end of file
diff --git a/lib/paymentProcessors/TestByCardNumber/paymentGateway.php b/lib/paymentProcessors/TestByCardNumber/paymentGateway.php
new file mode 100644 (file)
index 0000000..af02d0c
--- /dev/null
@@ -0,0 +1,190 @@
+<?php
+/**
+ * Event Management System
+ * Test Payment Processing class
+ *
+ * @category Front-End
+ * @package  EventManagement
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: classes/paymentProcessors/test.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ * @link     <>
+ */
+
+/**
+ * EventManagementAuthorizeNetPaymentProcessing class
+ *
+ * PHP version 5
+ *
+ * @category Event Management Admin Tickets
+ * @package  EventManagement
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: classes/paymentProcessors/test.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ * @link     <>
+ */
+
+/**
+ * Test Payment Gateway class
+ *
+ * PHP version 5
+ */
+
+class PaymentGateway
+{
+
+    /**
+     * Constructor
+     *
+     * @param $account Array of account information - Not used for Test Processor
+     *
+     * @return boolean    Returns value of $success parameter
+     * @access public
+     */
+    function __construct($account = false)
+    {
+
+       // Nothing to do here for the test processor
+        return true;
+
+    }
+
+    /*
+     * Process Credit Card Payment
+     *
+     * @param array    $pmt Payment information
+     *
+     * array(
+     *                 'gateway' => {selected payment gateway},
+     *                 'name' => {name of venue}
+     *                 'charge' => {amount to charge card}
+     *                 'cctype' => {type of card - text}
+     *                 'ccnumb' => {card number - digits only}
+     *                 'ccexp' => {expiration date as m/Y}
+     *                 'ccode' => {security code on back of card}
+     * )
+     *
+     * @param array $contact Billing contact information (not used in this class)
+     *
+     * This Test Processor looks at the last digit of the card number
+     * and synthesizes a corresponding response.
+     *
+        *      1       Card Approved
+        *      2       Bad Data Supplied
+        *      3       Communications Failure
+        *  4   Bad response or no response from processor
+        *  5   Transaction validation not accepted
+        *  6   Merchant authentication failure or bad account
+        *  7   Card Declined
+     *
+     * @return array    Returns array of results
+     */
+    function processPayment($pmt, $contact = false)
+    {
+
+       // Get last digit of card number that indicates desired response
+       $respCode = substr($pmt['ccnumb'], 15, 1);
+
+       // Approved flag
+       $approved = false;
+
+       // Prepare synthesized response
+       switch ($respCode) {
+
+               case 1:
+
+                       $resp = array(
+                           'gateway' => 'Card # Tests',
+                               'status' => 1,
+                               'statusText' => 'Card Approved',
+                               'authCode' => '00110011',
+                               'description' => 'Card Approved'
+                       );
+                       break;
+
+               case 2:
+
+                       $resp = array(
+                           'gateway' => 'Card # Tests',
+                           'status' => 2,
+                    'statusText' => 'Bad data supplied',
+                               'authCode' => '',
+                               'description' => 'Card number was not recognizable'
+                       );
+                       break;
+
+               case 3:
+
+                       $resp = array(
+                    'gateway' => 'Card # Tests',
+                    'status' => 3,
+                    'statusText' => 'Communications failure',
+                    'authCode' => '',
+                    'description' => 'We were unable to communicate with the credit card processing service.'
+                       );
+                       break;
+
+               case 4:
+
+                       $resp = array(
+                    'gateway' => 'Card # Tests',
+                    'status' => 4,
+                    'statusText' => 'Bad Response',
+                    'authCode' => '',
+                    'description' => 'We received an unrecognizable response from the credit card processing service.'
+                       );
+                       break;
+
+               case 5:
+
+                       $resp = array(
+                    'gateway' => 'Card # Tests',
+                    'status' => 5,
+                    'statusText' => 'Transaction not valid',
+                    'authCode' => '',
+                    'description' => 'We were unable to validate the response from the credit card processor.'
+                       );
+                       break;
+
+               case 6:
+
+                       $resp = array(
+                    'gateway' => 'Card # Tests',
+                    'status' => 6,
+                    'statusText' => 'Merchant account problem',
+                    'authCode' => '00110011',
+                    'description' => 'The merchant account for this venue was not recognized by the credit card processor.'
+                       );
+                       break;
+
+               case 7:
+
+                       $resp = array(
+                    'gateway' => 'Card # Tests',
+                    'status' => 7,
+                    'statusText' => 'Card Declined',
+                    'authCode' => '',
+                    'description' => 'Your credit card purchase was declined.'
+                       );
+                       break;
+
+               default:        // Consider any other last digit as approved
+
+                       $resp = array(
+                    'gateway' => 'Card # Tests',
+                    'status' => 1,
+                    'statusText' => 'Card Approved',
+                    'authCode' => '00110011',
+                    'description' => 'Card Approved'
+                       );
+                       break;
+
+       }
+
+       return $resp;
+    }
+
+}
+
+
+?>
\ No newline at end of file
diff --git a/lib/paymentProcessors/TestGood/paymentGateway.php b/lib/paymentProcessors/TestGood/paymentGateway.php
new file mode 100644 (file)
index 0000000..d5e5dbe
--- /dev/null
@@ -0,0 +1,96 @@
+<?php
+/**
+ * Event Management System
+ * No Payment PaymentGateway class
+ *
+ * @category Front-End
+ * @package  EventManagement
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: classes/paymentProcessors/no_payment.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ * @link     <>
+ */
+
+/**
+ * No Payment PaymentGateway class
+ *
+ * PHP version 5
+ *
+ * @category Event Management Admin Tickets
+ * @package  EventManagement
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: classes/paymentProcessors/no_payment.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ * @link     <>
+ */
+
+/**
+ * No Payment Gateway class
+ *
+ * PHP version 5
+ */
+
+class PaymentGateway
+{
+
+    /**
+     * Constructor
+     *
+     * @param $account Array of account information - Not used for Test Processor
+     *
+     * @return boolean    Returns value of $success parameter
+     * @access public
+     */
+    function __construct($account = false)
+    {
+
+       // Nothing to do here
+        return true;
+
+    }
+
+    /*
+     * No Payment Required
+     *
+     * @param array    $pmt Payment information
+     *
+     * array(
+     *                 'gateway' => {selected payment gateway},
+     *                 'name' => {name of venue}
+     *                 'charge' => {amount to charge card}
+     *                 'cctype' => {type of card - text}
+     *                 'ccnumb' => {card number - digits only}
+     *                 'ccexp' => {expiration date as m/Y}
+     *                 'ccode' => {security code on back of card}
+     * )
+     *
+     * @param array $contact Billing contact information (not used in this class)
+     *
+     * This Processor always returns a "Card Approved" status
+     * and synthesizes a corresponding response.
+     *
+        *      1       Card Approved
+     *
+     * @return array    Returns array of results
+     */
+    function processPayment($pmt, $contact = false)
+    {
+
+       // Get last digit of card number that indicates desired response
+       $respCode = 'NO-PAYMENT';
+
+       // Approved flag
+       $approved = false;
+
+               $resp = array(
+                   'gateway' => 'Card Good',
+                   'status' => 1,
+                       'statusText' => 'No Payment',
+                       'authCode' => '000000',
+                       'description' => 'No Payment Required'
+               );
+
+       return $resp;
+    }
+
+}
\ No newline at end of file
diff --git a/lib/paymentProcessors/readme.txt b/lib/paymentProcessors/readme.txt
new file mode 100644 (file)
index 0000000..5796411
--- /dev/null
@@ -0,0 +1,11 @@
+Gaslight Media Payment Gateway Classes
+--------------------------------------
+
+These classes are standardized so they may be used to process payments for the same calling code.
+To do this, all of the classes that need to be called are named "paymentGaetway.php" and they use
+the same standards for method names, calling parameters, and return results.
+
+Since all of the classes have the same name, it is only necessary to specify the directory in which
+to find the class to select the desired payment methd.
+
+(Need to add standards documentation here)
\ No newline at end of file
index df78b8b..ccaf14e 100644 (file)
@@ -46,16 +46,16 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices
     /**
      * Constructor
      *
-     * This contructor performs the work for this model. This model returns
+     * This constructor performs the work for this model. This model returns
      * an array containing the following.
      *
      * 'status'
      *
-     * True if successfull and false if there was a fatal failure.
+     * True if successful and false if there was a fatal failure.
      *
      * 'view'
      *
-     * A suggested view name that the contoller should use instead of the
+     * A suggested view name that the controller should use instead of the
      * default view for this model or false to indicate that the default view
      * should be used.
      *
@@ -153,7 +153,7 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices
             // Set transaction_time to current time.
             $_REQUEST['transaction_time'] = date('Y-m-d H:i:s');
             $_REQUEST['due_date'] = date('Y-m-d', strtotime($_REQUEST['due_date']));
-            echo '<pre>' . print_r( $_REQUEST, true ) . '</pre>';
+            // echo '<pre>' . print_r( $_REQUEST, true ) . '</pre>';
             $invoices = $this->insertEntry();
             $this->invoice_id = $invoices['fieldData']['id'];
             // After the Invoice is created need to add each line item
@@ -322,11 +322,7 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices
             }
             unset($invoicesResult);
 
-            echo '<pre>$invoices: ' . print_r( $invoices, true ) . '</pre>';
-
-            foreach ( $invoices as $invoice ) {
-                // $this->generateInvoiceTotal( $invoice['id'] );
-            }
+            // echo '<pre>$invoices: ' . print_r( $invoices, true ) . '</pre>';
 
             break;
 
index 35752dc..897c86e 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /**
  * Gaslight Media Members Database
- * Admin Member Billing List
+ * Admin Billing Dashboard
  *
  * PHP version 5.5
  *
@@ -9,17 +9,15 @@
  * @package  glmMembersDatabase
  * @author   Chuck Scott <cscott@gaslightmedia.com>
  * @license  http://www.gaslightmedia.com Gaslightmedia
- * @release  admin.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @release  index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
  * @link     http://dev.gaslightmedia.com/
  */
-
-// Inform the billing code that we're working from the member area
 define('GLM_MEMBERS_BILLING_MEMBER_MENU', true);
 
-// Load the events index
-require GLM_MEMBERS_BILLING_PLUGIN_PATH."/models/admin/billing/index.php";
+// Load Billing data abstract
+// require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH.'/data/dataBilling.php';
 
-class GlmMembersAdmin_member_billing extends GlmMembersAdmin_billing_index
+class GlmMembersAdmin_member_billing // extends GlmDataBilling
 {
 
     /**
@@ -37,36 +35,14 @@ class GlmMembersAdmin_member_billing extends GlmMembersAdmin_billing_index
      */
     public $config;
     /**
-     * Billing List
-     *
-     * @var $billing
-     * @access public
-     */
-    public $billing = false;
-    /**
-     * Contact Info
-     *
-     * @var $contactInfo
-     * @access public
-     */
-    public $contactInfo = false;
-    /**
-     * Member ID
+     * Billing ID
      *
      * @var $memberID
      * @access public
      */
     public $memberID = false;
-    /**
-     * Contact ID
-     *
-     * @var $contactID
-     * @access public
-     */
-    public $contactID = false;
-
 
-    /*
+    /**
      * Constructor
      *
      * This contructor performs the work for this model. This model returns
@@ -100,9 +76,175 @@ class GlmMembersAdmin_member_billing extends GlmMembersAdmin_billing_index
         // Save plugin configuration object
         $this->config = $config;
 
-        // Run constructor for members data class
-        parent::__construct($wpdb, $config);
+        /*
+         * Run constructor for the Billing data class
+         *
+         * Note, the third parameter is a flag that indicates to the Contacts
+         * data class that it should flag a group of fields as 'view_only'.
+         */
+        // parent::__construct(false, false, true);
+
+    }
+
+    public function modelAction($actionData = false)
+    {
+        // Initialize Variables Here
+        $numbPending        = 0;
+        $namesList          = false;
+        $haveCategories     = false;
+        $numberPending      = 0;
+        $fromMemberMenu     = false;
+        $this->memberID     = false;
+        $memberData         = false;
+        $memberName         = false;
+        $haveMember         = false;
+        $haveAccount        = false;
+        $option             = 'list';
+        $view               = 'billing';
+        $account            = false;
+        $accountID          = 0;
+        $accountUpdated     = false;
+        $accountUpdateError = false;
+        $accountAdded       = false;
+        $accountInsertError = false;
+
+        // For lockedToMember
+        $lockedToMember = false;
+        $lockedWhereT   = 'true';
+        $lockedWhere    = 'true';
+
+        // Check if there's a logged in user who is locked to their own entity
+        $lockedToMember = apply_filters('glm_members_locked_to_member_id', false);
+        if ($lockedToMember) {
+            $memberID       = $lockedToMember;
+            $lockedToMember = $memberID;
+            $lockedWhereT   = 'T.ref_type = '.$this->config['ref_type_numb']['Member'].' AND T.ref_dest = '.$memberID;
+            $lockedWhere    = 'ref_type = '.$this->config['ref_type_numb']['Member'].' AND ref_dest = '.$memberID;
+        }
+
+        // Get number of billing
+        // $numberPending = $this->getStats($lockedWhere.' status = '.$this->config['status_numb']['Pending']);
+
+        // I know this is awkward, but we if there's anything that follows these we need " AND " appended.
+        if ($lockedWhereT != '') {
+            $lockedWhereT .= ' AND ';
+        }
+        if ($lockedWhere != '') {
+            $lockedWhere .= ' AND ';
+        }
+
+        if ( defined( 'GLM_MEMBERS_BILLING_MEMBER_MENU' ) && GLM_MEMBERS_BILLING_MEMBER_MENU ) {
+            $fromMemberMenu = true;
+
+            if ( isset( $_REQUEST['member'] ) ) {
+                $this->memberID = $_REQUEST['member'];
+            }
+        }
+
+        require_once GLM_MEMBERS_PLUGIN_CLASS_PATH . '/data/dataMembers.php';
+        $this->Members = new GlmDataMembers( $this->wpdb, $this->config );
+
+        if ( $this->memberID ) {
+            $memberData = $this->Members->getEntry( $this->memberID );
+        }
+
+        if ( isset( $memberData ) && is_array( $memberData ) && $memberData['id'] > 0 ) {
+            $haveMember = true;
+            $memberName = $memberData['name'];
+        }
+
+        if ( isset( $_REQUEST['option'] ) ) {
+            $option = $_REQUEST['option'];
+        }
+
+        switch ( $option ) {
+        case 'account':
+            require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH .  '/data/dataAccounts.php';
+            $Accounts = new GlmDataAccounts( $this->wpdb, $this->config );
+
+            // Check to see if we're adding an account or editing one.
+            if ( isset( $_REQUEST['ref_name'] ) ) {
+                $_REQUEST['anniversary_date'] = date('Y-m-d', strtotime($_REQUEST['anniversary_date']));
+                // echo '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
+                // if there's no id then add account
+                if ( !isset( $_REQUEST['id'] ) ) {
+                    $account = $Accounts->insertEntry();
+                    if ( !$account['status'] ) {
+                        $accountInsertError = true;
+                    } else {
+                        $accountAdded = true;
+                    }
+                } else {
+                    $account = $Accounts->updateEntry( $_REQUEST['id'] );
+                    if ( !$account['status'] ) {
+                        $accountUpdateError = true;
+                    } else {
+                        $accountUpdated = true;
+                    }
+                }
+            }
+
+            // Need to see if there's an account for this member.
+            $accountID = $this->wpdb->get_var(
+                $this->wpdb->prepare(
+                    "SELECT id
+                       FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts
+                      WHERE ref_dest = %d",
+                    $this->memberID
+                )
+            );
+            if ( !$account ) {
+                if ( $accountID ) {
+                    $account     = $Accounts->editEntry( $accountID );
+                    $haveAccount = true;
+                } else {
+                    $accountID   = 0;
+                    $account     = $Accounts->newEntry();
+                    // Set the ref_name from memberData
+                    $account['fieldData']['ref_name'] = $memberData['name'];
+                    $haveAccount = false;
+                }
+            } else {
+                $haveAccount = true;
+                // echo '<pre>$account: ' . print_r( $account, true ) . '</pre>';
+            }
+
+            // echo '<pre>$account: ' . print_r( $account, true ) . '</pre>';
+            $view = 'editAccount';
+            break;
+        case 'list':
+            break;
+        }
+
+        // Compile template data
+        $templateData = array(
+            'accountID'          => $accountID,
+            'option'             => $option,
+            'fromMemberMenu'     => ( defined('GLM_MEMBERS_BILLING_MEMBER_MENU' ) ? true: false ),
+            'lockedToMember'     => $lockedToMember,
+            'numberPending'      => $numberPending,
+            'memberID'           => $this->memberID,
+            'haveMember'         => $haveMember,
+            'haveAccount'        => $haveAccount,
+            'memberData'         => $memberData,
+            'memberName'         => $memberName,
+            'account'            => $account,
+            'accountUpdated'     => $accountUpdated,
+            'accountUpdateError' => $accountUpdateError,
+            'accountAdded'       => $accountAdded,
+            'accountInsertError' => $accountInsertError,
+        );
+        // echo '<pre>$templateData: ' . print_r( $templateData, true ) . '</pre>';
+
+        // Return status, any suggested view, and any data to controller
+        return array(
+            'status'        => true,
+            'modelRedirect' => false,
+            'view'          => 'admin/billing/'.$view.'.html',
+            'data'          => $templateData
+        );
 
     }
 
+
 }
diff --git a/models/admin/member/savebilling.php b/models/admin/member/savebilling.php
new file mode 100644 (file)
index 0000000..35752dc
--- /dev/null
@@ -0,0 +1,108 @@
+<?php
+/**
+ * Gaslight Media Members Database
+ * Admin Member Billing List
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  admin.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link     http://dev.gaslightmedia.com/
+ */
+
+// Inform the billing code that we're working from the member area
+define('GLM_MEMBERS_BILLING_MEMBER_MENU', true);
+
+// Load the events index
+require GLM_MEMBERS_BILLING_PLUGIN_PATH."/models/admin/billing/index.php";
+
+class GlmMembersAdmin_member_billing extends GlmMembersAdmin_billing_index
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+    /**
+     * Billing List
+     *
+     * @var $billing
+     * @access public
+     */
+    public $billing = false;
+    /**
+     * Contact Info
+     *
+     * @var $contactInfo
+     * @access public
+     */
+    public $contactInfo = false;
+    /**
+     * Member ID
+     *
+     * @var $memberID
+     * @access public
+     */
+    public $memberID = false;
+    /**
+     * Contact ID
+     *
+     * @var $contactID
+     * @access public
+     */
+    public $contactID = false;
+
+
+    /*
+     * Constructor
+     *
+     * This contructor performs the work for this model. This model returns
+     * an array containing the following.
+     *
+     * 'status'
+     *
+     * True if successfull and false if there was a fatal failure.
+     *
+     * 'view'
+     *
+     * A suggested view name that the contoller should use instead of the
+     * default view for this model or false to indicate that the default view
+     * should be used.
+     *
+     * 'data'
+     *
+     * Data that the model is returning for use in merging with the view to
+     * produce output.
+     *
+     * @wpdb object WordPress database object
+     *
+     * @return array Array containing status, suggested view, and any data
+     */
+    public function __construct ($wpdb, $config)
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+
+        // Run constructor for members data class
+        parent::__construct($wpdb, $config);
+
+    }
+
+}
index 06d4a23..7d422a2 100644 (file)
@@ -94,6 +94,17 @@ CREATE TABLE {prefix}payments (
 
 ----
 
+-- pdfs
+CREATE TABLE {prefix}pdfs (
+    id INT NOT NULL AUTO_INCREMENT,
+    ref_type INT NOT NULL,                                 -- reference type
+    ref_dest INT NOT NULL,                                 -- reference types id
+    pdf MEDIUMTEXT NOT NULL,                               -- saved pdf
+    PRIMARY KEY (id)
+);
+
+----
+
 -- Notification Types
 CREATE TABLE {prefix}notification_types (
     id INT NOT NULL AUTO_INCREMENT,
index 926a4ad..8b65c5f 100644 (file)
@@ -71,6 +71,7 @@ $glmMembersBillingAddOnValidActions = array(
         ),
         'member' => array(
             'billing' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
+            'index'   => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
         ),
     ),
     'frontActions' => array(
index 5e1dc21..02112e4 100644 (file)
@@ -24,7 +24,7 @@
                 {else}
                     <tr class="alternate">
                 {/if}
-                    <td>{$t.id}</td>
+                    <td> {$t.id} </td>
                     <td> {$t.member_name} </td>
                     <td> {$t.transaction_time.datetime} </td>
                     <td> {$t.due_date.date} </td>
diff --git a/views/admin/member/index.html b/views/admin/member/index.html
new file mode 100644 (file)
index 0000000..0f74edc
--- /dev/null
@@ -0,0 +1,19 @@
+{if $fromMemberMenu}
+    {include file='admin/member/header.html'}
+    {include file='admin/billing/memberBillingSubHeader.html'}
+{else}
+    {include file='admin/billing/header.html'}
+{/if}
+
+    <table class="glm-admin-table">
+        <tr>
+            <td colspan="2" align="">
+            </td>
+        </tr>
+    </table>
+
+    <table class="glm-admin-table">
+        <tr><th>Number of Pending Invoices Listed: </th><td> replace me </td></tr>
+    </table>
+
+{include file='admin/footer.html'}