#romerocox-webhooks
1 messages ยท Page 1 of 1 (latest)
Do you have any more detail than that? The webhook wouldn't be the one returning a 400 - that would be your server responding back to the event we sent with a 400. Have you done some debugging on your server to pinpoint what the issue could be?
Undefined index: HTTP_STRIPE_SIGNATURE in
$sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE'];
$event = null;
this is from the docs
Which docs were you following?
I mean, the code from the docs
this was given to me when I was adding an endpoint.
you select the events to listen to, and there is a code on the right hand side
Where are you seeing the 'Undefined index: HTTP_STRIPE_SIGNATURE in' error?
server error logs
PHP Notice: Undefined index: HTTP_STRIPE_SIGNATURE in /home/wpnx80wu4brp/public_html/euteaviso.com/api/webhook.php on line 21
Can you add logs to print out the full $payload you get before the '$sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE'];' line?
sure
$payload contains the request as expected
should I share?
I'm now doing the same with the $sig_header
Yes, please share what you see in the $payload
sig_header = t=1656352234,v1=d232bbef3a38efa2d79a9d4fa8cf84e2d3a48a5331c526260bd0ecfba27d9954
payload
except the 'pay_load:' part
Ah, I think the PHP notice log is just a warning - not the root cause of the error.
Have you made sure to replace the $endpoint_secret with the one generated when you created the webhook endpoint?
#1 /home/wpnx80wu4brp/public_html/euteaviso.com/vendor/stripe/stripe-php/lib/Webhook.php(29): Stripe\WebhookSignature::verifyHeader('{\n "id": "evt_...', 't=1656352376,v1...', 'whsec_fa35dec04...', 300)
#2 /home/wpnx80wu4brp/public_html/euteaviso.com/api/webhook.php(31): Stripe\Webhook::constructEvent('{\n "id": "evt_...', 't=1656352376,v1...', 'whsec_fa35dec04...')```
this is what comes out of the exception
oh!
I may have not,
I may have mixed them
I thought it was like an API secret key and would never change
that was it.
it was different, let me retry
It shouldn't change once it's been set, but it's unique to each webhook endpoint
yeah that was it
shame on me, I apologize.
such a newbie
I'm now debugging the trial_end issue
phew! glad that took care of the webhook issues ๐
Now what's your question on trials?
I need a better understanding I guess.
I'm able to create the subscription.
After that, shouldn't I collect the payment details as it was a regular subscription so we can charge the CX once the trial ends?
What happen is that I'm not able to get the secret if I add trial_end at the subscription creation.
That works, but when it gets to the next line:
client_secret does not generates
so I'm unable to mount the element payment
the subscription gets created on the Stripe side, everything is fine.
I must be doing something wrong on the payment side
With trials there is no payment due at the start, so we an't generate a Payment Intent - instead, you'll want to use the client-secret from the Setup Intent found at 'pending_setup_intent' on the Subscription (https://stripe.com/docs/api/subscriptions/object#subscription_object-pending_setup_intent)
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
So I'd need to create the subscription, and after that create the setup intent?
and then, use the client-secret generated from the setup intent to mount the element?
No, the Subscription will create the Setup Intent for you - you'd expand 'pending_setup_intent' when you create the Subscription and it should be right htere
Oh cool, that would be easier ๐
Thanks, let me get to that.
can you please build the road to that client-secret for me?
'customer' => $customer_id,
'items' => [[
'price' => $price_id,
]],
'payment_behavior' => 'default_incomplete',
'payment_settings' => ['save_default_payment_method' => 'on_subscription', 'payment_method_types'=>['card']],
'expand' => ['pending_setup_intent'],
"metadata" => ["cliente_id" => $membro->memberID],
"trial_end"=> $unix
]);```
would that be $subscription->pending_setup_payment->payment_intent->client_secret ?
No, it's just be $subscription->pending_setup_payment->client_secret
cool
thank you
Now, after paying, getting:
No such payment_intent: 'seti_1LFMPWHFtTbW5w9ddyF8iJPd'
from Stripe.js
const paymentElement = elements.create('payment');
this should probably change?
I believe you just need to change 'confirmPayment' -> 'confirmSetup'
so if the CX is upgrading his sub then I should still use the payment_intent, right?
No, that shouldn't change things ๐
ok thank you sir
That should do it for now, I appreciate all the support
qq: under the payment_methods, can I add "wallet"
or apple and google pay would be added automatically anyways ?
If you include 'card' then it should include apple pay and google pay automatically
great! thanks!
wait, did you also ask some questions about the setup intent ID?
I did but no longer needed my friend haha
๐ perfect
is it possible to add coupons to the element payment using Stripe.js?
Any additional parameter or I should build that on my own
You'd have to include that in the Subscription creation call and collect it in your own UI