-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom id for invoice id #603
Conversation
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 $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'); |
Add installments. (fixes srmklive#602)
Some webhook verification fails with $request->all(); You can test "PAYMENT.SALE.COMPLETED" `request->all {"id":"WH-0UX959158W078642N-2MW5123584490731L","event_version":"1.0","create_time":"2023-12-22T21:32:24.574Z","resource_type":"sale","event_type":"PAYMENT.SALE.COMPLETED","summary":"Payment completed for $ 3.67 USD","resource":{"amount":{"total":"3.67","currency":"USD","details":{"subtotal":"3.67"}},"payment_mode":"INSTANT_TRANSFER","create_time":"2023-12-22T21:32:18Z","custom":"id=3QWVF5ZswM&user=1&plan=2&interval=monthly&renew=10.4895&amount=3.671325¤cy=USD&taxes=3%2C1&coupon=1","transaction_fee":{"currency":"USD","value":"0.62"},"billing_agreement_id":"I-MKX0RAHUCACW","update_time":"2023-12-22T21:32:18Z","protection_eligibility_type":"ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE","protection_eligibility":"ELIGIBLE","links":[{"method":"GET","rel":"self","href":"https://api.sandbox.paypal.com/v1/payments/sale/1SK68449YM493670F"},{"method":"POST","rel":"refund","href":"https://api.sandbox.paypal.com/v1/payments/sale/1SK68449YM493670F/refund"}],"id":"1SK68449YM493670F","state":"completed","invoice_number":null},"links":[{"href":"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-0UX959158W078642N-2MW5123584490731L","rel":"self","method":"GET"},{"href":"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-0UX959158W078642N-2MW5123584490731L/resend","rel":"resend","method":"POST"}]} payload {"stdClass":{"id":"WH-0UX959158W078642N-2MW5123584490731L","event_version":"1.0","create_time":"2023-12-22T21:32:24.574Z","resource_type":"sale","event_type":"PAYMENT.SALE.COMPLETED","summary":"Payment completed for $ 3.67 USD","resource":{"amount":{"total":"3.67","currency":"USD","details":{"subtotal":"3.67"}},"payment_mode":"INSTANT_TRANSFER","create_time":"2023-12-22T21:32:18Z","custom":"id=3QWVF5ZswM&user=1&plan=2&interval=monthly&renew=10.4895&amount=3.671325¤cy=USD&taxes=3%2C1&coupon=1","transaction_fee":{"currency":"USD","value":"0.62"},"billing_agreement_id":"I-MKX0RAHUCACW","update_time":"2023-12-22T21:32:18Z","protection_eligibility_type":"ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE","protection_eligibility":"ELIGIBLE","links":[{"method":"GET","rel":"self","href":"https://api.sandbox.paypal.com/v1/payments/sale/1SK68449YM493670F"},{"method":"POST","rel":"refund","href":"https://api.sandbox.paypal.com/v1/payments/sale/1SK68449YM493670F/refund"}],"id":"1SK68449YM493670F","state":"completed","invoice_number":""},"links":[{"href":"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-0UX959158W078642N-2MW5123584490731L","rel":"self","method":"GET"},{"href":"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-0UX959158W078642N-2MW5123584490731L/resend","rel":"resend","method":"POST"}]}} `
Variable assignment fixed.
For some reasons the WH verification fails when If you want to test you can try the webhook |
Allow to add custom id for invoice id.