Apple Pay

Configure Apple Pay with your business developer account. Estimated Time: 1 Hour

Purpose

Triumph takes payment through Apple Pay for fraud reduction purposes.

Background

This background section is for your own information, and not neccesary to integrate with Triumph. Move on to Roadmap if you're not interested in the internal mechanics of Apple Pay -- we provide detailed steps so you can integrate with ease.

Apple Pay is a service offered by Apple that allows users that have added payment cards to their Apple Wallet to make purchases in apps. At a high level when a user makes a purchase, PassKit (Apple Pay and Wallet) will encrypt the user's payment details and hand the result off to us. Triumph then passes this encrypted information to our backend, which will decrypt the token process the payment.

Apple requires each app that utilizes Apple Pay to do the following

  1. Create a merchantID

  2. Upload a Certificate Signing Request (CSR)

  3. Enable the Apple Pay capability with the merchantID created above

Traditionally, when creating a CSR the developer will create and hold a private key associated with the CSR. The CSR itself does not contain private information but instead has the corresponding "public key" that will be used encrypt the Apple Pay tokens. When the developer uploads the CSR they do it under the merchantId they previously created and Apple gives them back an Apple Pay Payment Processing Certificate. The developer then adds their merchantId to their app's configuration.

This allows apple to encrypt the Apple Pay tokens with the correct public key so that only the developer (or whoever has access to both the secret and the Apple Pay Processing Certificate) can decrypt the tokens.

Roadmap

Triumph will be the sole custodian of the corresponding secret keys for each CSR, which lasts 25 months.

Since Triumph will decrypt Apple Pay tokens on your behalf, the Apple Pay flow is slightly different from the normal case above. You will:

  1. Create a merchantID

  2. Download a Triumph generated CSR and upload it to Apple

  3. Download an Apple Payment Processing Certificate from Apple and upload this to Triumph.

  4. Add the merchantID to your game.

Creating a MerchantID

To create a merchantID, log in to your Apple Business Developer Account here, and and click Identifiers under Certificates, Identifiers & Profiles.

Under Identifiers, click the + button to add an identifier.

Scroll down to Merchant IDs, select it, and click Continue in the upper right corner.

Give a description for your merchantID and an identifier of the form merchant.{yourGameName}.triumph. Hit Continue.

Confirm that the identifier has been successfully added to your list of identifiers.

Upload Triumph CSR to Apple

Generate CSR

Navigate to the Triumph Dashboard, and click on Settings -> Apple Pay. Click dowload certificate signing request. Note: this may take up to 30 seconds to generate and download. The file will be named triumph-certificate-signing-request.csr. Do not change the name of this file.

Upload to Apple

Navigate to the link here, and scroll down, and select Apple Payment Processing Certificate. Click continue at the upper right corner of the page.

Next, select the merchantID you generated in the previous step on the drop down menu and hit continue.

Click Create Certificate.

Select no for the question about Mainland China (Triumph does not operate in China) and hit continue.

Upload the CSR file you generated in the previous step and click Continue.

Download the Apple Payment Processing Certificate. This should be named apple_pay.cer.

Upload Apple Payment Processing Certificate to Triumph

Finally, go back to the Triumph Dashboard and upload the generated Payment Processing Cerificate to Triumph.

Add MerchantID to Your Game

All thats left to do is add the merchantID to your game. This is simple.

Navigate to theTriumphAPI prefab, and change the merchantID variable to what you just created. Make sure this name is exactly matched, or you will not be able to process payments.

using UnityEngine;
using TriumphKit;

public class TriumphUnityNativeMethods: MonoBehaviour, ITriumphUnityNativeMethods {
    
    // REQUIRED CONFIG IMPLEMENTATION 
    
   /*
    * This is where you will put your game's gameId, which you will
    * provision on the Triumph dashboard later. For now, leave this
    * as the empty string to load the SDK in sandbox mode.
    */
    public static readonly string gameId = ""
    
   /*
    * Add the merchantId to this variable
    */
    public static readonly string merchantId = "merchant.gameName.triumph"

Next Steps

You're now ready to build your project!

Last updated