PolyPay logoPolyPay.ai

Нативные SDK для Android и iOS

Встройте нативные экраны выбора способа и оплаты без WebView.

Native checkout flow

  1. The merchant server creates checkout without currency or network and returns checkout_url.
  2. The SDK validates the HTTPS /pay/{tradeId} URL.
  3. The native page loads currencies, networks, and fee estimates.
  4. Android opens compatible EVM wallets and provides manual copy actions; iOS keeps its address QR and copy flow.
  5. The merchant server verifies payment before fulfillment.

1. Create checkout on the server

Keep X-API-Key on the server and omit currency and network to enable native selection.

// Trusted merchant server only. Never return the API Key to the app.
const response = await fetch('https://api.polypay.ai/api/v1/pay/order/checkout', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': process.env.POLYPAY_API_KEY!
  },
  body: JSON.stringify({
    mch_order_id: order.id,
    amount: order.amount,
    notify_url: 'https://merchant.example.com/webhooks/polypay'
    // Omit currency and network: the native SDK shows the selector.
  })
});

return { checkoutUrl: (await response.json()).data.checkout_url };

2. Install a native SDK

Android (Kotlin)

Use the Activity Result contract with the checkout URL returned by your server. Android API 24+.

dependencies {
  implementation("ai.polypay:checkout:0.1.1")
}
private val checkout = registerForActivityResult(PolyPayCheckoutContract()) { result ->
  // PAYMENT_DETECTED is not a fulfillment decision.
  viewModel.reconcileOnMerchantServer(result.tradeId)
}

checkout.launch(
  PolyPayCheckoutOptions(checkoutUrl = checkoutUrlFromYourServer)
)

iOS (SwiftUI or UIKit)

Add the Swift Package and present its SwiftUI view or UIKit controller. iOS 15+.

https://github.com/PolyPayAi/ios-sdk.git
let configuration = try PolyPayCheckoutConfiguration(
  checkoutURL: checkoutURLFromYourServer
)

PolyPayCheckoutView(configuration: configuration) { outcome in
  // paymentDetected is not a fulfillment decision.
  merchantAPI.reconcile(outcome)
}

Included native pages

Payment methodCurrency, network, merchant default, and fee estimate.
PaymentExact amount, network, address, copy actions, Android EVM wallet launch, and observed status.
Terminal statesConfirming, detected, expired, cancelled, error, and close.

Result and fulfillment authority

Результат SDK не содержит paid; выполнение возможно только после сверки на сервере.

Security requirements

  • Never place merchant credentials in the app.
  • Allow only exact HTTPS checkout hosts and /pay/{tradeId}.
  • Use server-provided amount, address, network, and fee data.
  • Use verified webhooks or authenticated server reconciliation as final authority.
  • Never fulfill from a client callback.

Release verification

  • Build and test both SDK packages.
  • Test selection and payment pages on real Android and iOS devices.
  • Test expiry, cancellation, confirmation, and network errors.
  • Verify app artifacts contain no merchant secret.
  • Verify client events cannot fulfill an order.