srmklive / laravel-paypal

Laravel plugin for processing payments through PayPal.
https://laravel-paypal-demo.srmk.info/
MIT License
1.05k stars 316 forks source link

Missing docs? #631

Closed linups closed 5 months ago

linups commented 6 months ago

Hello,

Sorry, this is not exact issue, but i'm not able to find, where to post question.

I see in documentation a lot of examples with subscription. But i cannot find any example with regular charge (when is needed simple charge for one or multiple items) Did i missed something?

Thank you.

eqxDev commented 6 months ago

This is the code I use which functions, the data is just the same from the Paypal order create API

$provider = new PayPal(); $provider->setApiCredentials(config('paypal')); $provider->getAccessToken();

    $response = $provider->createOrder([
        "intent" => "CAPTURE",
        "application_context" => [
            "return_url" => route('checkout.success', ['order' => $order->id, 'token' => $token, 'type' => 'paypal']),
            "cancel_url" => route('checkout.cancel', ['order' => $order->id, 'token' => $token]),
        ],
        "purchase_units" => [
            0 => [
                'reference_id' => 'web-' . $order->id,
                "amount" => [
                    "currency_code" => "GBP",
                    "value" => $total
                ]
            ]
        ]
    ]);