Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Array
- (
- [0] => X-PAYPAL-SECURITY-USERID: developer_api1.gmail.com
- [1] => X-PAYPAL-SECURITY-PASSWORD: xxxxxxxx
- [2] => X-PAYPAL-SECURITY-SIGNATURE: xxxxxxxxx
- [3] => X-PAYPAL-SECURITY-SUBJECT: subject
- [4] => X-PAYPAL-REQUEST-DATA-FORMAT: XML
- [5] => X-PAYPAL-RESPONSE-DATA-FORMAT: XML
- [6] => X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T
- [7] => X-PAYPAL-DEVICE-ID:
- [8] => X-PAYPAL-DEVICE-IPADDRESS: http://192.168.1.9:8888
- [9] => X-PAYPAL-SANDBOX-EMAIL-ADDRESS: [email protected]
- )
- /**
- * Timezone Setting
- * List of Supported Timezones: http://www.php.net/manual/en/timezones.php
- */
- date_default_timezone_set('America/Chicago');
- /**
- * Enable Sessions
- * Checks to see if a session_id exists. If not, a new session is started.
- */
- if(!session_id()) session_start();
- /**
- * Sandbox Mode - TRUE/FALSE
- * Check the domain of the current page and set $sandbox accordingly.
- * This allows you to automatically use Sandbox or Live credentials throughout
- * your application based on what server the app is running from.
- *
- * I like to do this so I don't forget to update Sandbox credentials to Live
- * prior to uploading files to a production server.
- *
- * In this case, it's checking to see if the current URL is http://sandbox.domain.*
- * If so, $sandbox is true and the PayPal sandbox will be used throughout. If not,
- * we'll assume it must be a live transaction and will use live credentials throughout.
- *
- * Following this pattern will allow you to create your own http://sandbox.domain.com test server,
- * and then any time your code runs from that server, PayPal's sandbox will be used automatically.
- *
- * If you would rather just set $sandbox to true/false on your own that's fine,
- * but you have to make sure your live server always uses false and your test server
- * always uses true. It's easy to forget this and up with real customers processing
- * payments from your live site on the PayPal sandbox.
- */
- $host_split = explode('.',$_SERVER['HTTP_HOST']);
- $sandbox = $host_split[0] == 'sandbox' && $host_split[1] == 'domain' ? TRUE : FALSE;
- $sandbox=TRUE;
- $domain = $sandbox ? 'http://192.168.1.9:8888' : 'http://www.realurl.com/';
- $cancel_url="http://192.168.1.9:8888";
- $return_url="http://192.168.1.9:8888";
- /**
- * Enable error reporting if running in sandbox mode.
- */
- if($sandbox)
- {
- error_reporting(E_ALL|E_STRICT);
- ini_set('display_errors', '1');
- }
- /**
- * PayPal API Version
- * ------------------
- * The library is currently using PayPal API version 109.0.
- * You may adjust this value here and then pass it into the PayPal object when you create it within your scripts to override if necessary.
- */
- $api_version = '119.0'; // Released 11.05.2014
- /**
- * PayPal Application ID
- * --------------------------------------
- * The application is only required with Adaptive Payments applications.
- * You obtain your application ID but submitting it for approval within your
- * developer account at http://developer.paypal.com
- *
- * We're using shorthand if/else statements here to set both Sandbox and Production values.
- * Your sandbox values go on the left and your live values go on the right.
- * The sandbox value included here is a global value provided for developrs to use in the PayPal sandbox.
- */
- $application_id = $sandbox ? 'APP-80W284485P519543T' : '';
- /**
- * PayPal Developer Account Email Address
- * This is the email address that you use to sign in to http://developer.paypal.com
- */
- $developer_account_email = '[email protected]';
- /**
- * PayPal Gateway API Credentials
- * ------------------------------
- * These are your PayPal API credentials for working with the PayPal gateway directly.
- * These are used any time you're using the parent PayPal class within the library.
- *
- * We're using shorthand if/else statements here to set both Sandbox and Production values.
- * Your sandbox values go on the left and your live values go on the right.
- *
- * You may obtain these credentials by logging into the following with your PayPal account: https://www.paypal.com/us/cgi-bin/webscr?cmd=_login-api-run
- */
- $api_username = $sandbox ? 'developer_api1.gmail.com' : 'developer_api1.gmail.com';
- $api_password = $sandbox ? 'xxxxxxxxxxxxxxxxxxxxxxxxxx' : 'xxxxxxxxxxxxxxxxxxxxxxxxxx';
- $api_signature = $sandbox ? 'xxxxxxxxxxxxxxxxxxxxxxxxxx' : 'xxxxxxxxxxxxxxxxxxxxxxxxxx';
- /**
- * Payflow Gateway API Credentials
- * ------------------------------
- * These are the credentials you use for your PayPal Manager: http://manager.paypal.com
- * These are used when you're working with the PayFlow child class.
- *
- * We're using shorthand if/else statements here to set both Sandbox and Production values.
- * Your sandbox values go on the left and your live values go on the right.
- *
- * You may use the same credentials you use to login to your PayPal Manager,
- * or you may create API specific credentials from within your PayPal Manager account.
- */
- $payflow_username = $sandbox ? 'SANDBOX_PAYFLOW_USERNAME' : 'LIVE_PAYFLOW_USERNAME';
- $payflow_password = $sandbox ? 'SANDBOX_PAYFLOW_PASSWORD' : 'LIVE_PAYFLOW_PASSWORD';
- $payflow_vendor = $sandbox ? 'SANDBOX_PAYFLOW_VENDOR' : 'LIVE_PAYFLOW_VENDOR';
- $payflow_partner = $sandbox ? 'SANDBOX_PAYFLOW_PARTNER' : 'LIVE_PAYFLOW_PARTNER';
- /**
- * PayPal REST API Credentials
- * ---------------------------
- * These are the API credentials used for the PayPal REST API.
- * These are used any time you're working with the REST API child class.
- *
- * You may obtain these credentials from within your account at http://developer.paypal.com
- */
- $rest_client_id = $sandbox ? 'SANDBOX_CLIENT_ID' : 'LIVE_CLIENT_ID';
- $rest_client_secret = $sandbox ? 'SANDBOX_SECRET_ID' : 'LIVE_SECRET_ID';
- /**
- * PayPal Finance Portal API
- * -------------------------
- * These are credentials used for obtaining a PublisherID used in Bill Me Later Banner code.
- * As of now, these are specialized API's and you must obtain credentials directly from a PayPal rep.
- */
- $finance_access_key = $sandbox ? 'SANDBOX_ACCESS_KEY' : 'LIVE_ACCESS_KEY';
- $finance_client_secret = $sandbox ? 'SANDBOX_CLIENT_SECRET' : 'LIVE_CLIENT_SECRET';
- /**
- * Third Party User Values
- * These can be setup here or within each caller directly when setting up the PayPal object.
- */
- $api_subject = 'soggetto'; // If making calls on behalf a third party, their PayPal email address or account ID goes here.
- $device_id = '';
- $device_ip_address = $_SERVER['REMOTE_ADDR'];
- /**
- * Enable Headers
- * Option to print headers to screen when dumping results or not.
- */
- $print_headers = true;
- /**
- * Enable Logging
- * Option to log API requests and responses to log file.
- */
- $log_results = false;
- $log_path = $_SERVER['DOCUMENT_ROOT'].'/logs/';
- <?php
- // Include required library files.
- require_once('includes/config.php');
- require_once('autoload.php');
- //phpinfo();
- // Create PayPal object.
- $PayPalConfig = array(
- 'Sandbox' => $sandbox,
- 'DeveloperAccountEmail' => $developer_account_email,
- 'ApplicationID' => $application_id,
- 'DeviceID' => $device_id,
- 'IPAddress' => "http://192.168.1.9:8888",
- 'APIUsername' => $api_username,
- 'APIPassword' => $api_password,
- 'APISignature' => $api_signature,
- 'APISubject' => $api_subject,
- 'PrintHeaders' => $print_headers,
- 'LogResults' => $log_results,
- 'LogPath' => $log_path,
- );
- $PayPal = new angelleyePayPalAdaptive($PayPalConfig);
- // Prepare request arrays
- $PayRequestFields = array(
- 'ActionType' => 'PAY_PRIMARY', // Required. Whether the request pays the receiver or whether the request is set up to create a payment request, but not fulfill the payment until the ExecutePayment is called. Values are: PAY, CREATE, PAY_PRIMARY
- 'CancelURL' => $cancel_url, // Required. The URL to which the sender's browser is redirected if the sender cancels the approval for the payment after logging in to paypal.com. 1024 char max.
- 'CurrencyCode' => 'EUR', // Required. 3 character currency code.
- 'FeesPayer' => 'SECONDARYONLY', // The payer of the fees. Values are: SENDER, PRIMARYRECEIVER, EACHRECEIVER, SECONDARYONLY
- 'IPNNotificationURL' => 'http://192.168.1.9:8888/ipn/', // The URL to which you want all IPN messages for this payment to be sent. 1024 char max.
- 'Memo' => '', // A note associated with the payment (text, not HTML). 1000 char max
- 'Pin' => '', // The sener's personal id number, which was specified when the sender signed up for the preapproval
- 'PreapprovalKey' => '', // The key associated with a preapproval for this payment. The preapproval is required if this is a preapproved payment.
- 'ReturnURL' => $return_url, // Required. The URL to which the sener's browser is redirected after approvaing a payment on paypal.com. 1024 char max.
- 'ReverseAllParallelPaymentsOnError' => '', // Whether to reverse paralel payments if an error occurs with a payment. Values are: TRUE, FALSE
- 'SenderEmail' => '', // Sender's email address. 127 char max.
- 'TrackingID' => 'trackpasy234234' // Unique ID that you specify to track the payment. 127 char max.
- );
- $ClientDetailsFields = array(
- 'CustomerID' => '345', // Your ID for the sender 127 char max.
- 'CustomerType' => '34', // Your ID of the type of customer. 127 char max.
- 'GeoLocation' => '', // Sender's geographic location
- 'Model' => '', // A sub-identification of the application. 127 char max.
- 'PartnerName' => '' // Your organization's name or ID
- );
- $FundingTypes = array('ECHECK', 'BALANCE', 'CREDITCARD'); // Funding constrainigs require advanced permissions levels.
- $Receivers = array();
- $Receiver = array(
- 'Amount' => '500.00', // Required. Amount to be paid to the receiver.
- 'Email' => '[email protected]', // Receiver's email address. 127 char max.
- 'InvoiceID' => '', // The invoice number for the payment. 127 char max.
- 'PaymentType' => 'GOODS', // Transaction type. Values are: GOODS, SERVICE, PERSONAL, CASHADVANCE, DIGITALGOODS
- 'PaymentSubType' => '', // The transaction subtype for the payment.
- 'AccountID' => '',
- 'Phone' => array('CountryCode' => '', 'PhoneNumber' => '', 'Extension' => ''), // Receiver's phone number. Numbers only.
- 'Primary' => 'true' // Whether this receiver is the primary receiver. Values are boolean: TRUE, FALSE
- );
- array_push($Receivers,$Receiver);
- $Receiver = array(
- 'Amount' => '50.00', // Required. Amount to be paid to the receiver.
- 'Email' => '[email protected]', // Receiver's email address. 127 char max.
- 'InvoiceID' => '', // The invoice number for the payment. 127 char max.
- 'PaymentType' => 'GOODS', // Transaction type. Values are: GOODS, SERVICE, PERSONAL, CASHADVANCE, DIGITALGOODS
- 'PaymentSubType' => '', // The transaction subtype for the payment.
- 'AccountID' => '',
- 'Phone' => array('CountryCode' => '', 'PhoneNumber' => '', 'Extension' => ''), // Receiver's phone number. Numbers only.
- 'Primary' => 'false' // Whether this receiver is the primary receiver. Values are boolean: TRUE, FALSE
- );
- array_push($Receivers,$Receiver);
- $SenderIdentifierFields = array(
- 'UseCredentials' => '' // If TRUE, use credentials to identify the sender. Default is false.
- );
- $AccountIdentifierFields = array(
- 'Email' => '', // Sender's email address. 127 char max.
- 'Phone' => array('CountryCode' => '', 'PhoneNumber' => '', 'Extension' => '') // Sender's phone number. Numbers only.
- );
- $PayPalRequestData = array(
- 'PayRequestFields' => $PayRequestFields,
- 'ClientDetailsFields' => $ClientDetailsFields,
- //'FundingTypes' => $FundingTypes,
- 'Receivers' => $Receivers,
- 'SenderIdentifierFields' => $SenderIdentifierFields,
- 'AccountIdentifierFields' => $AccountIdentifierFields
- );
- // Pass data into class for processing with PayPal and load the response array into $PayPalResult
- $PayPalResult = $PayPal->Pay($PayPalRequestData);
- // Write the contents of the response array to the screen for demo purposes.
- echo '<pre />';
- print_r($PayPalResult);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement