Skip to content

Latest commit

 

History

History
154 lines (117 loc) · 4.44 KB

File metadata and controls

154 lines (117 loc) · 4.44 KB

Apps Service

Handle Appstore payments and subscriptions with the Apps Service. This service provides functionality for the Basalam Appstore payment flow: list payment methods, browse and inquire transactions, verify transactions, create pre-transactions, list your plans and manage their subscriptions.

Table of Contents

Apps Methods

Method Description Parameters
getMethods() List available payment methods includeDisabled, xGatewaySecret
listTransactions() Get transaction history page, perPage, status, fromDate, toDate, xGatewaySecret
listUnverified() List unverified transactions page, perPage, xGatewaySecret
inquiryTransaction() Inquire a transaction status hashId, xGatewaySecret
verifyTransaction() Manually verify a transaction hashId, xGatewaySecret
createPreTransaction() Create a pre-transaction request, xGatewaySecret
listPlans() List the current user's plans None
listPlanSubscriptions() List subscriptions of plans planId, status, customerId, page, perPage
getPlanSubscription() Get a sold subscription's details subscriptionId

Examples

Basic Setup

use Basalam\BasalamClient;
use Basalam\Auth\PersonalToken;

$auth = new PersonalToken(token: "your_access_token");
$client = new BasalamClient(auth: $auth);

Get Methods Example

function getMethodsExample()
{
    global $client;

    $methods = $client->apps->getMethods(
        includeDisabled: false
    );

    return $methods;
}

List Transactions Example

function listTransactionsExample()
{
    global $client;

    $transactions = $client->apps->listTransactions(
        page: 1,
        perPage: 20,
        status: 1,
        fromDate: "2026-01-01",
        toDate: "2026-06-01"
    );

    return $transactions;
}

Inquiry Transaction Example

function inquiryTransactionExample()
{
    global $client;

    $transaction = $client->apps->inquiryTransaction(
        hashId: "abc123hash"
    );

    return $transaction;
}

Verify Transaction Example

function verifyTransactionExample()
{
    global $client;

    $transaction = $client->apps->verifyTransaction(
        hashId: "abc123hash"
    );

    return $transaction;
}

Create Pre Transaction Example

use Basalam\Apps\Models\CreatePreTransactionRequest;

function createPreTransactionExample()
{
    global $client;

    $preTransaction = $client->apps->createPreTransaction(
        request: new CreatePreTransactionRequest(
            referenceId: "order-456",
            amount: 150000,
            description: "Subscription purchase",
            callbackUrl: "https://your-app.com/payment/callback",
            planId: 7,
            userId: 123
        )
    );

    return $preTransaction;
}

List Plans Example

function listPlansExample()
{
    global $client;

    $plans = $client->apps->listPlans();
    return $plans;
}

List Plan Subscriptions Example

function listPlanSubscriptionsExample()
{
    global $client;

    $subscriptions = $client->apps->listPlanSubscriptions(
        planId: 7,
        status: 1,
        page: 1,
        perPage: 20
    );

    return $subscriptions;
}