#romerocox-webhooks

1 messages ยท Page 1 of 1 (latest)

rough cipher
#

Hello! Let's start with the webhooks - what issue are you having?

copper pier
#

hey Karbi, it returns 400 bad request.

rough cipher
#

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?

copper pier
#

Undefined index: HTTP_STRIPE_SIGNATURE in

#

$sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE'];
$event = null;

#

this is from the docs

rough cipher
#

Which docs were you following?

copper pier
#

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

rough cipher
#

Where are you seeing the 'Undefined index: HTTP_STRIPE_SIGNATURE in' error?

copper pier
#

server error logs

#

PHP Notice: Undefined index: HTTP_STRIPE_SIGNATURE in /home/wpnx80wu4brp/public_html/euteaviso.com/api/webhook.php on line 21

rough cipher
#

Can you add logs to print out the full $payload you get before the '$sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE'];' line?

copper pier
#

sure

#

$payload contains the request as expected

#

should I share?

#

I'm now doing the same with the $sig_header

rough cipher
#

Yes, please share what you see in the $payload

copper pier
#

sig_header = t=1656352234,v1=d232bbef3a38efa2d79a9d4fa8cf84e2d3a48a5331c526260bd0ecfba27d9954

#

except the 'pay_load:' part

rough cipher
#

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?

copper pier
#
#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

rough cipher
#

It shouldn't change once it's been set, but it's unique to each webhook endpoint

copper pier
#

yeah that was it

#

shame on me, I apologize.

#

such a newbie

#

I'm now debugging the trial_end issue

rough cipher
#

phew! glad that took care of the webhook issues ๐Ÿ™‚

#

Now what's your question on trials?

copper pier
#

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

rough cipher
#

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)

copper pier
#

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?

rough cipher
#

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

copper pier
#

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 ?

rough cipher
#

No, it's just be $subscription->pending_setup_payment->client_secret

copper pier
#

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?

rough cipher
#

I believe you just need to change 'confirmPayment' -> 'confirmSetup'

copper pier
#

so if the CX is upgrading his sub then I should still use the payment_intent, right?

rough cipher
#

yup!

#

(but only if payment is needed for the update)

copper pier
#

I have always_invoice setup

#

would this change things?

rough cipher
#

No, that shouldn't change things ๐Ÿ™‚

copper pier
#

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 ?

rough cipher
#

If you include 'card' then it should include apple pay and google pay automatically

copper pier
#

great! thanks!

rough cipher
#

wait, did you also ask some questions about the setup intent ID?

copper pier
#

I did but no longer needed my friend haha

rough cipher
#

๐Ÿ‘ perfect

copper pier
#

is it possible to add coupons to the element payment using Stripe.js?

#

Any additional parameter or I should build that on my own

rough cipher
#

You'd have to include that in the Subscription creation call and collect it in your own UI