ASWebAuthenticationSession
For iOS usage scenario, using the ASWebAuthenticationSession is one of the recommended ways.
After creating the transaction and getting the transaction link, the following implementation is recommended:
In your common flow (which IDPay is inserted) you will open the ASWebAuthenticationSession with the link generated through the API;
Customize this opening in any way that is ideal for your application;
Monitor if the URL has changed (to redirectUrl) and then close the WKWebView;
To make the flow work, follow these steps:
Step 1: Create the payment authentication controller
OCreate a class called IDPayAuthenticationController
(or whatever you prefer to call it).
Then, import the AuthenticationServices
ramework at the top of the class.
Declare the class as NSObject
and implement the ASWebAuthenticationPresentationContextProviding
protocol.
The result should be:
Step 2: Implement authentication
Open the file where you will perform the authentication and add the necessary imports (the example is done in ContentView.swift
).
To control the authentication state, create a @State
property.
Create an instance of the IDPayAuthenticationController
class outside the body of the ContentView
structure.
To validate the payment create a function called authenticatePayment.
Remember to change the URL_AUTHENTICATION
to the authentication URL received in your transaction. Also change the callbackURLScheme BUNDLE
to the redirect informed at the creation of your transaction (use the Bundle Identifier of your application).
It is important to set the prefersEphemeralWebBrowserSession
to true
to ensure a unique authentication per transaction.
Follows an example of how it should look in the APP:
The following permissions are required to function correctly:
Camera;
Geolocation.
To know more about the WKWebView, the following articles and documentation are recommended:
Access the official documentation at WKWebView.
Still need help?
Didn't find something or still need help? If you're already a client or partner, you can reach out through our Help Center.
Last updated