| @@ 108-137 (lines=30) @@ | ||
| 105 | /** |
|
| 106 | * Done. |
|
| 107 | */ |
|
| 108 | public function done(Request $request) |
|
| 109 | { |
|
| 110 | ||
| 111 | //je recupere les informations de retour de Paypal |
|
| 112 | $id = $request->get('paymentId'); |
|
| 113 | // $token = $request->get('token'); |
|
| 114 | $payer_id = $request->get('PayerID'); |
|
| 115 | $payment = PayPal::getById($id, $this->_apiContext); |
|
| 116 | ||
| 117 | $paymentExecution = PayPal::PaymentExecution(); |
|
| 118 | //execution du paiment a partir du Payer |
|
| 119 | //Requete à Paypal: débit du montant de a transaction au Payer |
|
| 120 | $paymentExecution->setPayerId($payer_id); |
|
| 121 | $executePayment = $payment->execute($paymentExecution, $this->_apiContext); |
|
| 122 | ||
| 123 | // Clear the shopping cart, |
|
| 124 | $request->session()->pull('likes', []); |
|
| 125 | ||
| 126 | //write log |
|
| 127 | Log::info('Un client vient de passer uen commande via Paypal'.$payer_id); |
|
| 128 | ||
| 129 | // Write database |
|
| 130 | ||
| 131 | // Thank the user for the purchase |
|
| 132 | return view('Cart/success'); |
|
| 133 | } |
|
| 134 | ||
| 135 | /** |
|
| 136 | * Cancel. |
|
| 137 | */ |
|
| 138 | public function cancel() |
|
| 139 | { |
|
| 140 | } |
|
| @@ 67-83 (lines=17) @@ | ||
| 64 | * |
|
| 65 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
|
| 66 | */ |
|
| 67 | public function done(Request $request) |
|
| 68 | { |
|
| 69 | $id = $request->get('paymentId'); |
|
| 70 | $payer_id = $request->get('PayerID'); |
|
| 71 | ||
| 72 | $payment = PayPal::getById($id, $this->_apiContext); |
|
| 73 | ||
| 74 | $paymentExecution = PayPal::PaymentExecution(); |
|
| 75 | ||
| 76 | $paymentExecution->setPayerId($payer_id); |
|
| 77 | $executePayment = $payment->execute($paymentExecution, $this->_apiContext); |
|
| 78 | ||
| 79 | // Clear the shopping cart, write to database, send notifications, etc. |
|
| 80 | $request->session()->pull('likes', []); |
|
| 81 | ||
| 82 | return view('Main/index'); |
|
| 83 | } |
|
| 84 | ||
| 85 | /** |
|
| 86 | * Page Dashboard. |
|