Skip to Content
SandboxSubscriptionsSandbox hooks: charges

Sandbox hooks: charges

In production a subscription is charged on the project schedule — once every 30 days, for several cycles. That is not something you can wait for in a test, so the cycle is compressed by the <TestInfo> block in CreateSubscription: the period is given in seconds and the outcome of each charge is chosen upfront.

FieldValue
BillingPeriodSeconds1…86400. Enables the charge cycle — without this field there are no charges at all. Sets both the period between charges and the retry interval after a decline
MaxIterations1…100, default 3. How many successful charges happen before the subscription closes (FINISHED / Closed)
ExpectedBillingResultSuccess (default) or Failed — the outcome of every charge attempt
BillingAmountCharge amount in the notifications (CustomerPrice), default 10.00
OperatorIDSubscription operator, default 22. The value 20 switches on Megafon behaviour: operation_status instead of action in the return redirect (WAP) and CancelUrl in the CancelSubscription response

Before every successful charge the mock sends a ContentRequest — a query for the service SMS text. Answer with StatusName=REQUEST_ACCEPTED and a ContentMessage block carrying the parameter values; the response is stored in the callback log.

Invalid values do not break the request: a warning goes to the log and the default is used. The first charge is counted from the moment the subscription is activated (PIN confirmation or payment), not from its creation.

The <TestInfo> block does not exist in the production contract — remove it before going live. There, charges follow the project schedule.

What arrives with ExpectedBillingResult=Success

Every period — APPROVED_BILLING with a growing BillingIteration and a shifted PaidUntil. On the last iteration FINISHED follows, the subscription moves to Closed and charges stop.

What arrives with Failed

The charge attempt fails: REJECTED_BILLING_ATTEMPT, status Redelivering, BillingErrorCode=210 (“no money”), and one period later the next attempt. After the third failure — REJECTED_BILLING and RenewingFailed: the subscription is closed, no further attempts.

CreateSubscription with the charge cycle
<Request> <SubscriptionProjectID>2001</SubscriptionProjectID> <Subscriber_MSISDN>79600000000</Subscriber_MSISDN> <Now>20260817120000</Now> <Signature>d2f36558ca5455be...</Signature> <TestInfo> <BillingPeriodSeconds>10</BillingPeriodSeconds> <MaxIterations>3</MaxIterations> <ExpectedBillingResult>Success</ExpectedBillingResult> <BillingAmount>49.00</BillingAmount> </TestInfo> </Request>
Notification sequence
# ExpectedBillingResult=Success APPROVED right after confirmation APPROVED_BILLING +10 s BillingIteration=1 APPROVED_BILLING +20 s BillingIteration=2 APPROVED_BILLING +30 s BillingIteration=3 FINISHED +30 s SubscriptionStatus=Closed # ExpectedBillingResult=Failed APPROVED after confirmation REJECTED_BILLING_ATTEMPT +10 s Redelivering, BillingErrorCode=210 REJECTED_BILLING_ATTEMPT +20 s Redelivering REJECTED_BILLING +30 s RenewingFailed