/**
  * Prepares the path info.
  *
  * @return string path info
  */
 function GetPathInfo()
 {
     $baseUrl = GetBaseUrl();
     if (null === ($requestUri = GetRequestUri())) {
         return '/';
     }
     $pathInfo = '/';
     // Remove the query string from REQUEST_URI
     if ($pos = strpos($requestUri, '?')) {
         $requestUri = substr($requestUri, 0, $pos);
     }
     if (null !== $baseUrl && false === ($pathInfo = substr($requestUri, strlen($baseUrl)))) {
         // If substr() returns false then PATH_INFO is set to an empty string
         return '/';
     } elseif (null === $baseUrl) {
         return $requestUri;
     }
     return (string) $pathInfo;
 }
Exemple #2
0
use PayPal\Api\Amount;
use PayPal\Api\Details;
use PayPal\Api\Item;
use PayPal\Api\ItemList;
use PayPal\Api\Payer;
use PayPal\Api\Payment;
use PayPal\Api\RedirectUrls;
use PayPal\Api\Transaction;
use PayPal\Api\ExecutePayment;
use PayPal\Api\PaymentExecution;
global $PAYPAL;
global $TRANSACTION_TYPE;
global $META_DATA;
$PAYPAL = array('client_id' => 'AQ2LctRuZ4HMRI4AWt-ho08f-pnzboLgP5Knxo6XzNgmCzMuNvRP2SKyjJ90MIF7V8vuIJPWoCEJfu1e', 'client_secret' => 'ELHW3t4KYkWa3oosJUTQ0VB7R_HJE7kW_xMuQu-u_msHgokk1FF0rnydINs3E6xIKj448jDPov8sefZL', 'apiContext', 'api_context' => null, 'payment_method' => 'paypal', 'currency' => 'USD');
$TRANSACTION_TYPE['DONATION'] = array('payment_desc' => 'Donation Transaction', 'return_url' => GetBaseUrl() . '/donate.php/execute_payment_test?success=true', 'cancel_url' => GetBaseUrl() . '/donate.php/execute_payment_test?success=false', 'intent' => 'sale');
$TRANSACTION_TYPE['STORE'] = array('payment_desc' => 'Store Transaction', 'return_url' => GetBaseUrl() . '/donate.php/execute_payment_test?success=true', 'cancel_url' => GetBaseUrl() . '/donate.php/execute_payment_test?success=false', 'intent' => 'sale');
$META_DATA['item'] = array('sku', 'name', 'description', 'quantity', 'price', 'currency', 'tax', 'url', 'category', 'weight', 'length', 'height', 'width', 'supplementary_data', 'postback_data');
$META_DATA['details'] = array('subtotal' => 1, 'shipping' => 1, 'tax' => 1, 'handling_fee' => 1, 'shipping_discount' => -1, 'insurance' => 1, 'gift_wrap' => 1, 'fee' => 1);
include __DIR__ . '/bootstrap.php';
function CreateTransaction($transactionType, $itemArray, $details)
{
    $payer = new Payer();
    $payer->setPaymentMethod($GLOBALS['PAYPAL']['payment_method']);
    $itemList = new ItemList();
    $itemList->setItems($itemArray);
    $amount = new Amount();
    $amount->setCurrency($GLOBALS['PAYPAL']['currency'])->setTotal(GetDetailsTotal($details))->setDetails($details);
    $transaction = new Transaction();
    $transaction->setAmount($amount)->setItemList($itemList)->setDescription($GLOBALS['TRANSACTION_TYPE']['DONATION']['payment_desc'])->setInvoiceNumber(uniqid());
    $redirectUrls = new RedirectUrls();
    $redirectUrls->setReturnUrl($GLOBALS['TRANSACTION_TYPE']['DONATION']['return_url'])->setCancelUrl($GLOBALS['TRANSACTION_TYPE']['DONATION']['cancel_url']);