Our PromptPay Component renders PromptPay in your payment form and collects your shopper's selected bank.
Requirements
Select the server-side flow that your integration uses:
Requirement | Description |
---|---|
Integration type | Make sure that you have built a Sessions flow iOS Components integration. |
Setup steps | Before you begin, contact our Support Team to add PromptPay in your Customer Area. |
Show PromptPay in your payment form
Include PromptPay in the list of available payment methods.
-
Specify in your /paymentMethods request:
- countryCode: TH.
- amount.currency: THB.
- channel: Specify iOS.
-
Decode the
/paymentMethods
response with thePaymentMethods
structure.let paymentMethods = try JSONDecoder().decode(PaymentMethods.self, from: paymentMethodsResponse)
Find
paymentMethods.type
promptpay and put it into an object. For example,promptpayPaymentMethod
. -
Create an instance of
APIContext
with the following parameters:Parameter name Required Description clientKey
Your client key. environment
Use test. When you are ready to accept live payments, change the value to one of our live environments. APIContext initializationExpand viewCopy link to code blockCopy code// When you are ready to go live, change environment to Environment.live // You can also use other environment values described in https://adyen.github.io/adyen-ios/Docs/Structs/Environment.html let apiContext = APIContext(environment: Environment.test, clientKey: clientKey) -
Initialize the PromptPay Component:
let promptpayComponent = PromptPayComponent(paymentMethod: promptpayPaymentMethod, apiContext: apiContext) promptpayComponent.delegate = self // In this example, the Pay button will show 10 <strong>THB</strong>. // The value is in minor units. Change the currencyCode to the currency for the PromptPay Component. promptpayComponent.payment = Payment(amount: Amount(value: 1000, currencyCode: "<strong>THB</strong>")) present(promptpayComponent.viewController, animated: true)
Make a payment
When the shopper proceeds to pay, the Component invokes the didSubmit
method containing the data.paymentMethod
from the PaymentComponentDelegate
.
- Pass the
data.paymentMethod
to your server. -
From your server, make a /payments request, specifying:
paymentMethod.type
: Thedata.paymentMethod
from your client app.
Expand viewCopy link to code blockCopy codecurl https://checkout-test.adyen.com/v69/payments \ -H 'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "amount": { "currency": "THB", "value": 10000 }, "paymentMethod": { "type": "promptpay" }, "reference": "YOUR_ORDER_NUMBER" }' The response contains the following data:
resultCode
: Pendingaction
: Contains the QR codeurl
andqrCodeData
.
{ "pspReference": "8815658961765250", "resultCode": "Pending", "action": { "paymentData": "Ab02b4c0!BQABAgA...", "paymentMethodType": "promptpay", "type": "qrCode", "url": "https://test.adyen.com/hpp/generateQRCodeImage.shtml?url=DMhpN90TFR2e7TzwHYRFkhw4brxm2wHBg", "qrCodeData": "DMhpN90TFR2e7TzwHYRFkhw4brxm2wHBg" } }
Show the QR code
Use the information in the action
object of the /payments response to render the QR code.
action.url
: Use this URL to download the QR code.action.qrCodeData
: Use this to render the QR code on your checkout page.
The shopper can either scan the QR code, or take a screenshot of the QR code and upload it to their bank app.
Show the payment result
Use the resultCode
from the /payments/details response to show the payment outcome on your frontend.
You will also receive the outcome of the payment asynchronously in a webhook.
The resultCode
values you can receive for PromptPay are:
eventCode | success field | Description | Action to take |
---|---|---|---|
AUTHORISATION | false | The transaction failed. | Cancel the order and inform the shopper that the payment failed. |
AUTHORISATION | true | The shopper successfully completed the payment. | Inform the shopper that the payment has been successful and proceed with the order. |
Test and go live
Test PromptPay payments with real payment details and small amounts.
Check the status of your test PromptPay payments in your Customer Area > Transactions > Payments.
To accept live PromptPay payments, you must contact our Support Team to add PromptPay in your live Customer Area.