Code=50 “No such payment_intent” when confirm payment intent for stripe
Asked Answered
T

4

8

I am getting following error while confirming payment intent using this method STPAPIClient.shared().confirmPaymentIntent()

Error Domain=com.stripe.lib Code=50 "No such payment_intent: pi_1ElaQpFSNNCQ7y59" UserInfo={com.stripe.lib:ErrorMessageKey=No such payment_intent: pi_1ElaQpFSNNCQ7y59, com.stripe.lib:StripeErrorCodeKey=resource_missing, com.stripe.lib:StripeErrorTypeKey=invalid_request_error, com.stripe.lib:ErrorParameterKey=intent, NSLocalizedDescription=No such payment_intent: pi_1ElaQpFSNNCQ7y59}

Code which I am executing:

STPAPIClient.shared().confirmPaymentIntent(with: paymentIntentParams, completion: { (paymentIntent, error) in

if let error = error {

    // handle error

} else if let paymentIntent = paymentIntent {

    // see below to handle the confirmed PaymentIntent

    if paymentIntent.status == .requiresAction {

        guard let redirectContext = STPRedirectContext(paymentIntent: paymentIntent, completion: { clientSecret, redirectError in

            // Fetch the latest status of the Payment Intent if necessary
            STPAPIClient.shared().retrievePaymentIntent(withClientSecret: clientSecret) { paymentIntent, error in

                // Check paymentIntent.status
            }

        })else{

            // This PaymentIntent action is not yet supported by the SDK.
            return;
        }
        redirectContext.startRedirectFlow(from: self)

    }else{
         // Show success message
    }
}
})
Tannin answered 15/6, 2019 at 12:9 Comment(2)
The payment intent id looks much shorter than what Stripe's payment intent id. Can you make sure you are actually using the correct id?Schlicher
The id returned in the error is just the id of the intent. It is shorter but very similar to the intent's client secret. I'm getting the same error with the JS api, did you find a solution to this?Mucker
H
12

In case of if you are using stripe connect(direct charge) feature you need to pass stripe connected account id(stripeAccount) while creating stripe instance in frontend side. see below example

var stripe = Stripe(STRIPE_PUBLIC_KEY, { stripeAccount: "{{ connected_account }}" });
Horning answered 20/9, 2019 at 9:32 Comment(3)
you sir just saved my bacon, nothing short of legen...daryDeciare
@Horning This is what I was missing in my case too. Thanks a lot for this.Axseed
I do this and see "received unknown parameter: stripeAccount"Exarch
T
5

I've had a similar problem with the JS api ('No such payment_intent'). My mistake was that I was using stripe.handleCardPayment instead of stripe.handleCardSetup with a client_secret of a SetupIntent.

Titlark answered 7/8, 2019 at 9:58 Comment(0)
S
2

add this method in your code and set this sourceid to paymentIntentParams.paymentMethodId = sourceid rest same set this source id to paymentid.

 STPAPIClient.shared().createPaymentMethod(with: paymentMethodParams) { paymentMethod, error in
            if error == nil {
                let data = paymentMethod as? STPSource
                sourceid = paymentMethod?.stripeId ?? ""
                print(paymentMethod)
                self.intentMakePayment(sourceid)
            }
        }
Schlenger answered 28/8, 2019 at 6:14 Comment(0)
P
0

So I got the same problem with Stripe Connect and iOS. To use that along with client secret or in my case EphemeralKeyProvider, here's the call to inject the Stripe Connect account parameter.

STPAPIClient.shared().stripeAccount = "KEY_PROVIDED_HERE"

This will allow Stripe Connect to confirm the payment methods.

Pizzicato answered 26/5, 2020 at 13:30 Comment(1)
I would like to try your solution - where can the KEY_PROVIDED_HERE accountId be found in Stripe dashboard? I am not seeing it. Thank youZecchino

© 2022 - 2024 — McMap. All rights reserved.