예제 #1
0
<?php

// Include required library files.
require_once '../includes/config.php';
require_once '../autoload.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 angelleye\PayPal\Adaptive($PayPalConfig);
// Prepare request arrays
$UpdateInvoiceFields = array('InvoiceID' => '', 'MerchantEmail' => '', 'PayerEmail' => '', 'Number' => '', 'CurrencyCode' => '', 'InvoiceDate' => '', 'DueDate' => '', 'PaymentTerms' => '', 'DiscountPercent' => '', 'DiscountAmount' => '', 'Terms' => '', 'Note' => '', 'MerchantMemo' => '', 'ShippingAmount' => '', 'ShippingTaxName' => '', 'ShippingTaxRate' => '', 'LogoURL' => '');
$BusinessInfo = array('FirstName' => '', 'LastName' => '', 'BusinessName' => '', 'Phone' => '', 'Fax' => '', 'Website' => '', 'Custom' => '');
$BusinessInfoAddress = array('Line1' => '', 'Line2' => '', 'City' => '', 'State' => '', 'PostalCode' => '', 'CountryCode' => '');
$BillingInfo = array('FirstName' => '', 'LastName' => '', 'BusinessName' => '', 'Phone' => '', 'Fax' => '', 'Website' => '', 'Custom' => '');
$BillingInfoAddress = array('Line1' => '', 'Line2' => '', 'City' => '', 'State' => '', 'PostalCode' => '', 'CountryCode' => '');
$ShippingInfo = array('FirstName' => '', 'LastName' => '', 'BusinessName' => '', 'Phone' => '', 'Fax' => '', 'Website' => '', 'Custom' => '');
$ShippingInfoAddress = array('Line1' => '', 'Line2' => '', 'City' => '', 'State' => '', 'PostalCode' => '', 'CountryCode' => '');
// For invoice items you populate a nested array with multiple $InvoiceItem arrays.  Normally you'll be looping through cart items to populate the $InvoiceItem
// array and then push it into the $InvoiceItems array at the end of each loop for an entire collection of all items in $InvoiceItems.
$InvoiceItems = array();
$InvoiceItem = array('Name' => '', 'Description' => '', 'Date' => '', 'Quantity' => '', 'UnitPrice' => '', 'TaxName' => '', 'TaxRate' => '');
array_push($InvoiceItems, $InvoiceItem);
$PayPalRequestData = array('UpdateInvoiceFields' => $UpdateInvoiceFields, 'BusinessInfo' => $BusinessInfo, 'BusinessInfoAddress' => $BusinessInfoAddress, 'BillingInfo' => $BillingInfo, 'BillingInfoAddress' => $BillingInfoAddress, 'ShippingInfo' => $ShippingInfo, 'ShippingInfoAddress' => $ShippingInfoAddress, 'InvoiceItems' => $InvoiceItems);
// Pass data into class for processing with PayPal and load the response array into $PayPalResult
$PayPalResult = $PayPal->UpdateInvoice($PayPalRequestData);
// Write the contents of the response array to the screen for demo purposes.
echo '<pre />';
print_r($PayPalResult);