From: Chuck Scott Date: Mon, 2 Apr 2018 20:09:20 +0000 (-0400) Subject: Moved Payment Processors Class to main plugin X-Git-Tag: v2.10.28^2~7 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=dbfeb1d87c2850878f707010049268eee86b9c2a;p=WP-Plugins%2Fglm-member-db.git Moved Payment Processors Class to main plugin Updated Authorize.net SDK for new API. Added enhanced paymentProcessorsTest.php file to test and demostrate the new Authorize.net features Added ability to create a customer payment profile from a completed transaction Added ability to charge using a stored customer payment profile with Authorize.net --- diff --git a/lib/paymentProcessors/Authorize.Net/paymentGateway.php b/lib/paymentProcessors/Authorize.Net/paymentGateway.php new file mode 100644 index 00000000..1408c826 --- /dev/null +++ b/lib/paymentProcessors/Authorize.Net/paymentGateway.php @@ -0,0 +1,730 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: AuthorizeNet.php,v 1.0 2018/03/30 19:31:47 cscott Exp $ + * @link <> + */ + +require 'sdk-php-master/vendor/autoload.php'; +use net\authorize\api\contract\v1 as AnetAPI; +use net\authorize\api\controller as AnetController; +// use net\authorize\api\contract\v1\CustomerProfileIdType; + +// Uncomment the following line to activate log - DO NOT KEEP THIS ENABLED FOR NORMAL PRODUCTION! +// define("AUTHORIZENET_LOG_FILE", "phplog"); + +/** + * Authorize.net PaymentGateway class + * + * PHP version 5 + * + * @category Event Management Admin Tickets + * @package EventManagement + * @author Chuck Scott + * @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; + /** + * Merchant API Credentials + * + * @var object + * @acess private + */ + private $merchantAuthentication; + /** + * Test Mode + * + * @var string + * @access private + */ + private $testMode; + + /** + * Constructor + * + * @param array $account Account information + * + * @access public + * + * Information provided + * + * $account + * login Authorize.net login + * key Authorize.net login key + * test Test mode + * 0 = Production Mode (PRODUCTION) + * 1 = Local Transaction Approval Test + * 2 = Local Transaction Decline Test + * 3 = On-Line Transaction Test (SANDBOX) + * conf True if Authorize.net should send confirmation E-Mail to customer + * email Merchant E-Mail address to receive notices from Authorize.net for the transaction + * + * API Access for Authorize.net SANDBOX + * API Login ID: 44pvQ8D7d + * Transaction Key: 8rj6ME772K9Pe9pJ + * Secret Question: Simon + * + */ + public function __construct($account) + { + + $this->account = $account; + + // Set Authorize.net environment + $this->account['environment'] = 'SANDBOX'; + if ($this->account['test'] == 0) { + $this->account['environment'] = 'PRODUCTION'; + } + + // Common setup for API credentials + $this->merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $this->merchantAuthentication->setName($account['login']); + $this->merchantAuthentication->setTransactionKey($account['key']); + + } + + /** + * Process a Payment + * + * @param payment Array payment information + * @param contact Array contact information + * + * @access public + * @return array + * + * Information provided + * + * $payment array + * transOpt Transaction option: 0 = Charge Card, 1 = Charge Card and stroe as Profile, 2 = Charge using Stored Profile + * name Name of Venue + * customerProfileId Customer Profile ID from stored profile - if using transOpt = 2 + * paymentProfileId Payment Profile ID from stored profile - if using transOpt = 2 + * charge Total to be charged + * cctype Card type (not used for Authorize.net) Not Required + * ccname Name on card (not used for Authorize.net) + * ccnumb Card number + * ccexp Expiration date (m/y) + * cccode Security code on back of card + * invoice Invoice # is session ID (or some part thereof) + * Max 20 chars, letters and digits only + * Only last 20 chars used if longer + * + * $customer array + * id Customer ID - Must be unique for all customers + * fname Customer first name + * lname Customer last name + * addr1 Address Line 1 + * addr2 Address Line 2 + * city City + * state State + * country Country + * zip ZIP/Postal code + * phone Customer phone number + * email Customer E-Mail address + * + * return array + * gateway Name of this gateway + * status Numeric return status code + * 1 Approved + * 2 Bad data supplied + * 3 Communications failure + * 4 Bad response + * 5 Transaction not valid + * 6 Merchant account problem + * 7 Card declined + * statusText Short name of status + * authCode Authorization code - blank if card not accepted + * transId Authorize.Net Transaction ID for reference to this transaction + * refId Our reference ID for this request - this is also sent to Authorize.net for them to store with the transaction + * description Text description of result + * customerProfileId Customer Profile ID - Required to use stored payment profile for future charges + * paymentProfileId Payment Profile ID - Required to use stored payment profile for future charges + * profileStatus Status of stored profile request - True if stored profile information is returned + * profileStatusText Text descibing status of request to store payment profile + * + * Authorize.net test card numbers + * American Express 370000000000002 + * Discover 6011000000000012 + * Visa 4007000000027 + * 4012888818888 + * JCB 3088000000000017 + * Diners Club 38000000000006 + * Carte Blanche 38000000000006 + */ + public function processPayment($payment = false, $customer = false) + { + + $errorMsg = array(); + + // Set the transaction's refId using timestamp + $refId = 'ref' . time(); + + // Check for required data ***** NEED TO ADD TO THIS TO TEST ALL NEEDED FIELDS ***** + if (!is_array($payment) || !is_array($payment)) { + $resp = array( + 'gateway' => 'Authorize.Net', + 'status' => 2, + 'statusText' => 'Bad Data Supplied', + 'authCode' => '', + 'transId' => '', + 'refId' => $refId, + 'description' => 'The required payment and contact information was not supplied.' + ); + return $resp; + } + + // Check for specified test mode + switch ($this->account['test']) { + + // Production Mode + case 0: + break; + + // Local Test + case 1: + // Always return a card approval + $resp = array( + 'gateway' => 'Authorize.Net', + 'status' => 1, + 'statusText' => 'Card Approved', + 'authCode' => '12345678', + 'transId' => '0', + 'refId' => $refId, + 'description' => '(TESTMODE) Local Test - Card Approved' + ); + return $resp; + break; + + // Fail Test + case 2: + $resp = array( + 'gateway' => 'Authorize.Net', + 'status' => 7, + 'statusText' => 'Card Declined', + 'authCode' => '', + 'transId' => '', + 'refId' => $refId, + 'description' => '(TESTMODE) Local Test - Card Declined' + ); + return $resp; + break; + + // Online Test + case 3: + // Force Use of Authorize.net SANDBOX + $this->account['environment'] = 'SANDBOX'; + break; + + // Invalid test setting + default: + $resp = array( + 'gateway' => 'Authorize.Net', + 'status' => 2, + 'statusText' => 'Bad data supplied', + 'authCode' => '', + 'transId' => '', + 'refId' => $refId, + 'description' => 'Invalid test mode supplied - No transaction attempted' + ); + return $resp; + break; + + } + + // Test for certain required data or data content issues + if (isset($customer['id']) && trim($customer['id']) != '') { + if (strlen($customer['id']) > 20 ) { + $errorMsg[] = 'Customer ID is too long - maximum 20 characters'; + } + } + if (!isset($payment['name']) || trim($payment['name']) == '') { + $errorMsg[] = 'Required Vendor Name not provided'; + } + if (!isset($payment['transOpt']) || !in_array($payment['transOpt'], array(0,1,2))) { + $errorMsg[] = 'Invalid transaction option specified'; + } else { + + switch ($payment['transOpt']) { + + case 0: // Charge Card Only + case 1: // Charge Card and save as profile + echo "AASDASD"; + + if (!isset($customer['fname']) || trim($customer['fname']) == '') { + $errorMsg[] = 'Required Customer First Name not provided'; + } + if (!isset($customer['lname']) || trim($customer['lname']) == '') { + $errorMsg[] = 'Required Customer Last Name not provided'; + } + if (!isset($customer['addr1']) || trim($customer['addr1']) == '') { + $errorMsg[] = 'Required Customer Address Line 1 not provided'; + } + if (!isset($customer['city']) || trim($customer['city']) == '') { + $errorMsg[] = 'Required Customer City not provided'; + } + if (!isset($customer['state']) || trim($customer['state']) == '') { + $errorMsg[] = 'Required Customer State not provided'; + } + if (!isset($customer['zip']) || trim($customer['zip']) == '') { + $errorMsg[] = 'Required Customer ZIP/Postal Code not provided'; + } + if (!isset($customer['country']) || trim($customer['country']) == '') { + $errorMsg[] = 'Required Customer Country not provided'; + } + if (!isset($payment['charge']) || (trim($payment['charge'])-0) <= 0) { + $errorMsg[] = 'Required Charge Amount not provided'; + } + if (!isset($payment['ccnumb']) || trim($payment['ccnumb']) == '') { + $errorMsg[] = 'Required Credit Card Number not provided'; + } + if (!isset($payment['ccexp']) || trim($payment['ccexp']) == '') { + $errorMsg[] = 'Required Credit Card Expiration not provided'; + } + if (!isset($payment['cccode']) || trim($payment['cccode']) == '') { + $errorMsg[] = 'Required Credit Card Security Code not provided'; + } + + break; + + case 2: // Charge using profile + + if (!isset($payment['customerProfileId']) || trim($payment['customerProfileId']) == '') { + $errorMsg[] = 'Required Customer Profile ID for charging a stored profile not provided'; + } + if (!isset($payment['paymentProfileId']) || trim($payment['paymentProfileId']) == '') { + $errorMsg[] = 'Required Payment Profile ID for charging a stored profile not provided'; + } + + break; + + } + + } + + // If there's a problem with submitted information + if (count($errorMsg) > 0) { + $resp = array( + 'gateway' => 'Authorize.Net', + 'status' => 2, + 'statusText' => 'Bad data supplied', + 'authCode' => '', + 'transId' => '', + 'refId' => $refId, + 'description' => implode(', ', $errorMsg) + ); + return $resp; + } + + // Create order information + $order = new AnetAPI\OrderType(); + if (isset($payment['invoice']) && trim($payment['invoice']) != '') { + $order->setInvoiceNumber(substr($payment['invoice'], -20)); + } + $order->setDescription($payment['name']); + + // Set the customer's identifying information + $customerIdent = new AnetAPI\CustomerDataType(); + if (isset($customer['email']) && trim($customer['email']) != '') { + $customerIdent->setEmail($customer['email']); + } + // $customerIdentData->setType("individual"); // "individual" or "business" - Not required + if (isset($customer['id']) && trim($customer['id']) != '') { + $customerIdent->setId($customer['id']); + } + + // Create a transaction type + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType("authCaptureTransaction"); + $transactionRequestType->setAmount($payment['charge']); + $transactionRequestType->setOrder($order); + $transactionRequestType->setCustomer($customerIdent); + + // If charge using a stored profile + if (isset($payment['transOpt']) && $payment['transOpt'] == 2) { + + // Setup payment profile + $paymentProfile = new AnetAPI\PaymentProfileType(); + $paymentProfile->setPaymentProfileId($payment['paymentProfileId']); + + // Specify profile to charge + $profileToCharge = new AnetAPI\CustomerProfilePaymentType(); + $profileToCharge->setCustomerProfileId($payment['customerProfileId']); + $profileToCharge->setPaymentProfile($paymentProfile); + + // Set transaction request type to charge profile + $transactionRequestType->setProfile($profileToCharge); + + + // Else, charge using new card data + } else { + + // Set the customer's Bill To address + $customerAddress = new AnetAPI\CustomerAddressType(); + $customerAddress->setFirstName($customer['fname']); + $customerAddress->setLastName($customer['lname']); + $customerAddress->setAddress($customer['addr1'].($customer['addr2']!=''?', '.$customer['addr2']:'')); + $customerAddress->setCity($customer['city']); + $customerAddress->setState($customer['state']); + $customerAddress->setZip($customer['zip']); + $customerAddress->setCountry($customer['country']); + // $customerAddress->setCompany(''); + + // Create the payment data for a credit card + $creditCard = new AnetAPI\CreditCardType(); + $creditCard->setCardNumber($payment['ccnumb']); + $creditCard->setExpirationDate($payment['ccexp']); + $creditCard->setCardCode($payment['cccode']); + + // Create Payment Type + $paymentType = new AnetAPI\PaymentType(); + $paymentType->setCreditCard($creditCard); + + // Set transaction request type to charge card payment type + $transactionRequestType->setBillTo($customerAddress); + $transactionRequestType->setPayment($paymentType); + + } + + // Payment reference ID (up to 20 characters) for this request - Possibly supplied + $request = new AnetAPI\CreateTransactionRequest(); + $request->setMerchantAuthentication($this->merchantAuthentication); + $request->setRefId($refId); + $request->setTransactionRequest($transactionRequestType); + + // echo "TRANSACTION REQUEST
".print_r($request,1)."
"; + + // Send request to Authorize.net - ANetEvironment = CUSTOM, SANDBOX, PRODUCTION + $controller = new AnetController\CreateTransactionController($request); + + // Select processing environment + switch ($this->account['environment']) { + + case 'SANDBOX': + $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); + break; + + case 'PRODUCTION': + $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::PRODUCTION); + break; + + default: + die('Authorise.Net Payment Gateway: Serious error - processing environment not specified in calling code!'); + break; + + } + + // echo "TRANSACTION RESPONSE
".print_r($response,1)."
"; + + // Assume the worst + $respCode = 0; + $respDescr = 'Unable to communicate with credit card processor.'; + + // If we have some response + if ($response != null) { + + // And it if was acted upon and we got a good response + if ($response->getMessages()->getResultCode() != null) { + + // Get Transaction Response + $transResponse = $response->getTransactionResponse(); + + // If there's a transaction response + if ($transResponse != null) { + + // Get response code (see status codes below) + $respCode = $transResponse->getResponseCode(); + + + // If there's any messages + if ($transResponse->getMessages() != null) { + + // Get any message + $respDescr = $transResponse->getMessages()[0]->getDescription(); + + } else { + + $respDescr = "Transaction failed"; + + if ($transResponse->getErrors() != null) { + $errCode = $transResponse->getErrors()[0]->getErrorCode(); + $errMsg = $transResponse->getErrors()[0]->getErrorText(); + $respDescr .= ": $errMsg ($errCode)"; + } else { + $errCode = $response->getMessages()->getMessage()[0]->getCode(); + $errMsg = $response->getMessages()->getMessage()[0]->getText(); + $respDescr .= ": $errMsg ($errCode)"; + } + + } + + // If there was no transaction response data then check for a submission data error + } else { + $errMsg = $response->getMessages()->getMessage()[0]->getText(); + $respDescr = "Transaction failed: $errMsg"; + } + } + + } + + /* + * Possible returned Authorize.net status codes + * 1 = approved + * 2 = declined + * 3 = error + * 4 = held for review + */ + + // Determine response method + switch ($respCode) { + + // Approved + case 1: + $resp = array( + 'gateway' => 'Authorize.Net', + 'status' => 1, + 'statusText' => 'Card Approved', + 'authCode' => $transResponse->getAuthCode(), + 'transId' => $transResponse->getTransId(), + 'refId' => $refId, + 'description' => $respDescr + ); + break; + + // Declined + + case 2: + $resp = array( + 'gateway' => 'Authorize.Net', + 'status' => 7, + 'statusText' => 'Card Declined', + 'authCode' => '', + 'transId' => '', + 'refId' => $refId, + 'description' => $respDescr + ); + break; + + // Error + case 3: + $resp = array( + 'gateway' => 'Authorize.Net', + 'status' => 3, + 'statusText' => 'Transaction Error', + 'authCode' => '', + 'transId' => '', + 'refId' => $refId, + 'description' => $respDescr + ); + break; + + // Held for Review + case 4: + $resp = array( + 'gateway' => 'Authorize.Net', + 'status' => 7, + 'statusText' => 'Held for review', + 'authCode' => '', + 'transId' => '', + 'refId' => $refId, + 'description' => $response->response_reason_text + ); + break; + + // Any other response code + default: + $resp = array( + 'gateway' => 'Authorize.Net', + 'status' => 4, + 'statusText' => 'Bad Response', + 'authCode' => '', + 'transId' => '', + 'refId' => $refId, + 'description' => $respDescr + ); + break; + + } + + // echo "Response before profile
".print_r($resp,1)."
"; + + // Check if request to create a customer profile using this transaction + if (isset($payment['transOpt']) && $payment['transOpt'] == 1) { + + + // If the transaction was not successful + if ($resp['status'] != 1) { + $resp['profileId'] = false; + $resp['profileStatus'] = false; + $resp['profileStatusText'] = 'No profile, transaction had failed'; + + // Otherwise, if there's no TRansaction ID + } elseif (trim($resp['transId']) == '') { + $resp['profileId'] = false; + $resp['profileStatus'] = false; + $resp['profileStatusText'] = 'No profile, no transaction id available'; + + // Otherwise, try to create a customer profile + } else { + + $profileResponse = $this->createProfileFromTrans($resp['transId'], $customer); + + // Add profile request result to transaction result + $resp = array_merge($resp, $profileResponse); + + } + + } + + return $resp; + + } + + /** + * Create Customer Profile (saved card info) from a Transaction + * + * The following fields are required in the $customer array. + * This array can be the same as supplied to processPayment() with + * the ID added. + * + * id Customer ID - could be customer type plus record number + * email Customer E-Mail address + * + * Return array + * + * customerProfileId Profile ID for created customer profile (if successful) + * paymentProfileId Profile ID for payment (if successful) + * status True if successful + * statusText Explanation of result + * + * @param $transId string Transaction ID from a completed transaction + * @param $customer array Custoemr information + * + * @return array + * + */ + public function createProfileFromTrans($transId = false, $customer = false) + { + + $resp = false; + + // Set the transaction's refId using timestamp + $refId = 'ref' . time(); + + $errorMsg = array(); + + // Check required input + if ($transId === false || trim($transId) == '' ) { + $errorMsg[] = 'Required Transaction ID was not supplied'; + } + if (!$customer || !is_array($customer) ) { + $errorMsg[] = 'Required customer information was not supplied'; + } + if (!isset($customer['id']) || trim($customer['id']) == '' ) { +// $errorMsg[] = 'Required Customer ID was not supplied'; + } + if (strlen($customer['id']) > 20 ) { + $errorMsg[] = 'Customer ID is too long - maximum 20 characters'; + } + if (!isset($customer['email']) || trim($customer['email']) == '' ) { + $errorMsg[] = 'Required Customer E-Mail address was not supplied'; + } + + // If there's error messages + if (count($errorMsg) > 0) { + $resp = array( + 'profileId' => false, + 'profileStatus' => false, + 'profileStatusText' => implode(', ', $errorMsg) + ); + return $resp; + } + + // Build customer profile - only using customerId and E + $customerProfile = new AnetAPI\CustomerProfileBaseType(); + $customerProfile->setMerchantCustomerId($customer['id']); + $customerProfile->setEmail($customer['email']); + $customerProfile->setDescription($customer['fname'].' '.$customer['lname'].', '.$customer['city'].' '.$customer['state'].' '.$customer['zip'].' '.$customer['phone']); + + $request = new AnetAPI\CreateCustomerProfileFromTransactionRequest(); + $request->setMerchantAuthentication($this->merchantAuthentication); + $request->setTransId($transId); + $request->setCustomer($customerProfile); + $request->setRefId($refId); + + // echo "PROFILE REQUEST
".print_r($request,1)."
"; + + $controller = new AnetController\CreateCustomerProfileFromTransactionController($request); + + // Select processing environment + switch ($this->account['environment']) { + + case 'SANDBOX': + $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); + break; + + case 'PRODUCTION': + $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::PRODUCTION); + break; + + default: + die('Authorise.Net Payment Gateway: Serious error - processing environment not specified'); + break; + + } + + // echo "PROFILE RESPONSE
".print_r($response,1)."
"; + + if ($response != null) { + + $errorMessages = $response->getMessages()->getMessage(); + + if ($response->getMessages()->getResultCode() == "Ok") { + $resp = array( + 'customerProfileId' => $response->getCustomerProfileId(), + 'paymentProfileId' => $response->getCustomerPaymentProfileIdList()[0], + 'profileStatus' => true, + 'profileStatusText' => $errorMessages[0]->getCode().' '.$errorMessages[0]->getText() + ); + return $resp; + + } else { + $errorMessages = $response->getMessages()->getMessage(); + $resp = array( + 'customerProfileId' => false, + 'paymentProfileId' => false, + 'profileStatus' => false, + 'profileStatusText' => $errorMessages[0]->getCode().' '.$errorMessages[0]->getText() + ); + return $resp; + } + + } + + // No valid response + $resp = array( + 'profileId' => false, + 'profileStatus' => false, + 'profileStatusText' => 'bad response' + ); + return $resp; + + + } + +} diff --git a/lib/paymentProcessors/Authorize.Net/sdk-php-master/.gitignore b/lib/paymentProcessors/Authorize.Net/sdk-php-master/.gitignore new file mode 100644 index 00000000..3dfe0af1 --- /dev/null +++ b/lib/paymentProcessors/Authorize.Net/sdk-php-master/.gitignore @@ -0,0 +1,12 @@ +*.DS_Store +composer.lock +vendor +phpunit.xml +tests/log +build +phplog + +# Ignore eclipse project files +.buildpath +.project +.settings diff --git a/lib/paymentProcessors/Authorize.Net/sdk-php-master/.gitmodules b/lib/paymentProcessors/Authorize.Net/sdk-php-master/.gitmodules new file mode 100644 index 00000000..fc7da8d4 --- /dev/null +++ b/lib/paymentProcessors/Authorize.Net/sdk-php-master/.gitmodules @@ -0,0 +1,4 @@ +[submodule "sample-code-php"] + path = sample-code-php + url = https://github.com/AuthorizeNet/sample-code-php.git + branch = master diff --git a/lib/paymentProcessors/Authorize.Net/sdk-php-master/.scrutinizer.yml b/lib/paymentProcessors/Authorize.Net/sdk-php-master/.scrutinizer.yml new file mode 100644 index 00000000..761daa42 --- /dev/null +++ b/lib/paymentProcessors/Authorize.Net/sdk-php-master/.scrutinizer.yml @@ -0,0 +1,17 @@ +checks: + php: + code_rating: true + duplication: true + +tools: + php_mess_detector: true + php_code_sniffer: true + sensiolabs_security_checker: true + php_cpd: true + php_loc: true + php_pdepend: true + external_code_coverage: + timeout: 1500 #15 min +filter: + paths: + - lib/* \ No newline at end of file diff --git a/lib/paymentProcessors/Authorize.Net/sdk-php-master/.travis.yml b/lib/paymentProcessors/Authorize.Net/sdk-php-master/.travis.yml new file mode 100644 index 00000000..5896cf1e --- /dev/null +++ b/lib/paymentProcessors/Authorize.Net/sdk-php-master/.travis.yml @@ -0,0 +1,35 @@ +language: php + +sudo: false + +env: + - TEST_SUITE=samples + +php: + - 5.6 + - 7.0 + - 7.1 + +before_install: + # execute all of the commands which need to be executed + # before installing dependencies + - composer validate # make sure that our composer.json file is valid for packaging + +install: + # install all of the dependencies we need here + - pecl install xmldiff + - composer install --prefer-dist + +before_script: + # execute all of the commands which need to be executed + # before running actual tests + - git submodule update --remote --recursive + +script: + # execute all of the tests or other commands to determine + # whether the build will pass or fail + - if [[ "$TEST_SUITE" == "samples" ]]; then phpenv config-rm xdebug.ini; cp -R lib sample-code-php/; cp -R vendor sample-code-php/; cd sample-code-php; vendor/phpunit/phpunit/phpunit test-runner.php .; cat testslog; fi + +after_script: +# - if [[ "$TEST_SUITE" == "coverage" ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi +# - if [[ "$TEST_SUITE" == "coverage" ]]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi diff --git a/lib/paymentProcessors/Authorize.Net/sdk-php-master/composer.json b/lib/paymentProcessors/Authorize.Net/sdk-php-master/composer.json new file mode 100644 index 00000000..731faaa7 --- /dev/null +++ b/lib/paymentProcessors/Authorize.Net/sdk-php-master/composer.json @@ -0,0 +1,7 @@ +{ + "require": { + "php": ">=5.6", + "authorizenet/authorizenet": "~1.9.6" + } +} + diff --git a/lib/paymentProcessors/MerchantSolutions/paymentGateway.php b/lib/paymentProcessors/MerchantSolutions/paymentGateway.php new file mode 100644 index 00000000..6968fe8a --- /dev/null +++ b/lib/paymentProcessors/MerchantSolutions/paymentGateway.php @@ -0,0 +1,349 @@ + + * @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 + * @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 index 00000000..5da5a520 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 index 00000000..1161fca2 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paymentGateway.php @@ -0,0 +1,591 @@ + + * @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 + * @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 + '__construct() - Existing Instance

' + .'Account Data:
' + .'

'.print_r($account,1).'
' + .'Access:
' + .'
'.print_r($access,1)."
" + .'Transaction:
' + .'
'.print_r($trans,1)."
"; + } + + + // 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 + '__construct() - New Instance

' + .'Account Data:
' + .'

'.print_r($account,1).'
' + .'Headers:
' + .'
'.print_r($headers,1)."
" + .'Request:
' + .'
'.print_r($request,1)."
"; + } + + // 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 "

ERROR: payment item incomplete

".print_r($item,1)."
"; + } + + // 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 'processPayment()

' + .'Headers:
' + .'

'.print_r($headers,1)."
" + .'Request:
' + .'
'.$request.'
'; + } + + // 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 'executePayment()

' + .'Headers:
' + .'

'.print_r($headers,1)."
" + .'Request:
' + .'
'.$request.'
'; + } + + // 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 '

sendRequest():
URL = '.$url.'
Headers:

'
+    			.print_r($headers,1).'
Request:
'.print_r($request,1).'
'; + } + + // 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:
' + .'
'.print_r($response,1).'
'; + } + + // 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."

"; + } + + } + + // 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 index 00000000..90f55b5f --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/.coveralls.yml @@ -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 index 00000000..e9c37ab1 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/.gitignore @@ -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 index 00000000..91cb2292 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/.travis.yml @@ -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 index 00000000..0c6c6f21 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/CHANGELOG.md @@ -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 index 00000000..ad030e50 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/LICENSE.txt @@ -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 index 00000000..2dcdc6d4 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/README.md @@ -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('', '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 index 00000000..d4e2ad4b --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/build.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + Composer is installed + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 index 00000000..20d7592f --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/composer.json @@ -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 index 00000000..fa9300e5 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Address.php @@ -0,0 +1,167 @@ +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 index 00000000..8c7cfe29 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Amount.php @@ -0,0 +1,61 @@ +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 index 00000000..9fc4b6dd --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Authorization.php @@ -0,0 +1,299 @@ +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 index 00000000..773f9526 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Capture.php @@ -0,0 +1,270 @@ +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 index 00000000..cd0ee91c --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/CreditCard.php @@ -0,0 +1,416 @@ +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 index 00000000..4251e62f --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/CreditCardHistory.php @@ -0,0 +1,97 @@ +{"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 index 00000000..13430ddc --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/CreditCardToken.php @@ -0,0 +1,183 @@ +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 index 00000000..ab383675 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Details.php @@ -0,0 +1,79 @@ +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 index 00000000..68006754 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/FundingInstrument.php @@ -0,0 +1,77 @@ +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 index 00000000..a09ee928 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/HyperSchema.php @@ -0,0 +1,116 @@ +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 index 00000000..4a40632c --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Item.php @@ -0,0 +1,97 @@ +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 index 00000000..ea38da66 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/ItemList.php @@ -0,0 +1,61 @@ +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 index 00000000..9cbd85e8 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Links.php @@ -0,0 +1,115 @@ +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 index 00000000..d0ccea3e --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Payee.php @@ -0,0 +1,78 @@ +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 index 00000000..d21d238c --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Payer.php @@ -0,0 +1,114 @@ +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 index 00000000..a9ff5963 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/PayerInfo.php @@ -0,0 +1,183 @@ +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 index 00000000..cf223f05 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Payment.php @@ -0,0 +1,299 @@ +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 index 00000000..b7048ebf --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/PaymentExecution.php @@ -0,0 +1,61 @@ +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 index 00000000..e9f28af1 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/PaymentHistory.php @@ -0,0 +1,79 @@ +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 index 00000000..c954b496 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/RedirectUrls.php @@ -0,0 +1,77 @@ +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 index 00000000..095200a1 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Refund.php @@ -0,0 +1,251 @@ +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 index 00000000..7e97776c --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/RelatedResources.php @@ -0,0 +1,79 @@ +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 index 00000000..5fb1284e --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Sale.php @@ -0,0 +1,235 @@ +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 index 00000000..a7f4de94 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/ShippingAddress.php @@ -0,0 +1,42 @@ +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 index 00000000..d8420aa0 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Transaction.php @@ -0,0 +1,152 @@ +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 index 00000000..22198370 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Api/Transactions.php @@ -0,0 +1,25 @@ +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 index 00000000..8b4d4e6b --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Auth/OAuthTokenCredential.php @@ -0,0 +1,137 @@ +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 index 00000000..4250b5ea --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Rest/ApiContext.php @@ -0,0 +1,78 @@ +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 index 00000000..395586cd --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/lib/PayPal/Rest/IResource.php @@ -0,0 +1,7 @@ +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 index 00000000..d8063ef1 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/phpunit.xml @@ -0,0 +1,29 @@ + + + + + + tests + + + + + + + + + + ./lib + + + + + \ 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 index 00000000..ec271c98 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/AddressTest.php @@ -0,0 +1,54 @@ +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 index 00000000..7f24e7bb --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/AmountTest.php @@ -0,0 +1,45 @@ +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 index 00000000..63ba8cb8 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/AuthorizationTest.php @@ -0,0 +1,156 @@ +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 index 00000000..a1162fde --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/CaptureTest.php @@ -0,0 +1,87 @@ +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 index 00000000..a7f1b532 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/CreditCardHistoryTest.php @@ -0,0 +1,72 @@ +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 index 00000000..27896fef --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/CreditCardTest.php @@ -0,0 +1,94 @@ +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 index 00000000..d1f8db97 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/CreditCardTokenTest.php @@ -0,0 +1,38 @@ +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 index 00000000..ae1cba91 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/DetailsTest.php @@ -0,0 +1,45 @@ +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 index 00000000..cb420d63 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/FundingInstrumentTest.php @@ -0,0 +1,36 @@ +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 index 00000000..fe5f8709 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/ItemListTest.php @@ -0,0 +1,46 @@ +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 index 00000000..59be2880 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/ItemTest.php @@ -0,0 +1,46 @@ +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 index 00000000..68da69a8 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/LinksTest.php @@ -0,0 +1,40 @@ +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 index 00000000..ea9469f2 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/PayeeTest.php @@ -0,0 +1,44 @@ +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 index 00000000..b1f5858c --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/PayerInfoTest.php @@ -0,0 +1,50 @@ +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 index 00000000..7568a3c5 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/PayerTest.php @@ -0,0 +1,45 @@ +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 index 00000000..577d2828 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/PaymentHistoryTest.php @@ -0,0 +1,39 @@ +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 index 00000000..2bf97955 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/PaymentTest.php @@ -0,0 +1,78 @@ +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 index 00000000..657e1676 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/RefundTest.php @@ -0,0 +1,54 @@ +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 index 00000000..c9773958 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/RelatedResourcesTest.php @@ -0,0 +1,35 @@ +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 index 00000000..b4c69728 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/SaleTest.php @@ -0,0 +1,73 @@ +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 index 00000000..6ca8b93a --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/ShippingAddressTest.php @@ -0,0 +1,56 @@ +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 index 00000000..f2e0ba33 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Api/TransactionTest.php @@ -0,0 +1,49 @@ +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 index 00000000..5dfe13ef --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Auth/OAuthTokenCredentialTest.php @@ -0,0 +1,35 @@ +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 index 00000000..34708473 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/ArrayClass.php @@ -0,0 +1,29 @@ +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 index 00000000..824b6849 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/ArrayUtilTest.php @@ -0,0 +1,21 @@ +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 index 00000000..a9a294b6 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/ChildClass.php @@ -0,0 +1,6 @@ +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 index 00000000..06e5e00a --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/NestedClass.php @@ -0,0 +1,27 @@ +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 index 00000000..86732b13 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/SimpleClass.php @@ -0,0 +1,19 @@ +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 index 00000000..d9453746 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Common/UserAgentTest.php @@ -0,0 +1,26 @@ +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 index 00000000..7c424e33 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/PayPal/Test/Constants.php @@ -0,0 +1,7 @@ +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 index 00000000..d2495968 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/bootstrap.php @@ -0,0 +1,6 @@ +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 index 00000000..f73b92a3 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/rest-api-sdk-php/tests/sdk_config.ini @@ -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 index 00000000..0db54317 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/.gitignore @@ -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 index 00000000..bfa023a6 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/CHANGELOG.md @@ -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 index 00000000..ad030e50 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/LICENSE.txt @@ -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 index 00000000..035c0477 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/README.md @@ -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 index 00000000..0496420d --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/build.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + 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 index 00000000..961fb470 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/composer.json @@ -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 index 00000000..da994c41 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/IPPCredential.php @@ -0,0 +1,23 @@ +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 index 00000000..f019dfaf --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/IPPThirdPartyAuthorization.php @@ -0,0 +1,11 @@ +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 index 00000000..c9f08333 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/MockOAuthDataStore.php @@ -0,0 +1,54 @@ +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 index 00000000..95bb48ed --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthConsumer.php @@ -0,0 +1,17 @@ +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 index 00000000..2133acc7 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthDataStore.php @@ -0,0 +1,27 @@ +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 index 00000000..48c3257d --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthServer.php @@ -0,0 +1,223 @@ +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 index 00000000..2e557d90 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthSignatureMethod.php @@ -0,0 +1,38 @@ +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 index 00000000..2c35c976 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthSignatureMethodHmacSha1.php @@ -0,0 +1,30 @@ +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 index 00000000..c29ebf3c --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthSignatureMethodPLAINTEXT.php @@ -0,0 +1,34 @@ +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 index 00000000..8dbcc5e1 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthSignatureMethodRsaSha1.php @@ -0,0 +1,68 @@ +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 index 00000000..50563e79 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthToken.php @@ -0,0 +1,31 @@ +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 index 00000000..8c7d34c1 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Oauth/OAuthUtil.php @@ -0,0 +1,169 @@ + $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 index 00000000..4cee501c --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Openid/PPOpenIdAddress.php @@ -0,0 +1,95 @@ +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 index 00000000..1c5e051e --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Openid/PPOpenIdError.php @@ -0,0 +1,61 @@ +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 index 00000000..ba76f0a9 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Openid/PPOpenIdSession.php @@ -0,0 +1,79 @@ +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 index 00000000..cdb90d03 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Openid/PPOpenIdTokeninfo.php @@ -0,0 +1,181 @@ +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 index 00000000..29ff51f4 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/Openid/PPOpenIdUserinfo.php @@ -0,0 +1,400 @@ +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 index 00000000..a33ab969 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/PPCertificateCredential.php @@ -0,0 +1,103 @@ +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 index 00000000..d1e6f496 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/PPSignatureCredential.php @@ -0,0 +1,69 @@ +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 index 00000000..27f1f8f8 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/PPSubjectAuthorization.php @@ -0,0 +1,26 @@ +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 index 00000000..d9a80e7d --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Auth/PPTokenAuthorization.php @@ -0,0 +1,38 @@ +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 index 00000000..5affd24d --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Common/PPApiContext.php @@ -0,0 +1,33 @@ +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 index 00000000..a93fe19e --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Common/PPArrayUtil.php @@ -0,0 +1,18 @@ + $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 index 00000000..ec4ae909 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Common/PPModel.php @@ -0,0 +1,84 @@ +_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 index 00000000..83bfd8f8 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Common/PPReflectionUtil.php @@ -0,0 +1,74 @@ +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 index 00000000..551c93bd --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Common/PPUserAgent.php @@ -0,0 +1,41 @@ +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 index 00000000..fc6de3fa --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPBaseService.php @@ -0,0 +1,87 @@ +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 index 00000000..f03560e8 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPConfigManager.php @@ -0,0 +1,123 @@ + "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 index 00000000..0b4a93c8 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPConnectionManager.php @@ -0,0 +1,42 @@ +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 index 00000000..da09c921 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPConstants.php @@ -0,0 +1,19 @@ +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 index 00000000..a8523bcf --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPHttpConfig.php @@ -0,0 +1,158 @@ + 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 index 00000000..2c395203 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPHttpConnection.php @@ -0,0 +1,112 @@ +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 index 00000000..cc817e3e --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPLoggingManager.php @@ -0,0 +1,77 @@ +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 index 00000000..82be10ab --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPMessage.php @@ -0,0 +1,117 @@ + $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 index 00000000..22e7f699 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPRequest.php @@ -0,0 +1,73 @@ +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 index 00000000..3ef6d8b7 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPUtils.php @@ -0,0 +1,397 @@ + $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 , + * 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 index 00000000..123bf4ba --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/PPXmlMessage.php @@ -0,0 +1,186 @@ +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 . ''; + } + + + + /** + * @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 index 00000000..1202c203 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Core/cacert.pem @@ -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 index 00000000..e10ea338 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Exception/OAuthException.php @@ -0,0 +1,8 @@ + \ 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 index 00000000..60dfa571 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Exception/PPConfigurationException.php @@ -0,0 +1,8 @@ +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 index 00000000..c4921732 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Exception/PPInvalidCredentialException.php @@ -0,0 +1,17 @@ +getLine().' in '.$this->getFile() + .': '.$this->getMessage().''; + 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 index 00000000..a33ae8ff --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Exception/PPMissingCredentialException.php @@ -0,0 +1,18 @@ +getLine().' in '.$this->getFile() + .': '.$this->getMessage().''; + + 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 index 00000000..616db009 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Exception/PPTransformerException.php @@ -0,0 +1,17 @@ +getLine().' in '.$this->getFile() + .': '.$this->getMessage().''; + + 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 index 00000000..9c26f461 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Formatter/FormatterFactory.php @@ -0,0 +1,16 @@ +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 index 00000000..1c2920b3 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Formatter/PPSOAPFormatter.php @@ -0,0 +1,28 @@ +getBindingInfo('namespace') != null ) ? $request->getBindingInfo('namespace') : ""; + $soapEnvelope = '"; + + $soapHeader = ''; + if($request->getBindingInfo('securityHeader') != null) { + $soapHeader .= $request->getBindingInfo('securityHeader'); + } + $soapHeader .= ''; + + $soapBody = ''; + $soapBody .= $request->getRequestObject()->toXMLString(); + $soapBody .= ''; + + return $soapEnvelope . $soapHeader . $soapBody . ''; + } + + 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 index 00000000..42b42167 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/IPPHandler.php @@ -0,0 +1,10 @@ +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 index 00000000..4b24cba1 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPCertificateAuthHandler.php @@ -0,0 +1,46 @@ +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 = ''; + } else { + $securityHeader = ''; + $securityHeader .= '' . $credential->getUserName() . ''; + $securityHeader .= '' . $credential->getPassword() . ''; + if($thirdPartyAuth && $thirdPartyAuth instanceof PPSubjectAuthorization) { + $securityHeader .= '' . $thirdPartyAuth->getSubject() . ''; + } + $securityHeader .= ''; + $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 index 00000000..51c1e0ed --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPGenericServiceHandler.php @@ -0,0 +1,18 @@ +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 index 00000000..8f563661 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPMerchantServiceHandler.php @@ -0,0 +1,64 @@ +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 index 00000000..b66ec5ee --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPOpenIdHandler.php @@ -0,0 +1,51 @@ +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 index 00000000..7b3c50ee --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPPlatformServiceHandler.php @@ -0,0 +1,47 @@ +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 index 00000000..428d5e4d --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Handler/PPSignatureAuthHandler.php @@ -0,0 +1,48 @@ +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' , ''); + } else { + $securityHeader = ''; + $securityHeader .= '' . $credential->getUserName() . ''; + $securityHeader .= '' . $credential->getPassword() . ''; + $securityHeader .= '' . $credential->getSignature() . ''; + if($thirdPartyAuth && $thirdPartyAuth instanceof PPSubjectAuthorization) { + $securityHeader .= '' . $thirdPartyAuth->getSubject() . ''; + } + $securityHeader .= ''; + $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 index 00000000..ffb23831 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/IPN/PPIPNMessage.php @@ -0,0 +1,172 @@ +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 index 00000000..cb8910e6 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/lib/PayPal/Transport/PPRestCall.php @@ -0,0 +1,50 @@ +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 index 00000000..87475c46 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/Openid/PPOpenIdAddressTest.php @@ -0,0 +1,39 @@ +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 index 00000000..46e84d15 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/Openid/PPOpenIdSessionTest.php @@ -0,0 +1,84 @@ +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 index 00000000..999145d2 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/Openid/PPOpenIdTokeninfoTest.php @@ -0,0 +1,41 @@ +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 index 00000000..330d843b --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/Openid/PPOpenIdUserinfoTest.php @@ -0,0 +1,46 @@ +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 index 00000000..4d7cca94 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPAPIServiceTest.php @@ -0,0 +1,72 @@ + '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 index 00000000..0b2b5926 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPBaseServiceTest.php @@ -0,0 +1,41 @@ +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 index 00000000..dd5d70f0 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPBootStrap.php @@ -0,0 +1,11 @@ +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 index 00000000..eda5d38b --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPConfigManagerTest.php @@ -0,0 +1,55 @@ +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 index 00000000..420cd116 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPConfigurationExceptionTest.php @@ -0,0 +1,37 @@ +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 index 00000000..d01550a6 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPConnectionExceptionTest.php @@ -0,0 +1,48 @@ +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 index 00000000..999c4644 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPConnectionManagerTest.php @@ -0,0 +1,76 @@ + '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 index 00000000..81cf5c8f --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPCredentialManagerTest.php @@ -0,0 +1,104 @@ + '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 index 00000000..9da50075 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPIPNMessageTest.php @@ -0,0 +1,58 @@ +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 index 00000000..7ed7c5a9 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPInvalidCredentialExceptionTest.php @@ -0,0 +1,40 @@ +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 index 00000000..5285ed84 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPLoggingManagerTest.php @@ -0,0 +1,64 @@ +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 index 00000000..8f29a7f2 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPMessageTest.php @@ -0,0 +1,441 @@ +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 index 00000000..ec8e7521 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPMissingCredentialExceptionTest.php @@ -0,0 +1,41 @@ +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 index 00000000..2d48a9dd --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPSignatureCredentialTest.php @@ -0,0 +1,103 @@ +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 index 00000000..7ad664d9 --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/PPUtilsTest.php @@ -0,0 +1,63 @@ +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 index 00000000..37e11b4a --- /dev/null +++ b/lib/paymentProcessors/PayPal/paypal-API-Not_sure_if_will_use/sdk-core-php/tests/sdk_config.ini @@ -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 index 00000000..6ee2f988 --- /dev/null +++ b/lib/paymentProcessors/PayPal/test.php @@ -0,0 +1,111 @@ + '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.

"; + + // Save Payer ID + $_SESSION['payerID'] = $_REQUEST['PayerID']; // NEED TO FILTER THIS FOR PRODUCTION + + // Create PayPal object with existing access object from the session + $PayPal = new PaymentGateway($account, $_SESSION['access'], $_SESSION['trans']); + + // Execute the PayPal payment + $r = $PayPal->executePayment($_SESSION['payerID']); + + echo "Payment Executed Successfully

"; + + exit; + + break; + + case 'Canceled': + + echo "Payment Cancelled

"; + exit; + + break; +} + +// Create the PayPal object (note no previous access object) +$PayPal = new PaymentGateway($account, false, false); + +// Was there an error? +if (!$PayPal->status) { + echo "Received an error: ".$PayPal->error; + exit; +} + +// Store access information +$_SESSION['access'] = $PayPal->access; + +// Try to enter Payment +$PayPal->processPayment($payment, $contact); + +// Was there an error? +if (!$PayPal->status) { + echo "Received an error: ".$PayPal->error; + exit; +} + +// Store Transaction data to session +$_SESSION['trans'] = $PayPal->trans; + +// Show user link to PayPal for them to approve payment +// Note that uses a target to create a new window/tab +echo 'Proceed to PayPal'; + +?> \ No newline at end of file diff --git a/lib/paymentProcessors/TestByCardNumber/paymentGateway.php b/lib/paymentProcessors/TestByCardNumber/paymentGateway.php new file mode 100644 index 00000000..9098c5fc --- /dev/null +++ b/lib/paymentProcessors/TestByCardNumber/paymentGateway.php @@ -0,0 +1,190 @@ + + * @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 + * @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 index 00000000..2dd38a87 --- /dev/null +++ b/lib/paymentProcessors/TestGood/paymentGateway.php @@ -0,0 +1,96 @@ + + * @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 + * @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/paymentProcessorsTest.php b/lib/paymentProcessors/paymentProcessorsTest.php new file mode 100644 index 00000000..02263dc8 --- /dev/null +++ b/lib/paymentProcessors/paymentProcessorsTest.php @@ -0,0 +1,157 @@ + $accountLogin, // Required + 'key' => $accountKey, // Required + 'test' => $testMode, // Required + 'conf' => $customerConfirmation, // Required + 'email' => $vendorConfirmationEmail // Required if "conf" above is true +); + +// Create Payment Array - Required +$payment = array( + 'transOpt' => $transOption, // Required + 'name' => $vendorName, // Required + 'charge' => $charge, // Required + 'customerProfileId' => $customerProfileId, // Required for transOption = 2 + 'paymentProfileId' => $paymentProfileId, // Required for transOption = 2 + 'cctype' => $cardType, // Optional (depends on payment processor) + 'ccname' => $nameOnCard, // Not required for Authorize.net + 'ccnumb' => $cardNumber, // Required for transOption = 0 & 1 + 'ccexp' => $cardExp, // Required for transOption = 0 & 1 + 'cccode' => $cardCode, // Required for transOption = 0 & 1 + 'invoice' => $invoiceNumb // Required +); + +// Customer Information - Required for transOption = 0 & 1 +$customer = array( + 'id' => $custId, // Alphanumeric - Required if creating or using stored customer profile - must be unique to customer +// 'type' => $custType, // 'individual' or 'business' - not required + 'fname' => $custFname, // Required + 'lname' => $custLname, // Required + 'addr1' => $custAddr1, // Required + 'addr2' => $custAddr2, // Optional + 'city' => $custCity, // Required + 'state' => $custState, // Required + 'country' => $custCountry, // Required + 'zip' => $custZip, // Required + 'phone' => $custPhone, // Required + 'email' => $custEmail // Required +); + +// ***** End of arrays required for calls to payment processor + + +// Instatiate the Payment Processor Class +require_once $paymentProcessor.'/paymentGateway.php'; +$CcProcessor = new PaymentGateway($account); + +// Now try to run the card processor +$ccResult = $CcProcessor->processPayment($payment, $customer); + +// Show return data +echo "

Data returned from selected paymentGateway.php.
".print_r($ccResult,1)."
"; + + + diff --git a/lib/paymentProcessors/phplog b/lib/paymentProcessors/phplog new file mode 100644 index 00000000..e69de29b diff --git a/lib/paymentProcessors/readme.txt b/lib/paymentProcessors/readme.txt new file mode 100644 index 00000000..57964118 --- /dev/null +++ b/lib/paymentProcessors/readme.txt @@ -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