Skip to main content
Cashfree’s iOS custom checkout integration enables merchants to embed a secure payment experience directly within their iOS applications using WKWebView, supporting a wide variety of payment methods.

Key benefits

  • Secure and PCI compliant: Securely collects payment details and submits them directly to Cashfree servers, removing the need for Payment Card Industry Data Security Standard (PCI DSS) compliance requirements at the merchant’s end.
  • Native iOS integration: Seamlessly integrate payments into your iOS app using WKWebView without requiring third-party SDKs.
  • Support for multiple payment methods: Accepts payments from over 120 payment methods including UPI Intent for direct app-to-app transfers.

Prerequisites

  1. Create a Cashfree Merchant Account and log in.
  2. Navigate to Developers > API Keys to generate your App ID and Secret Key. Learn how to generate API keys.
  3. Minimum iOS version is iOS 11.0 with WKWebView support.
The iOS checkout integration consists of three essential steps:

Step 1

Create Order

Step 2

Submit Form

Step 3

Handle Redirection

Step 1: Create order Server-side

Create an order from your backend before processing the payment. This is a server-side operation and must not be called from the client side.
  • Create orders through your backend, as this API requires your secret key.
  • Always provide a return URL when creating the order—it will be used to detect when the payment flow is complete.
You can follow the order creation steps in the Cashfree Hosted Checkout documentation. This will return a “payment_session_id” which will be used in the subsequent steps.

Step 2: Submit form Client-side

Submit the checkout form from your app’s web view using the payment session ID obtained from Step 1.
This step requires your application’s bundle ID to be whitelisted by Cashfree Payments. Please check Bundle ID Whitelisting.
Swift

Step 3: Handle redirection Client-side

Once the payment flow has ended, Cashfree Payments will redirect you to the URL specified while creating the order. Detect the URL redirection and close the web view appropriately.
Swift

UPI intent from checkout

UPI Intent allows users to make direct payments through installed UPI applications without entering payment details manually. If you want to add UPI intent functionality to your custom iOS checkout integration, follow the steps below.
  1. Add the required UPI app schemes to your info.plist file.
    You need to add the following to your info.plist to enable your app to detect installed UPI applications:
    swift
  2. Add the JSBridge functions for the checkout page to get the list of installed UPI apps and handle opening the selected UPI app.
    Swift

Testing

After completing the iOS integration, verify that the payment flow works correctly:
  1. Create a test order from your backend with a valid return URL.
  2. Load the checkout form in your WKWebView with the payment session ID.
  3. Verify that the payment page loads in the web view.
  4. Test the payment flow end-to-end using test credentials.
  5. Verify that the return URL is triggered correctly after payment completion.
  6. If using UPI Intent, test with actual UPI applications installed on your test device.

Sample code

Swift