* @created 2022-08-10 18:57:56 * @modified 2022-08-10 18:57:56 * * https://www.zongscan.com/demo333/1311.html * https://clickysoft.com/how-to-integrate-paypal-payment-gateway-in-laravel/ * https://www.positronx.io/how-to-integrate-paypal-payment-gateway-in-laravel/ * */ namespace Plugin\Paypal\Controllers; use Srmklive\PayPal\Services\PayPal; class PaypalController { public function handlePayment() { $product = []; $product['items'] = [ [ 'name' => 'Nike Joyride 2', 'price' => 112, 'desc' => 'Running shoes for Men', 'qty' => 2 ] ]; $product['invoice_id'] = 1; $product['invoice_description'] = "Order #{$product['invoice_id']} Bill"; $product['return_url'] = route('success.payment'); $product['cancel_url'] = route('cancel.payment'); $product['total'] = 224; $paypalModule = new PayPal(); $res = $paypalModule->setExpressCheckout($product); $res = $paypalModule->setExpressCheckout($product, true); return redirect($res['paypal_link']); } public function paymentCancel() { dd('Your payment has been declend. The payment cancelation page goes here!'); } public function paymentSuccess(Request $request) { $paypalModule = new ExpressCheckout; $response = $paypalModule->getExpressCheckoutDetails($request->token); if (in_array(strtoupper($response['ACK']), ['SUCCESS', 'SUCCESSWITHWARNING'])) { dd('Payment was successfull. The payment success page goes here!'); } dd('Error occured!'); } }