adyen-ios: iOS Drop-in - 500 Bad request

Hello! i am trying to initialize drop-in ios 5.0 with react native (my custom module) according to this guide: https://docs.adyen.com/online-payments/ios/drop-in

When I click on the Pay button i get error: 500 Bad request: photo_2022-12-16_17-26-02

Seems the documentation is not quite correct. For example:

Doc: let apiContext = APIContext(clientKey: clientKey, environment: Environment.test) Xcode says: try APIContext(environment: Environment.test, clientKey: clientKey)

Doc:

let configuration = AdyenSession.Configuration(sessionIdentifier: sessionId,
                                               initialSessionData: data,
                                               adyenContext: adyenContext)

Xcode says:

let configuration = AdyenSession.Configuration(sessionIdentifier: sessionId
                                                   initialSessionData: sessionData,
                                                   context: self.adyenContext!)

AdyenSession.initialize should be wrapped DispatchQueue.main.async

Doc: let dropInConfiguration = DropInComponent.Configuration(adyenContext: adyenContext) Xcode says: dropInConfiguration = DropInComponent.Configuration()

Doc:

let dropInComponent = DropInComponent(paymentMethods: session.sessionContext.paymentMethods,
                                      configuration: dropInConfiguration) 

Xcode says: let dropInComponent = DropInComponent(paymentMethods: session!.sessionContext.paymentMethods, context: adyenContext!,configuration: dropInConfiguration!)

  1. Show Drop-in in your app. This place is not very clear in the documentation.
    present(dropInComponent.viewController, animated: true)

I looked at the example in your repository and do it like this:

extension UIViewController {
    internal static var topPresenter: UIViewController? {
        var topController: UIViewController? = UIApplication.shared.keyWindow?.rootViewController
        
        while let presenter = topController?.presentedViewController {
            topController = presenter
        }
        return topController
    }
}

extension AdyenModule: PresentationDelegate {
    internal func present(component: PresentableComponent) {
        self.present(component)
    }
}

in my class:

func present(_ component: PresentableComponent) {
    currentPresenter = UIViewController.topPresenter
    currentPresenter?.present(component.viewController, animated: true)
  } 

and then: present(component: dropInComponent!)

Help me please, any ideas what could have gone wrong and what should I check again?

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

This thread is enormous amount of improvements for our documentation đź’š We are grateful for your feedback!

@anton0243

Do I understand correctly that sessions is more modern implementation that will replace endpoint integration in the future?

It will not replace endpoint integration. Both approaches will coexist.

Will it support sessions or only endpoint integration?

“Drop-in and Component for React Native” does not yet support sessions due to the fact that our native Android SDK does not support it. We expect it around Q3 2023, but no feasible timeline just yet.

Yes, I tried to use adyen test cards and my card from the wallet. Same result…

This error could happen if our backend sent a POST redirect instead of GET redirect. What returnURL are you using? “http://” or Custom URL scheme ?

UPD

This description of returnURL is copied from WEB and incorrect for iOS: https://docs.adyen.com/online-payments/ios/drop-in#create-a-payment-session

You can find out more about returnURL here https://docs.adyen.com/online-payments/ios/drop-in/integrated-before-5-0-0#step-3-make-a-payment