Search code examples
iosswiftframeworksapplepayentitlements

Use Apple Pay from a separate Swift Framework/Module


I would like to create a framework that possesses the capability to bill via Apple Pay. In a normal app that would involve me creating a merchant and setting up Apple Pay capability in an iOS app. However, I am not targeting an iOS App, but I am targeting a Swift Framework!

The project that will use my Swift Framework, ironically, already has Apple Pay capability and its own merchant and entitlements. But during a certain scenario of app execution, I need to present my own Apple Pay billing screen for my own merchant, and I have to do this from my non-main module, non-main bundle, from a framework.

The question is: how can I configure Apple Pay for my framework in a way that allows 2 merchants in a same app to be able to bill?

Alternatively: what if I ask the App that will be integrating my SDK to add my merchantId to its Apple Pay entitlements so that I use this merchantId to create PKPaymentRequests?


Solution

  • How can I configure Apple Pay for my framework in a way that allows 2 merchants in a same app to be able to bill?

    That's very easy, the merchantId just has to be in their entitlements, and they should pass it into the framework.

    What if I ask the App that uses the SDK to add my merchant ID to its own Apple Pay configuration so that I use the same Apple Pay merchant ID to create PKPaymentRequest?

    Their code will not compile because the merchantId in the entitlements must come from their own developer account.

    What is the correct way to do in your scenario is:

    • ask them to create a merchantId for their account
    • ask them to create the certificates and pass them onto you
    • configure the certificates as your own with your acquiring system
    • make sure you use this merchantId while making payments in the integrated SDK