Skip to main content

BUY BUTTON

Buy Button - iOS

ℹ️iOS β€” external payment link-outs (US, Japan, Brazil)

iOS: In the U.S., Japan, and Brazil, Apple now lets developers direct players to external web payments. The Xsolla SDK aligns with Apple’s updated guidelines.

The Buy Button Solution provides a complete, native payment experience with minimal integration effort. This approach handles the entire payment flow within your app using Xsolla's optimized UI components.

When to use Buy Button Solution:

  • You want a quick, native payment integration
  • You prefer Xsolla to handle payment UI and optimization
  • You need support for multiple payment methods out of the box
  • You want automatic compliance with regional payment regulations
// Enable Buy Button solution
settings.useBuyButtonSolution = YES;

The Web Shop approach redirects users to your existing Xsolla Web Shop in a browser, then returns them to your app after purchase completion. This method is ideal for gradual migration or when you want to maintain consistency with existing web-based payment flows.

When to use Web Shop link-outs:

  • You already have an established Xsolla Web Shop
  • You want to test Xsolla integration with minimal code changes
  • You need to maintain payment consistency across multiple platforms
  • You're implementing a phased migration from web to mobile payments
caution

In Web Shop link-out mode, the SDK does not execute its native in-app payment flow. It only opens the Web Shop and immediately cancels any SDK purchase callbacks. This mode is intended for minimal code changes: handle fulfillment and post-payment updates via your Web Shop processes (for example, webhooks or server-side logic), not via SDK purchase callbacks.

Configuring Web Shop Integration​

Use the helper method to configure the Web Shop redirect flow:

[settings setupBuyButtonWebShopWithUrl:[NSURL URLWithString:@"https://yourwebshop.xsolla.site"] 
userId:@"<USER_ID>"
returnUrl:@"yourgame://"
openExternally:YES];

Parameter explanation:

  • url: The URL of your Xsolla Web Shop where users complete purchases
  • userId: A unique identifier for the user in your system, used for purchase attribution and user tracking
  • returnUrl: The deep link URL scheme that brings users back to your app after purchase completion
  • openExternally: Whether to open the Web Shop in an external browser (recommended for compliance and better user experience)

Initiating Web Shop Purchases​

After configuration, initiate purchases by calling the purchase method with your product SKU:

// Attempt to purchase an item via Web Shop
BOOL handledExternally = [[SKPaymentQueue defaultQueue] purchaseWithSKU:@"money.100"];

if (handledExternally) {
// Web Shop opened successfully, update UI to reflect the redirect
NSLog(@"Purchase redirected to Web Shop");
// Optionally show a loading indicator or message to the user
}