private function _createPaymentURL(PayPal\Api\Payer $payer, PayPal\Api\RedirectUrls $redirectUrls, PayPal\Api\Transaction $transaction, PayPal\Rest\ApiContext $apiContext)
 {
     $payment = new PayPal\Api\Payment();
     $payment->setIntent("sale")->setPayer($payer)->setRedirectUrls($redirectUrls)->setTransactions(array($transaction));
     try {
         $payment->create($apiContext);
     } catch (Exception $e) {
         CLogger::getInstance()->add(__LINE__, __METHOD__, 'exception error', $e);
         die;
     }
     $url = $payment->getApprovalLink();
     CLogger::getInstance()->add(__LINE__, __METHOD__, 'url paypal', $url);
     CLogger::getInstance()->getLog('PayPal starting checkout');
     header("Location: {$url}");
     exit;
 }
Example #2
0
<?php

require_once 'app/includes/header.inc.php';
$result = CProcess::getInstance()->process($settings['billing']['paypal']);
CLogger::getInstance()->getLog('PayPal Billing Result');
 private static function _process(\PayPal\Api\Payment &$payment, PayPal\Rest\ApiContext &$apiContext, PayPal\Api\PaymentExecution &$execution)
 {
     #Logger
     CLogger::getInstance()->add(__LINE__, __CLASS__, 'status_before_to_process', self::_getStatus($payment));
     try {
         $result = $payment->execute($execution, $apiContext);
         CLogger::getInstance()->add(__LINE__, __CLASS__, 'result', $result);
         $payment_success = true;
     } catch (Exception $e) {
         $data = json_decode($e->getData());
         $payment_success = array('code' => $e->getCode(), 'message' => $e->getMessage(), 'line' => $e->getLine(), 'file' => $e->getFile(), 'exception' => $data->name, 'reason' => self::_getFailureReason($payment));
     }
     #Logger
     CLogger::getInstance()->add(__LINE__, __CLASS__, 'payment_status', $payment_success);
     CLogger::getInstance()->add(__LINE__, __CLASS__, 'status_after_to_process', self::_getStatus($payment));
     return $payment_success;
 }
Example #4
0
 public static function setLogId($intLogId)
 {
     CLogger::getInstance()->intLogId = $intLogId;
 }