#jespr

1 messages · Page 1 of 1 (latest)

neat summitBOT
foggy junco
#

This is the screen. "Stäng" in the top left corner is the close button I'm referring to. Apologize for the non-English

thorny crow
#

I believe it should close itself and not have that interstitial page if you set up a returnURL

foggy junco
#

I do get the returnURL callback, but if I use that to close the view, the confirmPayment completion callback isn't run.

#

And Stripe's internal cleanup (like resetting the inProgress flag) isn't run.

thorny crow
#

that feels like a bug then really

#

are you using the latest version of the SDK?

foggy junco
#

23.5.1

#

I can see that is not the latest, so let me try upgrading.

thorny crow
#

when you say you're using confirmPayment and want this callback(on the delegate I assume) what exact integration are you using, what does the code look like?

#

we generally highly suggest using the PaymentSheet integration only

foggy junco
#

We have a custom UI. The function (and callback) I'm referring to is: STPPaymentHandler.sharedHandler.confirmPayment

thorny crow
#

yeah that's what I thought

#

maybe there's a bug? I just tested Klarna using PaymentSheet and it works perfectly, the webview of their page closes and my code gets the result correctly and it's all good.

I might still have some code to use that other integration, let me try replicate

#

but yeah we heavily recommend PaymentSheet and it's where all our development goes really

foggy junco
#

That's good to know.

thorny crow
#

so I'm just trying it now and it seems to work fine

foggy junco
#

Unfortunately same result with the latest SDK. I'll see if I can reproduce the result with a test project. Bug reports go to github if it turns out I can?

thorny crow
#

give me a bit to show you the code I use and stuff.

foggy junco
#

That would be amazing.

thorny crow
#

so for example I do this and the success print line happens

  @objc func handleTestButtonTapped(){
        let paymentIntentClientSecret = "pi_xxx_secret_yyy"
        
        
        let paymentIntentParams = STPPaymentIntentParams(clientSecret: paymentIntentClientSecret)
        
        // Billing details
        let billingDetails = STPPaymentMethodBillingDetails()
        billingDetails.email = "email@email.com"
        let billingAddress = STPPaymentMethodAddress()
        billingAddress.country = "BE"
        billingDetails.address = billingAddress
        
       
        // Klarna PaymentMethod params
        let klarnaParams = STPPaymentMethodParams(klarna: STPPaymentMethodKlarnaParams(),
                                                                                     billingDetails: billingDetails,
                                                                                     metadata: nil)
        
        paymentIntentParams.paymentMethodParams = klarnaParams
        paymentIntentParams.returnURL="com.myapp://sheet-redirect"

        STPPaymentHandler.shared().confirmPayment(withParams: paymentIntentParams, authenticationContext: self) { (handlerStatus, paymentIntent, error) in
            switch handlerStatus {
            case .succeeded:
                // Payment succeeded
                print("klarna success")
            case .canceled:
                // Payment was cancelled
                print("canceled")
            case .failed:
                // Payment failed
                print("failed")
                print(error)
            @unknown default:
                fatalError()
            }
        }
    }
foggy junco
#

That looks promising. Do you do anything with the return URL callback?

thorny crow
#

I just do what our docs say

foggy junco
#

Got it.

#

Seems less likely to be a bug on your side then. I'll dig a bit further into it here.

#

Really appreciate all the feedback.

thorny crow
#

the fact you even get the "return to merchant" button to me heavily implies you're missing the returnURL or it's nil or not configured in your app's XCode settings or something

foggy junco
#

Well, it is there. Without it, I get an error trying to confirm the payment in the first place. But the code handling those links is a bit complicated (we have many different deep links), so there might something going wrong there.

neat summitBOT