Пример #1
0
 public function success($taskId)
 {
     $paypalService = new PaypalPaymentService();
     $paymentId = Input::get('paymentId');
     $payerID = Input::get('PayerID');
     $token = Input::get('token');
     $task = new \stdClass();
     $task->id = $taskId;
     $task->title = 'Task example title';
     $task->total = 50.25;
     try {
         $paypalService->checkPaymentSession($paymentId, $task);
     } catch (\Exception $e) {
         Log::error('PayPal Error ' . $e->getMessage());
         abort(404);
         return false;
     }
     // set task paid here
     dd($paymentId, $payerID, $token);
 }
Пример #2
0
 public function paypalSuccess($userId)
 {
     $paypalService = new PaypalPaymentService();
     $paymentId = Input::get('paymentId');
     $payerID = Input::get('PayerID');
     $token = Input::get('token');
     try {
         $paypalService->checkPaymentSession($paymentId, $this->user);
         $paymentInfo = $paypalService->paymentInfo;
         $amount = $paymentInfo['amount'];
         LogMapper::log('paypal_success', $amount, $userId, $paymentInfo);
     } catch (\Exception $e) {
         LogMapper::log('paypal_error', $e->getMessage(), 'success_callback', ['user' => $this->user->id, 'paymentId' => $paymentId]);
         return Redirect::to('/user/client/billing')->withErrors(['paypal' => 'Failed paypal']);
     }
     $payment = PaymentMapper::refillFromPaypal($this->user, $paypalService);
     LogMapper::log('payment', $amount, 'refilled', ['payment_id' => $payment->id, 'merchant' => 'paypal']);
     NotificationMapper::refilled($payment);
     return Redirect::to('/user/client/billing')->with(['success' => 'We got your payment']);
 }