Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

#2

  • Loading branch information...
commit 5260ad1ff6536f350714547b17b861aa02aa7cb3 1 parent 6e1be6f
@matuag authored
View
5 config/bootstrap.php
@@ -1,11 +1,11 @@
<?php
+
/**
* Lithium: the most rad php framework
*
* @copyright Copyright 2011, Union of RAD (http://union-of-rad.org)
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/
-
/**
* This is the primary bootstrap file of your application, and is loaded immediately after the front
* controller (`webroot/index.php`) is invoked. It includes references to other feature-specific
@@ -22,8 +22,6 @@
*
* @see lithium\util\collection\Filters
*/
-
-
/**
* This file contains configurations for PayPal
*/
@@ -32,5 +30,4 @@
} else {
require_once __DIR__ . '/bootstrap/paypal.php';
}
-
?>
View
132 config/bootstrap/paypal.php
@@ -9,106 +9,110 @@
* @copyright Copyright (c) 2012, Gautam Sathe
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/
-
-/****************************************************
- constants.php
-
- This is the configuration file for the samples.This file
- defines the parameters needed to make an API call.
-
- PayPal includes the following API Signature for making API
- calls to the PayPal sandbox:
-
- API Username sdk-three_api1.sdk.com
- API Password QFZCWN5HZM8VBG7Q
- API Signature A.d9eRKfd1yVkRrtmMfCFLTqa6M9AyodL0SJkhYztxUi8W9pCXF6.4NI
-
- Called by CallerService.php.
- ****************************************************/
/**
- # API user: The user that is identified as making the call. you can
- # also use your own API username that you created on PayPal’s sandbox
- # or the PayPal live site
+ *
+ * This is the configuration file for the samples.This file
+ * defines the parameters needed to make an API call.
+ * PayPal includes the following API Signature for making API
+ * calls to the PayPal sandbox:
+ *
+ * API Username sdk-three_api1.sdk.com
+ * API Password QFZCWN5HZM8VBG7Q
+ * API Signature A.d9eRKfd1yVkRrtmMfCFLTqa6M9AyodL0SJkhYztxUi8W9pCXF6.4NI
+ *
+ */
+/**
+ * API user: The user that is identified as making the call. you can
+ * also use your own API username that you created on PayPal’s sandbox
+ * or the PayPal live site
+ *
+ * for 3-token -> API_USERNAME,API_PASSWORD,API_SIGNATURE are needed
*/
-//for 3-token -> API_USERNAME,API_PASSWORD,API_SIGNATURE are needed
-
define('PAYPAL_API_USERNAME', 'platfo_1255077030_biz_api1.gmail.com');
-//
/**
- # API_password: The password associated with the API user
- # If you are using your own API username, enter the API password that
- # was generated by PayPal below
- # IMPORTANT - HAVING YOUR API PASSWORD INCLUDED IN THE MANNER IS NOT
- # SECURE, AND ITS ONLY BEING SHOWN THIS WAY FOR TESTING PURPOSES
+ * API_password: The password associated with the API user
+ * If you are using your own API username, enter the API password that
+ * was generated by PayPal below
+ * IMPORTANT - HAVING YOUR API PASSWORD INCLUDED IN THE MANNER IS NOT
+ * SECURE, AND ITS ONLY BEING SHOWN THIS WAY FOR TESTING PURPOSES
*/
-
define('PAYPAL_API_PASSWORD', '1255077037');
/**
- # API_Signature:The Signature associated with the API user. which is generated by paypal.
+ * API_Signature:The Signature associated with the API user. which is generated by paypal.
*/
-
define('PAYPAL_API_SIGNATURE', 'Abg0gYcQyxQvnf2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf');
/**
- # Endpoint: this is the server URL which you have to connect for submitting your API request.
+ * Endpoint: this is the server URL which you have to connect for submitting your API request.
*/
-
define('PAYPAL_API_ENDPOINT', 'https://api-3t.sandbox.paypal.com/nvp');
-/*
- # Third party Email address that you granted permission to make api call.
+/**
+ * Third party Email address that you granted permission to make api call.
*/
define('PAYPAL_SUBJECT', '');
-/*for permission APIs ->token, signature, timestamp are needed
- define('AUTH_TOKEN',"4oSymRbHLgXZVIvtZuQziRVVxcxaiRpOeOEmQw");
- define('AUTH_SIGNATURE',"+q1PggENX0u+6vj+49tLiw9CLpA=");
- define('AUTH_TIMESTAMP',"1284959128");
+
+/**
+ * If you want to use permission APIs ->token, signature, timestamp are needed
+ * Please uncomment the the 3 line below
*/
+// define('AUTH_TOKEN',"4oSymRbHLgXZVIvtZuQziRVVxcxaiRpOeOEmQw");
+// define('AUTH_SIGNATURE',"+q1PggENX0u+6vj+49tLiw9CLpA=");
+// define('AUTH_TIMESTAMP',"1284959128");
+// below three are needed if used permissioning
+define('PAYPAL_AUTH_TOKEN', '');
+define('PAYPAL_AUTH_SIGNATURE', '');
+define('PAYPAL_AUTH_TIMESTAMP', '');
+
/**
- USE_PROXY: Set this variable to TRUE to route all the API requests through proxy.
- like define('USE_PROXY',TRUE);
+ * PAYPAL_USE_PROXY: Set this variable to TRUE to route all the API requests through proxy.
+ * like define('PAYAPL_USE_PROXY',TRUE);
*/
define('PAYPAL_USE_PROXY', FALSE);
-/**
- PROXY_HOST: Set the host name or the IP address of proxy server.
- PROXY_PORT: Set proxy port.
- PROXY_HOST and PROXY_PORT will be read only if USE_PROXY is set to TRUE
+/**
+ * PAYPAL_PROXY_HOST: Set the host name or the IP address of proxy server.
+ * PAYPAL_PROXY_PORT: Set proxy port.
+ *
+ * PAYPAL_PROXY_HOST and PROXY_PORT will be read only if PAYPAL_USE_PROXY is set to TRUE
*/
define('PAYPAL_PROXY_HOST', '127.0.0.1');
define('PAYPAL_PROXY_PORT', '808');
-/* Define the PayPal URL. This is the URL that the buyer is
- first sent to to authorize payment with their paypal account
- change the URL depending if you are testing on the sandbox
- or going to the live PayPal site
- For the sandbox, the URL is
- https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=
- For the live site, the URL is
- https://www.paypal.com/webscr&cmd=_express-checkout&token=
+/**
+ * Define the PayPal URL. This is the URL that the buyer is
+ * first sent to to authorize payment with their paypal account
+ * change the URL depending if you are testing on the sandbox
+ * or going to the live PayPal site
+ *
+ * For the sandbox, the URL is
+ * https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=
+ * For the live site, the URL is
+ * https://www.paypal.com/webscr&cmd=_express-checkout&token=
*/
define('PAYPAL_URL', 'https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=');
/**
- # Version: this is the API version in the request.
- # It is a mandatory parameter for each API request.
- # The only supported value at this time is 2.3
+ * Version: this is the API version in the request.
+ * It is a mandatory parameter for each API request.
+ * The only supported value at this time is 2.3
*/
-
define('PAYPAL_VERSION', '65.1');
-// below three are needed if used permissioning
-
-define('PAYPAL_AUTH_TOKEN' , '');
-define('PAYPAL_AUTH_SIGNATURE', '');
-define('PAYPAL_AUTH_TIMESTAMP', '');
-
-// custom config
+/**
+ * Auth Mode: this defines the auth mode used by API call
+ * 3TOKEN - Merchant's API 3-TOKEN Credential is required to make API Call.
+ * FIRSTPARTY - Only merchant Email is required to make EC Calls.
+ * THIRDPARTY - Partner's API Credential and Merchant Email as Subject are required.
+ * PERMISSION
+ */
define('PAYPAL_AUTH_MODE', '');
-// Ack related constants
+/**
+ * Ack related constants
+ */
define('PAYPAL_ACK_SUCCESS', 'SUCCESS');
define('PAYPAL_ACK_SUCCESS_WITH_WARNING', 'SUCCESSWITHWARNING');
?>
View
23 extensions/net/http/CallerService.php
@@ -11,19 +11,21 @@
*/
namespace paypal_lib\extensions\net\http;
-/****************************************************
- CallerService.php
- This file uses the constants.php to get parameters needed
- to make an API call and calls the server.if you want use your
- own credentials, you have to change the constants.php
+/* * **************************************************
+ CallerService.php
- Called by TransactionDetails.php, ReviewOrder.php,
- DoDirectPaymentReceipt.php and DoExpressCheckoutPayment.php.
+ This file uses the constants.php to get parameters needed
+ to make an API call and calls the server.if you want use your
+ own credentials, you have to change the constants.php
- ****************************************************/
+ Called by TransactionDetails.php, ReviewOrder.php,
+ DoDirectPaymentReceipt.php and DoExpressCheckoutPayment.php.
+
+ * ************************************************** */
class CallerService {
+
protected $_config = array();
/**
@@ -78,7 +80,7 @@ private function _nvpHeader() {
$authMode = "FIRSTPARTY";
}
}
- switch($authMode) {
+ switch ($authMode) {
case "3TOKEN":
$nvpHeaderStr = '&PWD=' . urlencode($this->_config['paypalApiPassword']);
$nvpHeaderStr .= '&USER=' . urlencode($this->_config['paypalApiUsername']);
@@ -182,7 +184,7 @@ private function _deformatNVP($nvpstr) {
//position of value
$valuepos = strpos($nvpstr, '&') ? strpos($nvpstr, '&') : strlen($nvpstr);
- /*getting the Key and Value values and storing in a Associative Array*/
+ /* getting the Key and Value values and storing in a Associative Array */
$keyval = substr($nvpstr, $intial, $keypos);
$valval = substr($nvpstr, $keypos + 1, $valuepos - $keypos - 1);
//decoding the respose
@@ -198,4 +200,5 @@ private function _formAutorization($auth_token, $auth_signature, $auth_timestamp
}
}
+
?>
View
53 extensions/net/http/DoDirectPaymentService.php
@@ -11,33 +11,35 @@
*/
namespace paypal_lib\extensions\net\http;
-/***********************************************************
- DoDirectPaymentReceipt.php
- Submits a credit card transaction to PayPal using a
- DoDirectPayment request.
+/* * *********************************************************
+ DoDirectPaymentReceipt.php
- The code collects transaction parameters from the form
- displayed by DoDirectPayment.php then constructs and sends
- the DoDirectPayment request string to the PayPal server.
- The paymentType variable becomes the PAYMENTACTION parameter
- of the request string.
+ Submits a credit card transaction to PayPal using a
+ DoDirectPayment request.
- After the PayPal server returns the response, the code
- displays the API request and response in the browser.
- If the response from PayPal was a success, it displays the
- response parameters. If the response was an error, it
- displays the errors.
+ The code collects transaction parameters from the form
+ displayed by DoDirectPayment.php then constructs and sends
+ the DoDirectPayment request string to the PayPal server.
+ The paymentType variable becomes the PAYMENTACTION parameter
+ of the request string.
- Called by DoDirectPayment.php.
+ After the PayPal server returns the response, the code
+ displays the API request and response in the browser.
+ If the response from PayPal was a success, it displays the
+ response parameters. If the response was an error, it
+ displays the errors.
- Calls CallerService.php and APIError.php.
+ Called by DoDirectPayment.php.
- ***********************************************************/
+ Calls CallerService.php and APIError.php.
+
+ * ********************************************************* */
use paypal_lib\extensions\net\http\CallerService;
class DoDirectPaymentService {
+
protected $_config = array();
/**
@@ -85,8 +87,8 @@ public function directPayment($postData) {
$paymentType = urlencode($postData['paymentType']);
/* Construct the request string that will be sent to PayPal.
- The variable $nvpstr contains all the variables and is a
- name value pair string with & as a delimiter */
+ The variable $nvpstr contains all the variables and is a
+ name value pair string with & as a delimiter */
$nvpstr = '&PAYMENTACTION=' . $paymentType;
$nvpstr .= '&AMT=' . $amount;
$nvpstr .= '&CREDITCARDTYPE=' . $creditCardType;
@@ -103,19 +105,18 @@ public function directPayment($postData) {
$nvpstr .= '&CURRENCYCODE=' . $currencyCode;
/* Make the API call to PayPal, using API signature.
- The API response is stored in an associative array called $resArray */
+ The API response is stored in an associative array called $resArray */
$resArray = $callService->hashCall('doDirectPayment', $nvpstr);
/* Display the API response back to the browser.
- If the response from PayPal was a success, display the response parameters'
- If the response was an error, display the errors received using APIError.php.
+ If the response from PayPal was a success, display the response parameters'
+ If the response was an error, display the errors received using APIError.php.
*/
//$ack = strtoupper($resArray["ACK"]);
-
// if ($ack != "SUCCESS") {
- // $_SESSION['reshash'] = $resArray;
- // $location = "APIError.php";
- // header("Location: $location");
+ // $_SESSION['reshash'] = $resArray;
+ // $location = "APIError.php";
+ // header("Location: $location");
// }
//var_dump($resArray);
return $resArray;
View
1  extensions/net/http/PaypalService.php
@@ -49,7 +49,6 @@ public function paypalPayment($postData, $type = 'doDirectPayment') {
return $ack;
}
-
}
?>
Please sign in to comment.
Something went wrong with that request. Please try again.