Setup the Product
In this step, create the product and configure its name, price, and additional information:
val model = SessionRequestModel(
"John Doe",
"[email protected]",
129,
"usd",
"BestDealPackage",
"Best_deal_package",
"",
"Coin Pack Bundle"
)
Session Request Model Arguments
Argument | Is Mandatory | Description |
---|---|---|
customerId | yes | The name or identifier of the customer. |
email | no | The customer's email address. Although not mandatory, providing it helps expedite the payment process. |
price | yes | The price in cents , which will be converted by Appcharge . |
currency | yes | The currency used for the transaction, e.g., usd , eur . |
offerName | yes | The name of the offer. |
offerSku | yes | The SKU number or text for the offer. |
offerAssetUrl | no | A URL to display an image for the offer. |
offerDescription | yes | A description for the offer |
Session Metadata (Optional)
The session metadata allows you to add extra data for BI (Business Intelligence) and tracking purposes.
// Option 01: Use to get a parsable object string
model.addSessionMetadata(key: String, value: String)
// Example usage
model.addSessionMetadata("sessionDetails", "details...")
// Example Output
/*
{
...,
"sessionMetadata": "{\"sessionDetails\":\"details...\"}"
}
*/
// Option 02: Use to get any string
model.sessionMetadata = "{...}"
// Example usage
model.sessionMetadata = "{ \"sessionDetails\": \"details...\" }"
// Example output
/*
{
...,
sessionMetadata: { "sessionDetails": "details..." }
}
*/
Adding Items to the Offer
At least one item must be added to the offer.
val model = SessionRequestModel(...) // Your session model
model.addItem(
"Coins",
"<https://media-dev.appcharge.com/media/product-3.png">,
"Coins_xoxoxo",
300,
"300 Coins Booster"
)
Offer Item Arguments
Argument | Is Mandatory | Description |
---|---|---|
name | mandatory | The name for the item |
assetUrl | mandatory | An image asset for displaying the item |
sku | mandatory | The item SKU |
quantity | mandatory | Amount of quantity for purchase. For example, if the name is "Coins" and the quantity is 300 then it it will be displayed as 300 Coins. |
quantityDisplay | mandatory | The Quantity Display allows you to replace the item quantity with a given text. Leave it as empty string to keep the quantity amount. |
Open Checkout
In this final step, open the checkout by passing the product model to it:
bridge.openCheckout(model);
At runtime, a new window will open, guiding the user through the purchase process. Based on user interaction, the following interface methods will be triggered:
Method | Description |
---|---|
OnPurchaseSuccess | Triggered when the user successfully completes the purchase. |
OnPurchaseFailed | Triggered when the checkout window is closed or if an error occurs during the purchasing process. |