Payment Flow
An integration towards Nets Easy requires having the paymentId(transactionID) created before the checkout is initialized. Your mobile application can use one of the available integration types, based on your business requirements:
HostedPaymentPage (recommended): the Nets Easy checkout page is hosted by Nets Easy and will handle all checkout initialization. This is the suggested approach if your business has only mobile commerce integration.
EmbeddedCheckout (not recommended): The checkout page will be hosted by you, and also all the checkout initialization and JavaScript callback handling. You can refer the documentation here.
Your application must follow the next flow:
-
- Your mobile application will call an API on your backend to generate the PaymentID. Your backend will call the Nets EASY REST payment API to fetch the required ID, store it in the Database, then return it back to calling application.
IMPORTANT: While making the API call for creating a payment, make sure you add
"commercePlatformTag" : "iOSSDK"
in the request header. This is critical to identify the platform from which the payment is initiated.let headers: HTTPHeaders = [ "Authorization": token, "Content-Type": "application/json", "commercePlatformTag" : "iOSSDK" ]
Based on your chosen integration type, you need to consider the following:
* **HostedPaymentPage <span style="color:green">(recommended)</span>**: * In the request body, under **checkout** object, make sure to send the parameters: `integrationType = HostedPaymentPage` and `returnURL = YOUR RETURN URL`. Make sure that the parameter `url` is not sent. Nets Easy will initialize the checkout, and will return to you the `paymentId` and the `hostedPaymentPageUrl`. **Note**: The value for `returnUrl` must be your app scheme URL (for ex. `eu.nets.miaSample://`). It is just for detection purpose only for the SDK to know when the checkout process has completed and an indication to the wallet app to switch back to your app after finishing the payment.
-
Apart from the standard checkout, Nets EASY supports prefilling the consumer data while creating the payment ID to offer a faster checkout and better user experience. Based on your requirement, Nets EASY supports the following types of Consumer Data Handling by the merchant.
Inject address mode :
The merchant’s app can prefill the consumer data and send it to Nets EASY Checkout while creating the payment ID. The checkout object under the request body must contain the
consumer
data andmerchantHandlesConsumerData = true
. Here is an example :"checkout": { ... "consumer":{ "email":"john.doe@doemail.com", "shippingAddress":{ "addressLine1":"Toodels street 1", "addressLine2":"Co/ John", "postalCode":"0956", "city":"Stockholm", "country":"SWE" }, "phoneNumber":{ "prefix":"+46", "number":"0123456789" }, "privatePerson":{ "firstName":"john", "lastName":"Doe" } }, "merchantHandlesConsumerData": true }
No Shipping mode
If the purchase does not require physical shipping, then the merchant app can prefill only the
email
andpostalCode
along withmerchantHandlesConsumerData = true
while creating the payment ID. Here is an example :"checkout": { ... "consumer":{ "email":"john.doe@doemail.com", "shippingAddress":{ "postalCode":"0956", } }, "merchantHandlesConsumerData": true }
Normal checkout | Merchant handled consumer data checkout |
---|---|
Presenting Mia SDK Checkout WebView
After obtaining a payment ID from Nets Easy (Create Payment API call), typically following a user-action to continue with checkout, present the checkout WebView using Mia SDK as follows:
let miaSDK = MiaSDK.checkoutControllerForPayment(
withID: paymentId,
paymentURL: paymentURL,
isEasyHostedWithRedirectURL: easyHostedRedirectURL,
cancelURL: cancelURL,
success: { controller in /* handle success */ },
cancellation: { controller in /* handle cancellation */ },
failure: { controller, error in /* handle failure */ }
)
Handle completion by dismissing the controller
and optionally displaying the associated result to the user.
In case of failure, an Error
object is returned containing the details.
Note:
We recommend that you keep all error codes internal without showing them to your users. Instead, you should provide generic messages encouraging them to retry the transaction, to select another payment method, or to contact your customer service. Further detail regarding the error is accessible using the Payout API
Payment URL: For this integration type, the
paymentURL
is obtained in the JSON response of create-payment API request; underhostedPaymentPageUrl
key.Redirect URL: The SDK expects the same redirect URL that was passed in create-payment API request under
returnUrl
key. Pass this value to the SDK inisEasyHostedWithRedirectURL
parameter.Cancel URL: The SDK expects the same cancel URL that was passed in create-payment API request under
cancelUrl
key. Pass this value to the SDK incancelURL
parameter. ({"order" : {…}, "checkout" : { "returnUrl" : string,"cancelUrl" : string, …} }
)
Customize the embedded checkout
You can customize the content of the checkout. Refer this link
Important: Once a purchase is completed, the customer must receive a confirmation of the order and a receipt in the form of an on-screen-display and e-mail. Meaning that after you call Charge Payment, you need to call Get Payment API to retrieve the payment information and display it to the user.
Digital Wallets (MobilePay,Vipps,Swish)
Nets Easy Checkout includes Digital Wallets as payment methods.
The MiA SDK has the ability to app switch to the Vipps and MobilePay wallet apps. In order for the MiA SDK to perform app detection, you need to add the wallet app schemes (shown below) under the LSApplicationQueriesSchemes
key in your Info.plist file. If you skip this step, the MiA SDK will not be able to make an app switch to the mobile wallet even though the wallet app is installed on the device.
Vipps
<key>LSApplicationQueriesSchemes</key>
<array>
<string>vipps</string>
<string>vippsMT</string>
</array>
MobilePay
<key>LSApplicationQueriesSchemes</key>
<array>
<string>mobilepayonline</string>
<string>mobilepayonline-test</string>
</array>