Created
September 24, 2015 18:46
-
-
Save NateJLewis/1c913ab31618038573e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
$plugin_info = array( | |
'pi_name' => 'PPInContextConfig', | |
'pi_version' => '1.0.0', | |
'pi_author' => 'Nate Lewis', | |
'pi_author_url' => 'https://www.teestyle.com/', | |
'pi_description' => 'PayPal In-Context Config', | |
'pi_usage' => PPInContextConfig::usage() | |
); | |
class PPInContextConfig | |
{ | |
//Seller Sandbox Credentials- Sample credentials already provided | |
const PP_USER_SANDBOX = "roguecode0-facilitator_api1.gmail.com"; | |
const PP_PASSWORD_SANDBOX = "1382851966"; | |
const PP_SIGNATURE_SANDBOX = "AFcWxV21C7fd0v3bYYYRCpSSRl31AJp2N2whiI89JnorrxUhW0wQbakw"; | |
//Seller Live credentials. | |
const PP_USER = "rdrew_api1.teestyle.com"; | |
const PP_PASSWORD = "G4ZJ6QRV8FVFREYK"; | |
const PP_SIGNATURE = "AFcWxV21C7fd0v3bYYYRCpSSRl31AZopn8R.N5geYNCOZ3Fk5VuEjIPh"; | |
//The URL in your application where Paypal returns control to -after success (RETURN_URL) using Express Checkout Mark Flow | |
const RETURN_URL_MARK = 'http://'.$_SERVER['HTTP_HOST'].preg_replace('/paypal_ec_redirect.php/','return.php',$_SERVER['SCRIPT_NAME']); | |
//The URL in your application where Paypal returns control to -after success (RETURN_URL) and after cancellation of the order (CANCEL_URL) | |
const RETURN_URL = 'http://'.$_SERVER['HTTP_HOST'].preg_replace('/paypal_ec_redirect.php/','lightboxreturn.php',$_SERVER['SCRIPT_NAME']); | |
const CANCEL_URL = 'http://'.$_SERVER['HTTP_HOST'].preg_replace('/paypal_ec_redirect.php/','cancel.php',$_SERVER['SCRIPT_NAME']); | |
//In-Context in Express Checkout URLs for Sandbox | |
const PP_CHECKOUT_URL_SANDBOX = "https://www.sandbox.paypal.com/checkoutnow?token="; | |
const PP_NVP_ENDPOINT_SANDBOX = "https://api-3t.sandbox.paypal.com/nvp"; | |
//In-Context in Express Checkout URLs for Live | |
const PP_CHECKOUT_URL_LIVE = "https://www.paypal.com/checkoutnow?token="; | |
const PP_NVP_ENDPOINT_LIVE = "https://api-3t.paypal.com/nvp"; | |
//Express Checkout URLs for Sandbox | |
//const PP_CHECKOUT_URL_SANDBOX = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token="; | |
//const PP_NVP_ENDPOINT_SANDBOX = "https://api-3t.sandbox.paypal.com/nvp"; | |
//Express Checkout URLs for Live | |
//const PP_CHECKOUT_URL_LIVE = "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token="; | |
//const PP_NVP_ENDPOINT_LIVE = "https://api-3t.paypal.com/nvp"; | |
//Set this constant EXPRESS_MARK = true to skip review page | |
const EXPRESS_MARK = true; | |
//Set this constant ADDRESS_OVERRIDE = true to prevent from changing the shipping address | |
const ADDRESS_OVERRIDE = true; | |
//Set this constant USERACTION_FLAG = true to skip review page | |
const USERACTION_FLAG = false; | |
//Whether Sandbox environment is being used, Keep it true for testing | |
const SANDBOX_FLAG = true; | |
//Proxy Config | |
const PROXY_HOST = "127.0.0.1"; | |
const PROXY_PORT = "808"; | |
//Version of the APIs | |
const API_VERSION = "109.0"; | |
//ButtonSource Tracker Code | |
const SBN_CODE = "PP-DemoPortal-EC-IC-php"; | |
//Based on the USERACTION_FLAG assign the page | |
if(USERACTION_FLAG){ | |
$page = 'return.php'; | |
} else { | |
$page = 'review.php'; | |
} | |
if(SANDBOX_FLAG){ | |
$data['merchantID'] ="THWZVQ354KW5Y"; /* Use Sandbox merchant id when testing in Sandbox */ | |
$data['env'] = 'sandbox'; | |
return $data; | |
} | |
else { | |
$data['merchantID'] ="B7M37SGN6XJ3W"; /* Use Live merchant ID for production environment */ | |
$data['env'] = 'production'; | |
return $data; | |
} | |
public static function ppUserSandbox() | |
{ | |
return self::PP_USER_SANDBOX; | |
} | |
public static function ppPassSandbox() | |
{ | |
return self::PP_PASSWORD_SANDBOX; | |
} | |
public static function ppSigSandbox() | |
{ | |
return self::PP_SIGNATURE_SANDBOX; | |
} | |
public static function ppUser() | |
{ | |
return self::PP_USER; | |
} | |
public static function ppPass() | |
{ | |
return self::PP_PASSWORD; | |
} | |
public static function ppSig() | |
{ | |
return self::PP_SIGNATURE; | |
} | |
public static function returnUrlMark() | |
{ | |
return self::RETURN_URL_MARK; | |
} | |
public static function returnUrl() | |
{ | |
return self::RETURN_URL; | |
} | |
public static function cancelUrl() | |
{ | |
return self::CANCEL_URL; | |
} | |
public static function ppCheckoutURLSandbox() | |
{ | |
return self::PP_CHECKOUT_URL_SANDBOX; | |
} | |
public static function ppNvpEndpointSandbox() | |
{ | |
return self::PP_NVP_ENDPOINT_SANDBOX; | |
} | |
public static function ppCheckoutUrlLive() | |
{ | |
return self::PP_CHECKOUT_URL_LIVE; | |
} | |
public static function ppNvpEndpointLive() | |
{ | |
return self::PP_NVP_ENDPOINT_LIVE; | |
} | |
public function PPInContextConfig() | |
{ | |
$this->EE =& get_instance(); | |
} | |
/** | |
* Usage - EE Control Panel | |
*/ | |
public function usage() | |
{ | |
ob_start(); | |
?> | |
PayPal In-Context Config | |
<?php | |
$buffer = ob_get_contents(); | |
ob_end_clean(); | |
return $buffer; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment