public static printError ( $title, $objectName, null $objectId = null, null $request = null, Exception $exception = null ) | ||
$title | ||
$objectName | ||
$objectId | null | |
$request | null | |
$exception | Exception |
public static function printError($title, $objectName, $objectId = null, $request = null, $exception = null)
{
$data = null;
if ($exception instanceof \PayPal\Exception\PayPalConnectionException) {
$data = $exception->getData();
}
self::printOutput($title, $objectName, $objectId, $request, $data, $exception->getMessage());
}
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']); $payment = new Payment(); $payment->setIntent($GLOBALS['TRANSACTION_TYPE']['DONATION']['intent'])->setPayer($payer)->setRedirectUrls($redirectUrls)->setTransactions(array($transaction)); $request = clone $payment; try { $payment->create($GLOBALS['PAYPAL']['api_context']); } catch (Exception $ex) { ResultPrinter::printError("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", null, $request, $ex); return false; } $approvalUrl = $payment->getApprovalLink(); echo $approvalUrl; return array('request' => $request, 'payment' => $payment, 'approvalUrl' => $approvalUrl); }