This page explains how to add TWINT to your existing Drop-in integration.
The focus of this page is on describing how to use the TwintComponent
of the native Twint SDK to enable Twint payments on Drop-in.
Requirements
Requirement | Description |
---|---|
Integration type | Make sure that you have built your Drop-in integration. |
Setup steps | Before you begin, add TWINT in your test Customer Area. |
How it works
-
When a shopper on your app clicks the button to pay with Twint,
TwintComponent
makes a /payments request which containssubtype: sdk
. TheActionComponent
is triggered, which determines the transaction flow. -
The shopper is redirected to the Twint app on their device (or an error is displayed if a Twint app is not installed).
-
After the payment is processed, Twint app will return back to your app using the
redirectURL
, contained in the payment result. -
If the payment is successful a /payments/details request is made that contains
paymentData
, otherwise an error is shown.
Drop-in configuration
Add the following configuration:
-
Create a
TwintPaymentMethod
instance from your payment methods list.Create TwintPaymentMethod instanceExpand viewCopy link to code blockCopy codelet paymentMethod = paymentMethods.paymentMethod(ofType: TwintPaymentMethod.self)
-
Create the
TwintComponent
with thepaymentMethod
and the configuration.Create TwintComponentExpand viewCopy link to code blockCopy codelet component = TwintComponent(paymentMethod: paymentMethod, context: adyenContext, configuration: configuration)
-
Set your
AdyenSession
instance as the delegate to let it handle the flow.Set AdyenSessionExpand viewCopy link to code blockCopy codecomponent.delegate = self.adyenSession
-
Your app must configure a
callbackAppScheme
so that it is reopened when the payment is done.Configure callbackAppSchemeExpand viewCopy link to code blockCopy codecomponentConfig.actionComponent.twint = .init(callbackAppScheme: yourReturnURLScheme)
-
Your app should call the
RedirectComponent
in theAppDelegate
by adding below method.Call RedirectComponentExpand viewCopy link to code blockCopy codefunc application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool { RedirectComponent.applicationDidOpen(from: url) return true } -
Register all the apps that will be opened by your app by adding the following entries to your App’s
Info.plist file
. If this is not done, then TWINT SDK will not find any installed TWINT app.Register appsExpand viewCopy link to code blockCopy code<key>LSApplicationQueriesSchemes</key> <array> <string>twint-issuer1</string> <string>twint-issuer2</string> <string>twint-issuer3</string> <string>twint-issuer4</string> <string>twint-issuer5</string> <string>twint-issuer6</string> <string>twint-issuer7</string> <string>twint-issuer8</string> <string>twint-issuer9</string> <string>twint-issuer10</string> <string>twint-issuer11</string> <string>twint-issuer12</string> <string>twint-issuer13</string> <string>twint-issuer14</string> <string>twint-issuer15</string> <string>twint-issuer16</string> <string>twint-issuer17</string> <string>twint-issuer18</string> <string>twint-issuer19</string> <string>twint-issuer20</string> <string>twint-issuer21</string> <string>twint-issuer22</string> <string>twint-issuer23</string> <string>twint-issuer24</string> <string>twint-issuer25</string> <string>twint-issuer26</string> <string>twint-issuer27</string> <string>twint-issuer28</string> <string>twint-issuer29</string> <string>twint-issuer30</string> <string>twint-issuer31</string> <string>twint-issuer32</string> <string>twint-issuer33</string> <string>twint-issuer34</string> <string>twint-issuer35</string> <string>twint-issuer36</string> <string>twint-issuer37</string> <string>twint-issuer38</string> <string>twint-issuer39</string> <string>twint-issuer40</string> <string>twint-issuer41</string> <string>twint-issuer42</string> <string>twint-issuer43</string> <string>twint-issuer44</string> <string>twint-issuer45</string> <string>twint-issuer46</string> <string>twint-issuer47</string> <string>twint-issuer48</string> <string>twint-issuer49</string> <string>twint-issuer50</string> </array>
Recurring payments
To make recurring payments for TWINT, you need to:
Create a token
To create a token, include in your /payments request:
storePaymentMethod
: true- shopperReference: Your unique identifier for the shopper (minimum length three characters).
When the payment details have been stored, you receive a webhook containing:
eventCode
: RECURRING_CONTRACToriginalReference
: ThepspReference
of the initial payment.pspReference
: This is the token you need to make recurring payments for this shopper.
Make sure that your server is able to receive RECURRING_CONTRACT as part of your standard webhooks. If you have not requested this additional configuration yet, contact our Support Team.
Make a payment with a token
To make a payment with the token, include in your /payments request:
-
paymentMethod.storedPaymentMethodId
: ThepspReference
from the RECURRING_CONTRACT webhook.You can also get this value using the /listRecurringDetails endpoint.
-
shopperReference
: The unique shopper identifier that you specified when creating the token (minimum length three characters). -
shopperInteraction
: ContAuth. -
recurringProcessingModel
: Subscription or UnscheduledCardOnFile.
For more information about the shopperInteraction
and recurringProcessingModel
fields, refer to Tokenization.
curl https://checkout-test.adyen.com/checkout/v69/payments \ -H 'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "amount":{ "value":1000, "currency":"CHF" }, "paymentMethod":{ "type":"twint", "storedPaymentMethodId":"7219687191761347" }, "reference":"YOUR_ORDER_NUMBER", "merchantAccount":"YOUR_MERCHANT_ACCOUNT", "shopperReference":"YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j", "shopperInteraction":"ContAuth", "recurringProcessingModel": "Subscription" }'
Recurring payments only work when the amount is equal to zero.
Test and go live
Check the status of TWINT test payments in your Customer Area > Transactions > Payments.
Before you can accept live TWINT payments, you need to submit a request for TWINT in your live Customer Area.