laravel-paypal
laravel-paypal copied to clipboard
Add custom id for invoice id
Allow to add custom id for invoice id.
Can you specify why we need to add it? Any example you can share?
You can set any custom data like Invoice ID, Transaction ID so you can tract the resource on webhook.
For example:
$invoice = Invoice::create([...]);
$response = $provider->addProduct('Demo Product', 'Demo Product', 'SERVICE', 'SOFTWARE')
->addPlanTrialPricing('DAY', 7)
->addWeeklyPlan('Demo Plan', 'Demo Plan', 30)
->addCustomId($invoice->id)
->setReturnAndCancelUrl('https://example.com/paypal-success', 'https://example.com/paypal-cancel')
->setupSubscription('John Doe', '[email protected]', '2021-12-10');
Now on webhook i can track this custom_id and process the invoice.
One can even pass the http_build_query
query data in custom_id
. This way you don't even have to add temporary records in database and process everything on webhooks
$response = $provider->addProduct('Demo Product', 'Demo Product', 'SERVICE', 'SOFTWARE')
->addPlanTrialPricing('DAY', 7)
->addWeeklyPlan('Demo Plan', 'Demo Plan', 30)
->addCustomId(http_build_query(['user' => $user->id, 'plan' => $plan->id, ... 'something_else' => 'other data']))
->setReturnAndCancelUrl('https://example.com/paypal-success', 'https://example.com/paypal-cancel')
->setupSubscription('John Doe', '[email protected]', '2021-12-10');
For some reasons the WH verification fails when $request->all()
is sent in webhook_event
. I have tested the verification successfully with json_decode($request->getContent())
If you want to test you can try the webhook PAYMENT.SALE.COMPLETED