Skip to content

Latest commit

 

History

History
71 lines (55 loc) · 3.21 KB

File metadata and controls

71 lines (55 loc) · 3.21 KB

Appstore Service

Handle in-app payments and subscription plans with the Appstore Payment Service: payment methods, transactions, pre-transactions (payment intents), plans and plan subscriptions.

Most endpoints accept an optional gateway_secret argument which, when provided, is sent as the X-Gateway-Secret header. All methods are available in both async and _sync variants and are reachable through client.appstore.<method>() or directly as client.<method>().

Table of Contents

Methods

Method Description Parameters
get_payment_methods() List payment methods include_disabled, gateway_secret
list_transactions() List transactions page, per_page, status, from_date, to_date, gateway_secret
list_unverified_transactions() List unverified transactions page, per_page, gateway_secret
inquiry_transaction() Inquiry a transaction hash_id, gateway_secret
verify_transaction() Verify a transaction hash_id, gateway_secret
create_pre_transaction() Create a pre-transaction request: CreatePreTransactionRequest, gateway_secret
list_plans() List subscription plans None
list_plan_subscriptions() List plan subscriptions plan_id, status, customer_id, page, per_page
get_plan_subscription() Get a plan subscription subscription_id

Examples

Basic Setup

from basalam_sdk import BasalamClient, PersonalToken
from basalam_sdk.appstore import CreatePreTransactionRequest

auth = PersonalToken(token="your_access_token", refresh_token="your_refresh_token")
client = BasalamClient(auth=auth)

Create a pre-transaction and verify it

async def pay():
    pre_tx = await client.appstore.create_pre_transaction(
        request=CreatePreTransactionRequest(
            reference_id="order-123",
            amount=50000,
            callback_url="https://your-app.com/pay/callback",
        )
    )
    # Redirect the user to pre_tx.pay_url ... then, after the gateway callback:
    verified = await client.appstore.verify_transaction(hash_id=pre_tx.hash_id)
    return verified

List plans and subscriptions

plans = await client.appstore.list_plans()
subscriptions = await client.appstore.list_plan_subscriptions(status="active")

Using the gateway secret header

# When provided, gateway_secret is sent as the `X-Gateway-Secret` header.
transactions = await client.appstore.list_transactions(
    page=1, per_page=20, gateway_secret="your-gateway-secret"
)