Skip to main content

IAP.getSubscriptionInfo

Queries the current state of a subscription by order ID. Use this to check whether a subscription is still active (isAccessible), when it expires, and whether auto-renewal is on.

Signature

getSubscriptionInfo is a member of the IAP namespace object.

import { IAP } from '@apps-in-toss/web-framework';

declare const IAP: {
getSubscriptionInfo(args: {
params: { orderId: string };
}): Promise<{
subscription: {
catalogId: number;
status: string;
expiresAt: string | null;
isAutoRenew: boolean;
gracePeriodExpiresAt: string | null;
isAccessible: boolean;
};
}>;
// ...see overview
};

Parameters

NameTypeRequiredDescription
args.params.orderIdstringUnique ID of the subscription order to query.

Returns

Promise<IapSubscriptionInfoResponse> — subscription status.

FieldTypeDescription
subscription.catalogIdnumberSubscription catalog ID.
subscription.statusstringSubscription status string.
subscription.expiresAtstring | nullExpiry timestamp (ISO 8601), or null if unavailable.
subscription.isAutoRenewbooleanWhether auto-renewal is enabled.
subscription.gracePeriodExpiresAtstring | nullGrace period expiry (ISO 8601), or null if no grace period.
subscription.isAccessiblebooleanWhether the subscription content is currently accessible.

Permission

No permission required — the IAP namespace is not bound to a PermissionName.

Examples

Minimal

import { IAP } from '@apps-in-toss/web-framework';

const result = await IAP.getSubscriptionInfo({ params: { orderId: 'order-123' } });
console.log(result.subscription);

Realistic — subscription-gated content

import { IAP } from '@apps-in-toss/web-framework';
import { useEffect, useState } from 'react';

interface Props {
orderId: string;
}

function SubscriptionGate({ orderId }: Props) {
const [accessible, setAccessible] = useState(false);

useEffect(() => {
IAP.getSubscriptionInfo({ params: { orderId } }).then((result) => {
setAccessible(result.subscription.isAccessible);
});
}, [orderId]);

if (!accessible) {
return <p>A subscription is required to view this content.</p>;
}

return <p>Subscriber content here.</p>;
}

Try it live

Run this API in the "Order management" step of the IAP page in sdk-example.

Open in sdk-example

External references