Callback methods
To implement the iOS Payment Links SDK, include the following callback methods:| Method | Description | Argument | Type | |
|---|---|---|---|---|
onInitialized | Triggered when SDK initialization was successful. | |||
onInitializeFailed | Triggered when SDK initialization failed. | error | ACErrorMessage | |
onPricePointsSuccess | Triggered when the price points have successfully been retrieved. | pricePoints | PricePoints | |
onPricePointsFailed | Triggered when price points can’t be retrieved or are unavailable. | error | ACErrorMessage | |
onPurchaseSuccess | Triggered when a purchase was successful. | order | OrderResponseModel | |
onPurchaseFailed | Triggered when the checkout window closed or if a server to server error occurred during the purchasing process. Returns a unique integer error code, a detailed message, a raw JSON string (if available), and order details. | error, order | ACErrorMessage, OrderResponseModel |
OrderResponseModel properties
TheOrderResponseModel argument type contains the following properties:
| Property Name | Type | Description | Example |
|---|---|---|---|
date | Int | Unix timestamp of the order. | 1718182312 |
sessionToken | String | Unique token for the current session. | "xxxxXXXXxxxxXXXXxxxx" |
offerName | String | Name of the purchased offer. | "Starter Pack" |
offerSku | String | SKU identifier for the offer. | "starter_pack_001" |
items | [Item] | List of items included in the purchase. | [{ name: "Gems", sku: "gem_01", quantity: "100" }] |
items.name | String | Display name of the item. | "Gems" |
items.sku | String | Unique SKU code for the item. | "gem_01" |
items.quantity | String | Quantity of the item included. | "100" |
price | Int | Price of the order in minor units. For example, cents for USD. | 499 |
currency | String | ISO 4217 currency code | "USD" |
customerId | String | ID of the customer who made the purchase. | "cust_98765" |
customerCountry | String | Country code of the customer in ISO 3166-1 alpha-2 format. | "US" |
paymentMethodName | String | Payment method. | "Visa" |
orderId | String | Order ID. | "1234567890" |
purchaseId | String | A unique ID to track the transaction. | "pr_xxxxxx" |
ACErrorMessage properties
TheACErrorMessage argument type contains the following properties:
| Property Name | Type | Description | Example |
|---|---|---|---|
code | Int | Error code identifying the failure. | 3002 |
message | String | Detailed message describing the failure. | "Purchase canceled because the user closed the checkout interface." |
Example code
extension ViewController: ACPaymentLinksDelegate {
func onInitialized() {
print("SDK initialization was successful.")
}
func onInitializeFailed(error: ACErrorMessage) {
print("SDK initialization failed: \(error)")
}
func onPricePointsSuccess(pricePoints: PricePoints) {
print("Price points were successfully retrieved: \(pricePoints)")
}
func onPricePointsFailed(error: ACErrorMessage) {
print("Price points were not available: \(error)")
}
func onPurchaseSuccess(order: OrderResponseModel) {
print("Purchase was successful: \(order.orderId)")
}
func onPurchaseFailed(error: ACErrorMessage, order: GameOrderResponse?) {
print("Purchase failed: \(order.orderId ?? "No order ID found.")")
}
}
@interface ViewController () <ACPaymentLinksDelegate>
@end
@implementation ViewController
- (void)onInitialized {
NSLog(@"SDK initialization was successful.");
}
- (void)onInitializeFailedWithError:(ACErrorMessage *)error {
NSLog(@"SDK initialization failed: %@", error);
}
- (void)onPricePointsSuccessWithPricePoints:(PricePoints *)pricePoints {
NSLog(@"Price points were successfully retrieved: %@", pricePoints);
}
- (void)onPricePointsFailedWithError:(ACErrorMessage *)error {
NSLog(@"Price points were not available: %@", error);
}
- (void)onPurchaseSuccessWithOrder:(OrderResponseModel *)order {
NSLog(@"Purchase was successful: %@", order.orderId);
}
- (void)onPurchaseFailedWithError:(ACErrorMessage *)error order:(GameOrderResponse * _Nullable)order {
NSLog(@"Purchase failed: %@", order.orderId ?: @"No order ID found.");
}
@end
