#op84

1 messages · Page 1 of 1 (latest)

hexed kestrelBOT
cosmic bane
#

Hi

whats the difference between using capture_method or confirmation_method manual?
capture method is used in order to just place a hold on a amount of a card. While confirmation_method manual is to confirm the payment manually (when you want to call /confirm api call by your integration explicitly)

#

do some validation
what kind of validation you want to make ? on the PaymentMethod ?

topaz mist
#

no it's an internal app validation plus discount redemption (custom not from stripe)..

#

but that would be possible to capture the amount first - then do the validation and other stuff.. and if that succeeds capture it or otherwise release the capture or cancel the payment intent right? should work for sepa and card am i correct?

cosmic bane
#

Capture is only for Card payments.

#

For Sepa , you can create a SetupIntent collect PaymentMethods, and then create the PaymentIntent and charge the customer off_session.

topaz mist
#

i was thinking about doing that in the checkout process instead of creating a payment intent creating a setup intent and after that the payment intent.. but someone of your team told me to not do that.. so i'm confused.. setupintent is not async right?

cosmic bane
#

PaymentMethods can be async or not... Payment/Setup Intents are not labelled like that... SetupIntent is for saving PaymentMethod without doing a payment while PaymentIntent is for doing a payment (and optionally save the PaymentMethod, aka off_session usage)

#

but someone of your team told me to not do that.. so i'm confused.
It depends on your exact use case again... every hint are advices/recommendation there isn't only one correct answer... at the end you need to make the choose.

topaz mist
#

i get that payment methods can be async like sepa.. but the setup intent itself.. i can't use a setup intent in the checkout if it's not available asap to create the payment intent.. the payment intent success is another story.. i will get notified by that with a webhook.. but to create a payment intent i need a payment method which i get from the setup intent..

#

so my process would be in the checkout i create the setup intent with stripe elements .. save the payment method.. after that validate the app specific things if there's an app error return back to the cart.. otherwise create the payment intent and charge it with the payment method on file.. this can all be synchronous not async correct?

cosmic bane
#

yes step by step.

topaz mist
#

ok that sounds great so far. setup intents for async and sync payment methods are both syncronous - just checking once again?

cosmic bane
#

PaymentMethod are classified as Sync or Async.. Setup/Payment are not.

topaz mist
#

ok which means when adding payment details to a setupintent i instantly get a payment method to use or an error regardless if card or sepa..?

cosmic bane
#

Yes

topaz mist
#

amazing thanks for that information. another quick question.. when creating a paymentintent with off_session: true and confirm: true (which is required - correct?) it can throw an error if the payment fails.. isn't that the whole purpose of off_session to get the least errors?

cosmic bane
#

it can throw an error if the payment fails.. isn't that the whole purpose of off_session to get the least errors?
Yes, but if for the example the card has no more funds available? you'll get an error.

topaz mist
#

yes then i will get a webhook notification and set the status accordingly.. so can i do something like this?

  def pay_with_default_payment_method!
    company_payment_method = company.default_payment_method
    return if company_payment_method.nil?

    payment_intent = Stripe::PaymentIntent.create(
      {
        payment_method: company_payment_method.stripe_payment_method_id,
        amount: grandtotal_amount.cents,
        customer: company.stripe_customer_id,
        currency: company.currency,
        payment_method_types: PaymentMethod.available_types_for_company(company)
       },
      {
        api_key: tenant.stripe.secret_key
      }
    )
    update!(stripe_payment_intent_id: payment_intent.id)

    begin
      Stripe::PaymentIntent.confirm(
        payment_intent.id, { off_session: true }, { api_key: tenant.stripe.secret_key }
      )
    rescue => e
      Sentry.capture_exception(e)
    end
  end
cosmic bane
#

yes you can test that.

topaz mist
#

alright amazing. thanks for help

cosmic bane
#

Welcome!