AppMonetization / Client / put_custom_charges

put_custom_charges

AppMonetization.Client.put_custom_charges(**kwargs)

Adds charges that you compute to the end user’s next subscription invoice. The charges go to the billing period of the user’s current subscription that contains the current time. You don’t specify a period.

Each charge has a chargeId that you choose. If you submit a chargeId again in the same billing period, the existing charge is replaced instead of added again. A chargeId belongs to the first billing period that accepts it, so use a value that is unique for this user across all billing periods, such as a UUID or your own invoice line ID.

The request succeeds or fails as a whole: either every charge is accepted or none is. A successful response means that every charge was accepted.

If you submit a chargeId after its billing period has ended, the request fails with a ConflictException. The charge is already recorded. Don’t submit it again under a new chargeId, because that bills it twice.

A billing period holds at most 100 chargeId values for each user. If a request would exceed 100, it fails with a ServiceQuotaExceededException. Submitting a chargeId that is already in the period doesn’t count toward the limit.

See also: AWS API Documentation

Request Syntax

response = client.put_custom_charges(
    appId='string',
    userId='string',
    charges=[
        {
            'chargeId': 'string',
            'description': 'string',
            'amount': 'string',
            'currency': 'string',
            'metricId': 'string',
            'taxCode': 'string'
        },
    ],
    scope='sandbox'|'live'
)
Parameters:
  • appId (string) –

    [REQUIRED]

    The ID of the app.

  • userId (string) –

    [REQUIRED]

    The end user these charges bill.

  • charges (list) –

    [REQUIRED]

    The custom charges to add to this user’s next invoice. Stored at the submitted grain; the service never splits a charge. Accepted all-or-nothing.

    • (dict) –

      One developer-computed charge.

      • chargeId (string) – [REQUIRED]

        Caller-chosen stable id for THIS charge. It is the idempotency and replace key: re-submitting the same chargeId within its assigned period upserts the charge in place. A chargeId is bound to the first period it is accepted into; re-submitting it after that period rolls over is refused (ConflictException) rather than billing it again, so it must be unique per charge for this user across all periods — use a UUID or your own invoice-line id (the caller does not know the billing period, so it cannot be encoded in the id).

      • description (string) – [REQUIRED]

        Human-readable description, surfaced on the invoice line.

      • amount (string) – [REQUIRED]

        The charge, as a decimal string in major currency units (for example, “12.50”).

      • currency (string) – [REQUIRED]

        The ISO 4217 currency of the amount. Only USD is supported; a non-USD value is rejected.

      • metricId (string) –

        Optional metric this charge derives from. Omitted for a charge not tied to a metric (a flat or custom fee).

      • taxCode (string) –

        Optional product tax code; defaults to the service default when omitted.

  • scope (string) –

    [REQUIRED]

    Required. The environment: live or sandbox.

Return type:

dict

Returns:

Response Syntax

{
    'billingPeriodStartAt': datetime(2015, 1, 1),
    'billingPeriodEndAt': datetime(2015, 1, 1)
}

Response Structure

  • (dict) –

    • billingPeriodStartAt (datetime) –

      The billing period the service assigned these charges to, resolved from the user’s current subscription. The caller supplies no window; this reports where the charges landed.

    • billingPeriodEndAt (datetime) –

      End of the assigned billing period.

Exceptions

  • AppMonetization.Client.exceptions.AccessDeniedException

  • AppMonetization.Client.exceptions.ValidationException

  • AppMonetization.Client.exceptions.ConflictException

  • AppMonetization.Client.exceptions.InternalServerException

  • AppMonetization.Client.exceptions.ServiceQuotaExceededException

  • AppMonetization.Client.exceptions.ResourceNotFoundException

  • AppMonetization.Client.exceptions.ThrottlingException