Handling App Store Strong Customer Authentication Transactions (SCA)

Starting December 2020, European laws require Strong Customer Authentication (SCA) for users purchasing subscriptions over €30 or £25. Read more in the Apple Documentation.

A user is redirected from the app to the bank or the app store to complete the transaction and then redirected back to your app when the transaction is finished.

If you are checking the status of the subscriptions using the permissions everything is handled transparently by Glassfy, but if you want to be notified when a purchase is completed successfully you need to implement a delegate as in the following example.

@main
class AppDelegate: [...], Glassfy.PurchaseDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        Glassfy.initialize(apiKey: "YOUR_API_KEY")
        Glassfy.setPurchaseDelegate(self)
        [...]
    }

    func didPurchaseProduct(transaction: Glassfy.Transaction) {
        // handle transation
        // see transaction documentation here https://docs.glassfy.io/docs/transaction
    }
}
@interface AppDelegate () <GYPurchaseDelegate>
@end

@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [Glassfy initializeWithAPIKey:@"YOUR_API_KEY"];
    [Glassfy setPurchaseDelegate:self];

    [...]
}

#pragma mark - GYPurchaseDelegate delegate
- (void)didPurchaseProduct:(GYTransaction *)transaction 
{
    // handle transation
  // see transaction documentation here https://docs.glassfy.io/docs/transaction
}
@end
try {

  await Glassfy.initialize('YOU_API_KEY', false);
  
  Glassfy.setPurchaseDelegate({
      didPurchaseProduct(transaction) {
         // see transaction documentation here https://docs.glassfy.io/docs/transaction
      },
    });

} catch (e) {
  // initialization error
}
Glassfy.addDidPurchaseListener((transaction) async{
    // see transaction documentation here https://docs.glassfy.io/docs/transaction      
});

Did this page help you?