Payment-method icon

PayNow iOS Component

Add PayNow to your existing iOS Components integration.

Our PayNow Component renders PayNow in your payment form.

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 PayNow in your Customer Area.

Show PayNow in your payment form

Include PayNow in the list of available payment methods.

  1. Specify in your /paymentMethods request:

  2. Decode the /paymentMethods response with the PaymentMethods structure.

    Copy code
    let paymentMethods = try JSONDecoder().decode(PaymentMethods.self, from: paymentMethodsResponse)

    Find paymentMethods.type paynow and put it into an object. For example, paynowPaymentMethod.

  3. Create an instance of APIContext with the following parameters:

    Parameter name Required Description
    clientKey -white_check_mark- Your client key.
    environment -white_check_mark- Use test. When you are ready to accept live payments, change the value to one of our live environments
    APIContext initialization
    Expand view
    Copy link to code block
    Copy code
    Copy 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)
  4. Initialize the PayNow Component:

    Copy code
    let paynowComponent = paynowComponent(paymentMethod: paynowPaymentMethod, apiContext: apiContext)
    paynowComponent.delegate = self
    // In this example, the Pay button will show 10 SGD.
    // The value is in minor units. Change the currencyCode to the currency for the PayNow Component.
    paynowComponent.payment = Payment(amount: Amount(value: 1000,
    currencyCode: "SGD"))
    present(paynowComponent.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.

  1. Pass the data.paymentMethod to your server.
  2. From your server, make a /payments request, specifying paymentMethod.type: the data.paymentMethod from your client app.

    Expand view
    Copy link to code block
    Copy code
    Copy code
    curl 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": "SGD",
    "value": 1000
    },
    "paymentMethod": {
    "type": "paynow"
    },
    "reference": "YOUR_ORDER_NUMBER"
    }'

    The response contains the following data:

    • resultCode: Pending
    • action: Contains the QR code qrCodeData.
    /payments response
    Expand view
    Copy link to code block
    Copy code
    Copy code
    {
    "resultCode": "Pending",
    "action": {
    "paymentData": "Ab02b4c0!BQABAgA...",
    "paymentMethodType": "paynow",
    "type": "qrCode",
    "qrCodeData": "DMhpN90TFR2e7TzwHYRFkhw4brxm2wHBg"
    }
    }

Show the QR code

Use the information in the action object of the /payments response to render 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.

Test and go live

Before you can accept live payments, you must contact our Support Team to add PayNow in your live Customer Area.

You can penny test PayNow payments in your live Customer Area, using small amounts and a real banking app to scan a test QR.

You can check the status of PayNow payments in your live Customer Area > Transactions > Payments.

We recommend not to test PayNow payments in your test Customer Area. You cannot reverse bank transfers in the test environment, and the funds will be deducted from the bank account.

See also