Catappult logo
Catappult logo
language selectorEn

Faster development with one single integration.

Distribute your apps and games globally on app stores both on Android and iOS with a single, seamless integration.

One-step Payment

Easy and simple way

SDK

Traditional way

One-step Payment

is our easy and simple solution to integrate our in-app billing method. It requires little effort to implement and is the solution used by our top developers!

How it works

catappult osp step 1

End-user wants to buy a product on your application

catappult osp step 2

Application launches One Step Payment (OSP) billing flow by calling your OSP URL as an Intent

catappult osp step 3

AppCoins Wallet reads OSP URL Intent, handles the payment, and on completion calls your web service endpoint

catappult osp step 4

Your web service validates the transaction data

You give the product to the end-user

End-user wants to buy a product on your application

catappult osp step 1

Application launches One Step Payment (OSP) billing flow by calling your OSP URL as an Intent

catappult osp step 2

AppCoins Wallet reads OSP URL Intent, handles the payment, and on completion calls your web service endpoint

catappult osp step 3

Your web service validates the transaction data

catappult osp step 4

You give the product to the end-user

Check our guide

What you need to do

The first step in implementing One-Step Payment consists of generating your OSP URL.

The service to be called by the OSP URL is https://apichain.catappult.io/transaction/inapp but there are some query parameters that you will need to fill in. Below there are some snippets on how to generate the OSP URL in different languages. You can also generate your own OSP URL by changing the parameters on the Parameters section.

                
const crypto = require('crypto');

let product = "sword.001";
let domain = "com.appcoins.trivialdrivesample";
let callback_url = "https://www.mygamestudio.com/completePurchase?userId=1234";
let encoded_callback_url = encodeURIComponent(callback_url);

let url = "https://apichain.catappult.io/transaction/inapp";
url += "?product=" + product;
url += "&domain=" + domain;
url += "&callback_url=" + encoded_callback_url;

let secret_key = "secret";
let signature = crypto.createHmac("sha256", secret_key).update(url).digest("hex");
let signed_url = url + "&signature=" + signature;
                
              

Change Parameters

Now it's time to create an Intent with the generated OSP URL and request for it to be processed by the application's current Activity.

If the AppCoins Wallet is installed on the device, you can request it to process the created Intent. Otherwise, the Intent will be processed by the device's default Web Browser.

                
public static void launchOsp(Activity activity) {
  try {
    String domain = "com.appcoins.trivialdrivesample";
    String product = "sword.001";

    String ospUrl = generateOspUrl(domain, product);

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(ospUrl));

    if (isAppCoinsWalletInstalled(activity)){
      intent.setPackage("com.appcoins.wallet");
    }
    activity.startActivityForResult(intent, 10003)
  } catch (Exception e) {
    e.printStackTrace();
  }
}

private static String generateOspUrl(String domain, String product) {
  // TODO: Make a request to your server to obtain the OSP URL
  return "https://apichain.catappult.io/transaction/inapp?product=sword.001&domain=com.appcoins.trivialdrivesample&callback_url=https%3A%2F%2Fwww.mygamestudio.com%2FcompletePurchase%3FuserId%3D1234&signature=76a21fc764668b1e31e13c7cb98f2768ab52b3415ba4cd3c6455d223cc3fdaa0"
}

private static boolean isAppCoinsWalletInstalled(Activity activity) {
  PackageManager packageManager = activity.getApplicationContext().getPackageManager();
  Intent intentForCheck = new Intent(Intent.ACTION_VIEW);
  if (intentForCheck.resolveActivity(packageManager) != null){
    try {
      packageManager.getPackageInfo("com.appcoins.wallet", PackageManager.GET_ACTIVITIES);
      return true;
    } catch (Exception e) {}
  }
  return false;
}
                
              

Once the transaction is completed on the AppCoins Wallet, a POST request will be made to the web service endpoint you specified on the query string parameter callback_url of your OSP URL.

On the body of this POST request, a JSON object will be sent with a field named transaction. An example is shown below:

              
{
  "uid": "2DtyvTOSShc1xT9C",
  "domain": "com.appcoins.trivialdrivesample",
  "product": "sword.001",
  "reference": "XYZ98880032",
  "status": "COMPLETED",
  "added": "2020-04-18T06:15:18+00:00",
  "modified": "2020-04-18T07:17:19+00:00",
  "type": "INAPP_UNMANAGED",
  "price": {
    "appc": "115",
    "currency": "USD",
    "value": "11.5",
    "usd": "4.99"
  }
}
              
            

To verify data integrity, on your web service, you can make a GET request to our transaction's API https://api.catappult.io/broker/8.20220927/transactions/ where you pass the transaction UID (example: https://api.catappult.io/broker/8.20220927/transactions/2DtyvTOSShc1xT9C). An example of this endpoint's response is shown below:

              
{
  "uid": "2DtyvTOSShc1xT9C",
  "domain": "com.appcoins.trivialdrivesample",
  "product": "sword.001",
  "wallet_from": "0xa43748bf498d7070d05d4fde042c51c780ce71b9",
  "country": "PT",
  "type": "INAPP_UNMANAGED",
  "method": "appcoins_credits",
  "reference": null,
  "hash": "0x234e3c2407680ffe07d4f1bb7bc5c773085cd4ca723669a0473777ceeaabab95",
  "origin": "BDS",
  "status": "COMPLETED",
  "added": "2020-05-04T10:19:45+00:00",
  "modified": "2020-05-04T10:19:45+00:00",
  "gateway": {
    "name": "appcoins_credits"
  },
  "metadata": null,
  "price": {
    "appc": "115",
    "currency": "USD",
    "value": "11.5",
    "usd": "4.99"
  }
}
              
            

Now you should compare the common fields (uid, domain, product, ...) between the JSON object received on the POST request and the JSON object from the transaction's API endpoint's response. They must have the same value. Finally, once you do all the validations on your server, you will need to notify your application and give the item to the end user.

SDK solution

We also have an SDK solution to integrate our in-app billing method. This is the most traditional way of doing it and similar to most App Stores such as Amazon and Google Play! For more information, please visit our guide:

Check our guide

catappult sdk
sdk diagram