#bird-paymentintent-paymentmethod

1 messages ยท Page 1 of 1 (latest)

ashen crownBOT
sonic surge
#

@cunning marsh do you have a more specific question? That PaymentIntent was created successfully and then you didn't do anything else with it. So what's the real problem?

cunning marsh
#

ahh, ok. Well I have a simple elements form it hits this method:

public function charge($amount){    if (!auth()->user()->stripeCustomer()->exists()) {        $stripeCustomer = \Stripe\Customer::create();        \App\Models\StripeCustomer::create([            'user_id'   => auth()->user()->id,            'stripe_id' => $stripeCustomer->id,        ]);    }    try {        return \Stripe\PaymentIntent::create([            'setup_future_usage'        => 'off_session',            'amount'                    => $amount,            'currency'                  => 'usd',            'customer'                  => auth()->user()->stripeCustomer->stripe_id,            'automatic_payment_methods' => ['enabled' => true],        ], ['api_key' => $this->apiKey]);    } catch (InvalidRequestException $e) {        throw new PaymentFailedException();    }}
sonic surge
#

that's just a dump of unformatted server-side PHP code. What is your question?

#

bird-paymentintent-paymentmethod

cunning marsh
#

ok, tried to format a bit. So a user selects quantity and when they hit submit this charge() method is hit. It check if there is a stripeCustomer. If not, it creates one.

Then a payment intent is created, and the system creates one of our own orders.

So, what from stripes perspective needs to happen after the PaymentIntent is created?

#

It seems like all the info should be available?

#

it's a card element

sonic surge
#

I'm sorry I have no idea what any of this could mean at all. You keep talking about " a card element" but also only share PHP code

#

A PaymentIntent represents the intent to accept a payment from a Customer for a certain amount/currency. Creating it is solely that intent, it doesn't "charge" a card or anything

cunning marsh
#

I'm upgrading from the 2018 api. So that used to have a charge object. Is there an equavalent for this?

#

just uploaded the js/blade.php file where the form lives.

sonic surge
ashen crownBOT
cunning marsh
#

Hey no prob. just deleted. I thought it was specific - please pardon me there if it is not clear.

After creating a payment intent a charge did not get made with a payment card element.

woeful marlin
#

๐Ÿ‘‹ Hopping in here - are you sure you're actually confirming the PaymentIntent?

cunning marsh
#

yea, that seems to be what I'm missing. Appreciate that last doc. It seems like I should have a separate method for createPaymentIntent then return that to the browser, then confirm. It seems like I had the order of things messed up with the old charge payment flow....

#

going to step away for lunch but will be back...

woeful marlin
#

๐Ÿ‘ (we usually archive threads if it's been more than an hour since the last response, but if this thread is closed by the time your back feel free to ask again in the main channel)

#

It seems like I should have a separate method for createPaymentIntent then return that to the browser, then confirm.
Yup, generally that's how the flow should work