public function execute()
 {
     // Create PayPal object.
     $PayPalConfig = array('Sandbox' => $this->sandbox, 'DeveloperAccountEmail' => $this->developer_account_email, 'ApplicationID' => $this->application_id, 'DeviceID' => $this->device_id, 'IPAddress' => $_SERVER['REMOTE_ADDR'], 'APIUsername' => $this->api_username, 'APIPassword' => $this->api_password, 'APISignature' => $this->api_signature, 'APISubject' => $this->api_subject);
     $PayPal = new PayPal_Adaptive($PayPalConfig);
     // Prepare request arrays
     $ExecutePaymentFields = array('PayKey' => '', 'FundingPlanID' => '');
     $PayPalRequestData = array('ExecutePaymentFields' => $ExecutePaymentFields);
     // Pass data into class for processing with PayPal and load the response array into $PayPalResult
     $PayPalResult = $PayPal->ExecutePayment($PayPalRequestData);
     return $PayPalResult;
 }
示例#2
0
<?php

// Include required library files.
require_once '../includes/config.php';
require_once '../includes/paypal.class.php';
require_once '../includes/paypal.adaptive.class.php';
// Create PayPal object.
$PayPalConfig = array('Sandbox' => $sandbox, 'DeveloperAccountEmail' => $developer_account_email, 'ApplicationID' => $application_id, 'DeviceID' => $device_id, 'IPAddress' => $_SERVER['REMOTE_ADDR'], 'APIUsername' => $api_username, 'APIPassword' => $api_password, 'APISignature' => $api_signature, 'APISubject' => $api_subject);
$PayPal = new PayPal_Adaptive($PayPalConfig);
// Prepare request arrays
$ExecutePaymentFields = array('PayKey' => '', 'FundingPlanID' => '');
$PayPalRequestData = array('ExecutePaymentFields' => $ExecutePaymentFields);
// Pass data into class for processing with PayPal and load the response array into $PayPalResult
$PayPalResult = $PayPal->ExecutePayment($PayPalRequestData);
// Write the contents of the response array to the screen for demo purposes.
echo '<pre />';
print_r($PayPalResult);
 function payExecute_Successful($array)
 {
     /* 	amount, commision, paykey, rewardId, back_id, projectId, project_name,
     			backer_id, backer_email, backer_name, creator_id, creator_name, creator_email,
     			creator_paykey, creator_paypal */
     extract($array);
     wrtlog("In payment.class.php payExecute_Successful with array: " . print_r($array, true));
     $CurrencyCode = 'USD';
     $PayKey = $paykey;
     $FundingPlanID = '';
     $PayPal = new PayPal_Adaptive($this->PayPalConfig);
     // Prepare request arrays
     $ExecutePaymentFields = array('PayKey' => $PayKey, 'FundingPlanID' => '');
     $PayPalRequestData = array('ExecutePaymentFields' => $ExecutePaymentFields);
     // Pass data into class for processing with PayPal and load the response array into $PayPalResult
     $PayPalResult = $PayPal->ExecutePayment($PayPalRequestData);
     wrtlog("PayPal->ExecutePayment PayPalResult: " . print_r($PayPalResult, true));
     /*	
     	    [Errors] => Array
     			(
     			)
     	
     		[Ack] => Success
     		[Build] => 7935900
     		[CorrelationID] => 61cb624f0b5d4
     		[Timestamp] => 2013-12-03T04:36:58.662-08:00
     		[PaymentExecStatus] => COMPLETED
     		[XMLRequest] => ReturnAllen_USAP-87H43938LL9590813
     		[XMLResponse] => 2013-12-03T04:36:58.662-08:00Success61cb624f0b5d47935900COMPLETED*/
     if (strtolower($PayPalResult['Ack']) == 'success') {
         $this->payExecute_Successful_backer_dbupdate($array, $PayPalResult);
         $this->payExecute_Successful_backer_mail($array, $PayPalResult);
     } else {
         $this->cancel_preapprovals_backer_dbupdate($array, $PayPalResult, true);
         $this->payExecute_Successful_failed_backer_mail($array, $PayPalResult);
     }
 }