コード例 #1
0
$ReferenceID = '5C787706TD803561H';
$DRTFields = array('referenceid' => $ReferenceID, 'paymentaction' => 'Sale', 'ipaddress' => $_SERVER['REMOTE_ADDR']);
/**
 * Here we'll setup the payment details for the reference transaction
 * that we are processing.
 */
$PaymentDetails = array('amt' => '10.00', 'currencycode' => 'USD');
/**
 * Now we gather all of the arrays above into a single array.
 */
$PayPalRequestData = array('DRTFields' => $DRTFields, 'PaymentDetails' => $PaymentDetails);
/**
 * Here we are making the call to the DoExpressCheckoutPayment function in the library,
 * and we're passing in our $PayPalRequestData that we just set above.
 */
$PayPalResult = $PayPal->DoReferenceTransaction($PayPalRequestData);
/**
 * At this point, since the reference transaction is happening
 * to process a payment automatically, you'll want to handle
 * the result however works best for you.
 *
 * For example, you may be running this within a cron job.
 * In that scenario, you wouldn't be displaying anything
 * to the screen, but you might want to email yourself
 * a notification, update your database, etc.
 *
 * If this is happening within a user experience, then
 * you may want to redirect to a receipt page of some
 * sort.
 *
 * For demo purposes, we are simply dumping out the result