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.
Parameters:
-
app_id
(AppId)
–
-
user_id
(UserId)
–
The end user these charges bill.
-
charges
(CustomChargeList)
–
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.
-
scope
(RequestScope)
–
Required. The environment: live or sandbox.
Raises:
Source code in docs_src/capo_appmonetization/_services/app_monetization.py
| def put_custom_charges(
self,
app_id: "capo_appmonetization.types.app_id.AppId",
user_id: "capo_appmonetization.types.user_id.UserId",
charges: "capo_appmonetization.types.custom_charge_list.CustomChargeList",
scope: "capo_appmonetization.types.request_scope.RequestScope",
*,
config_overrides: Optional[AppMonetizationClientConfig] = None,
) -> "capo_appmonetization.types.put_custom_charges_response.PutCustomChargesResponse":
"""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.
Args:
app_id: The ID of the app.
user_id: The end user these charges bill.
charges: 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.
scope: Required. The environment: live or sandbox.
Raises:
capo_appmonetization.errors.access_denied_exception.AccessDeniedException: The caller does not have sufficient permission to perform this action.
capo_appmonetization.errors.conflict_exception.ConflictException: The request conflicts with the current state of the resource, such as a duplicate identifier or a version mismatch. Retrieve the current state of the resource and retry the request.
capo_appmonetization.errors.internal_server_exception.InternalServerException: An unexpected error occurred while processing the request.
capo_appmonetization.errors.resource_not_found_exception.ResourceNotFoundException: The referenced resource does not exist.
capo_appmonetization.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: The request would cause a service quota to be exceeded.
capo_appmonetization.errors.throttling_exception.ThrottlingException: The request was denied due to request throttling.
capo_appmonetization.errors.validation_exception.ValidationException: The request failed input validation.
capo_appmonetization.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_appmonetization.types.put_custom_charges_request.PutCustomChargesRequest]",
) -> OperationResponse[
"capo_appmonetization.types.put_custom_charges_response.PutCustomChargesResponse"
]:
import capo_appmonetization._operations.aws_monetization_ai_front_end.put_custom_charges
output, http_response = (
capo_appmonetization._operations.aws_monetization_ai_front_end.put_custom_charges.put_custom_charges(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("PutCustomCharges")
)
input_: capo_appmonetization.types.put_custom_charges_request.PutCustomChargesRequest = {
"app_id": app_id,
"user_id": user_id,
"charges": charges,
"scope": scope,
}
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|