Unified payment module for all mini-programs in Super App

TRUETECH is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
Unified payment module for all mini-programs in Super App
Complex
from 1 week to 3 months
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    757
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1054
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    874
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    445

Implementing Unified Payment Module for All Mini-Programs in Super App

Super App is shell containing dozens of mini-apps. Each wants to accept payments, but building separate provider integration in each—mistake for several reasons: PCI scope expands per mini-app, certificate updates require simultaneous deploy all mini-apps, user lacks unified payment history.

Solution—payment module as part of host app (Shell App), which mini-programs call via bridge API.

Architecture: Shell ↔ Mini-Program Bridge

Typical Super App built on WebView (or React Native / Flutter WebView) for mini-programs. Payment bridge:

// Android Shell App: register bridge method
webView.addJavascriptInterface(PaymentBridge(this), "NativePayment")

class PaymentBridge(private val activity: AppCompatActivity) {
    @JavascriptInterface
    fun initiatePayment(requestJson: String) {
        val request = PaymentRequest.fromJson(requestJson)
        activity.runOnUiThread {
            PaymentBottomSheet.show(activity, request) { result ->
                val js = "window.onPaymentResult(${result.toJson()})"
                webView.evaluateJavascript(js, null)
            }
        }
    }

    @JavascriptInterface
    fun getSavedPaymentMethods(): String {
        return paymentRepository.getSavedMethods().toJson()
    }
}
// Mini-program (JS/React): call payment module
async function checkout(amount, orderId) {
    return new Promise((resolve, reject) => {
        window.onPaymentResult = (result) => {
            if (result.status === 'success') resolve(result);
            else reject(result.error);
        };
        NativePayment.initiatePayment(JSON.stringify({
            amount,
            currency: 'RUB',
            orderId,
            miniProgramId: 'com.yourshop.miniapp'
        }));
    });
}

On iOS similar via WKScriptMessageHandler:

class PaymentMessageHandler: NSObject, WKScriptMessageHandler {
    func userContentController(
        _ controller: WKUserContentController,
        didReceive message: WKScriptMessage
    ) {
        guard message.name == "initiatePayment",
              let body = message.body as? [String: Any] else { return }

        let request = PaymentRequest(from: body)
        PaymentCoordinator.shared.present(request: request, from: hostViewController) { result in
            let js = "window.onPaymentResult(\(result.jsonString))"
            webView.evaluateJavaScript(js)
        }
    }
}

// Register in WKWebViewConfiguration
configuration.userContentController.add(PaymentMessageHandler(), name: "initiatePayment")

Unified PaymentCoordinator

Key component—PaymentCoordinator in Shell App. Knows:

  • available payment methods (cards, Apple Pay / Google Pay, SBP, Super App balance)
  • saved cards for user
  • which provider handles payment (one gateway or multiple)
// Android: PaymentCoordinator as singleton in Shell
class PaymentCoordinator private constructor() {
    companion object {
        val shared = PaymentCoordinator()
    }

    private val activeProviders = mutableMapOf<String, PaymentProvider>()

    fun registerProvider(id: String, provider: PaymentProvider) {
        activeProviders[id] = provider
    }

    fun initiatePayment(request: PaymentRequest, callback: (PaymentResult) -> Unit) {
        val provider = selectProvider(request)
        provider.process(request, callback)
    }

    private fun selectProvider(request: PaymentRequest): PaymentProvider {
        // Routing logic: different mini-programs may use different providers
        return activeProviders[request.miniProgramId]
            ?: activeProviders["default"]
            ?: throw IllegalStateException("No payment provider registered")
    }
}

Routing by miniProgramId allows one Super App work with multiple acquirers—one for marketplace, another for delivery, third for fintech.

Saved Payment Methods

User adds card once—available in all mini-programs. Store tokens centrally:

data class SavedPaymentMethod(
    val id: String,
    val type: PaymentMethodType, // CARD, SBP, APPLE_PAY
    val displayName: String,     // "Visa •••• 4242"
    val providerToken: String,   // provider token (not PAN!)
    val isDefault: Boolean
)

providerToken—token from Stripe (pm_xxx), CloudPayments, or other provider. PAN never stored on device.

Cross-device sync: tokens stored on server, tied to userId. On first Super App open after install—load user's payment methods.

Unified Payment Screen UI

Bottom Sheet with payment methods must be consistent across Super App. Different mini-programs can't change its look—important for user trust.

Unified payment screen must handle:

  • Show saved cards with selection option
  • Add new card (via provider SDK or custom card input)
  • Apple Pay / Google Pay in one tap
  • SBP with deep-link to banking app
  • Display amount and mini-program name (request origin)
// PaymentBottomSheet gets PaymentRequest and shows needed methods
data class PaymentRequest(
    val amount: Long,           // kopecks
    val currency: String,
    val orderId: String,
    val miniProgramId: String,
    val miniProgramName: String, // "Delivery YourShop"—for user display
    val allowedMethods: List<PaymentMethodType>? = null // null = all available
)

Error Handling and Retry

Payment—critical operation. Shell App must handle partial failures correctly:

  • Provider timeout → show "Payment status being verified", start polling
  • 3DS redirect → open WebView inside bottom sheet, don't leave app
  • Request duplication → idempotent orderId on server side

Timeline Estimates

3–6 weeks: bridge API design, PaymentCoordinator implementation, provider integration, unified UI bottom sheet, testing across mini-programs. Pricing is calculated individually after architecture analysis.