#riku_code

1 messages · Page 1 of 1 (latest)

next zephyrBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1336254165571338251

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

hollow shoal
#

What's the error message?

left flame
#

No error. I log the response and it seems like a success, but the customer is not listed

#

And in transactions view the transaction says no payment method

hollow shoal
#

What do you mean by "customer not listed"?

#

What's the paymentIntent ID btw?

left flame
#

is it the same as "payment ID"? pi_3QohKOR8CFUKP9Ks2CF95FAk

hollow shoal
#

I don't see any payment intent confirmation request

#

Did you call stripe.confirmCardPayment() ?

left flame
#

I don't want to confirm it yet. This should go like

  1. create the intent and save payment method for Buyer
  2. wait for Seller to reply if they still have the item
  3. If they still have it, confirm the Buyer's payment
  4. When Buyer aknowledges they have received the item, transfer funds to Seller, deducting our comission and shipping cost.
next zephyrBOT
round tusk
#

👋 taking over for my colleague. Let me catch up.

left flame
#

Or am I going the wrong way about it?

#

Maybe I don't fully understand what it means to confirm a payment intent? I basically want to do a reservation on the Buyer's card that is either released of confirmed when the Seller approves the deal.

round tusk
left flame
#

I added capture_method => manual to the creation of the payment intent.
$paymentIntent = \Stripe\PaymentIntent::create([
'amount' => WC()->cart->total * 100, // Amount in cents
'currency' => get_woocommerce_currency(),
'payment_method_types' => ['card'],
'customer' => $stripe_customer_id,
'setup_future_usage' => 'off_session',
'capture_method' => 'manual',
'description' => 'MyySe',
]);

#

So do I now need to confirm it still? And even though it says "manual" it does allow me to do it via the API programatically?

round tusk
#

yes confirming it won't capture the funds

#

you can see in the lifecycle of a PaymentIntent https://docs.stripe.com/payments/paymentintents/lifecycle it has to be confirmed before the processing phase

If you’re separately authorizing and capturing funds, your PaymentIntent can instead move to requires_capture. In that case, attempting to capture the funds moves it to processing.

Learn how PaymentIntents work within the payment flow.

left flame
#

So I don't need the: 'setup_future_usage' => 'off_session', That seems to bring about a Link dialog...

round tusk
#

setup_future_usage is meant to be used to save the PaymentMethod for off session payments in the future

#

you might still need to use that if you wish to charge your customer in the future without having them to provide their payment method again

left flame
#

But for this particular transaction to be finalised within a couple of days, that is not needed?

#

I still get this: Error confirming payment intent: You cannot confirm this PaymentIntent because it’s missing a payment method. To confirm the PaymentIntent with cus_Ri8PIeSFcJjAHu, specify a payment method attached to this customer along with the customer ID.

#

I create the Intent with the customer id like this:
$customer = \Stripe\Customer::create([
$_POST['billing_details']
]);
$stripe_customer_id = $customer->id;

    $paymentIntent = \Stripe\PaymentIntent::create([
        'amount' => WC()->cart->total * 100, // Amount in cents
        'currency' => get_woocommerce_currency(),
        'payment_method_types' => ['card'],
        'customer' => $stripe_customer_id,
        'capture_method' => 'manual',
        'description' => 'MyySe',
    ]);
#

I try to add the payment method to it like this:

paymentElement.on('change', function(event){
console.log(event);
if(event.error){
$('.payment_box.payment_method_myyse_gateway .payment-errors').text(event.error.message);
}
if(event.complete){
stripe.createPaymentMethod({
type: 'card',
card: paymentElement,
pa
}).then(function(result) {
console.log(result);
});
}
})

round tusk
left flame
#

And the element is a 'card' element.

round tusk
#

the confirmation should be made on the frontend side

#

with the PaymentElement

left flame
#

Ah, OK.

round tusk
left flame
#

So basically, I don't even have to create the customer for the payment intent, but I can add billing_details before submitting the form, after user clicks on "confirm"?

round tusk
#

that's one way of doing it yes

#

but if you need to save the payment method for future usage you need the customer object anyways

#

please note that when you add the billing_details on confirm, they will be added to the PaymentMethod object anyways

#

so they're not "directly" saved under the customer

left flame
#

Ah, OK.

#

Thanks for your help. I try to make it work with this information.