How To: Implement Mobile App Payments

Allow customers to make a purchase by redirecting from your mobile app to the browser.

Overview

This guide demonstrates how to integrate Coinflow into a mobile app, enabling users to purchase credits or items via a secure checkout flow. The integration uses a simple redirect to an external checkout link, making it easy to add payments to your iOS or Android app.

Watch a Demo


How It Works

  1. User initiates a purchase in your app (e.g., taps “Buy Coins”).
  2. Your app makes a request to your server
  3. Your server requests a checkout link from Coinflow and passes it back to the user
  4. The app opens the returned link in the user’s browser or a webview.
  5. User completes payment on the secure checkout page.
  6. User is redirected back to your app via a callback URL you can set.

iOS Swift Integration

Below is a simplified example from our demo app, showing how to request a checkout link and redirect the user:

1 private func goToCheckoutPage() {
2 let checkoutUrlStr = getCheckoutURLFromServer()
3 let checkoutUrl = URL(string: checkoutUrlStr)!
4 DispatchQueue.main.async {
5 openURL(checkoutUrl)
6 }
7 }

API Request Example (cURL)

You can also test the API directly using cURL:

1curl -X POST "https://api-sandbox.coinflow.cash/api/checkout/link" \
2 -H "Authorization: YOUR_API_KEY" \
3 -H "x-coinflow-auth-user-id: USER_ID" \
4 -H "Content-Type: application/json" \
5 -d '{
6 "subtotal": {
7 "currency": "USD",
8 "cents": 5000
9 },
10 "standaloneLinkConfig": {
11 "callbackUrl": "yourapp://checkout-complete",
12 "endUserDeviceIpAddress": "127.0.0.1"
13 }
14 }'

This standalone link config is what determines whether or not the checkout page is allowed to render outside of an Iframe embedded on a website that you have whitelisted. If you pass in this config, we allow the Coinflow checkout page to be viewed as a standalone link, which works great in use cases like redirecting to it from your mobile app.

Callback URL

The callback URL is what we redirect to upon successful completion of a checkout. For a mobile app, this will be typically a universal link that takes the user back to the app for you to update their app state given their successful payment.

End User Device IP Address

This will be the IP Address of the user that is planning to checkout.

Response

The response will include a link field with the checkout URL.

1{
2 "link": "https://sandbox-merchant.coinflow.cash/solana/purchase-v2/your-merchant-name?query_params=here"
3}

Resources