> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # ChargesRejectedEvent # Package: appBilling # Namespace: CustomChargesProvider # Method link: https://dev.wix.com/docs/api-reference/app-management/app-billing/custom-charges-service-plugin/charges-rejected-event.md ## Introduction Triggered in case Wix doesn't accept the charges you've returned in the List Charges method. You aren't allowed to charge a site owner more than the charge limit. Wix call List Charges in regular intervals until the sum of all charges is lower than the charge limit. Wix doesn't create an invoice in case the charges aren't accepted. --- ## REST API ### Schema ``` Method: chargesRejectedEvent Description: Triggered in case Wix doesn't accept the charges you've returned in the List Charges method. You aren't allowed to charge a site owner more than the charge limit. Wix call List Charges in regular intervals until the sum of all charges is lower than the charge limit. Wix doesn't create an invoice in case the charges aren't accepted. URL: null Method: POST Method parameters: param name: chargeIds | type: array | description: IDs of the rejected charges. Max: 5 charges param name: chargeLimit | type: chargeLimit | description: Maximum amount that your app may charge the customer per billing cycle. Min: `0.50` param name: currency | type: currency | description: Supported values: `AUD`, `BRL`, `CAD`, `EUR`, `GBP`, `ILS`, `INR`, `JPY`, `MXN`, `PLN`, `RUB`, `TRY`, `USD`. 3-letter currency code in [ISO-4217 alphabetic](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format of the charges. Wix may add supported currencies in the future. param name: reasons | type: array | description: Information about why Wix has rejected your app's charges. Max: 20 reasons - enum: - UNKNOWN: There is no information about why Wix has rejected the charges. - CHARGE_LIMIT_EXCEEDED: The sum of the charges is higher than the limit that you may charge the customer per billing cycle. - TOO_MANY_CHARGES: You can't provide more than 5 charges per invoice. - INVALID_FORMAT: You must submit charges as whole numbers or use a dot to separate major and minor units. For example, `10` or `1.50`. Currently, Wix doesn't validate whether the submitted number of decimals for the minor unit is supported for the given currency. param name: subscriptionId | type: subscriptionId | description: GUID of the subscription for which Wix hasn't accepted your custom charges. To track usage and billing for apps, we recommend to use `instanceId` instead of the `subscriptionId`. Return type: ChargesRejectedResponse EMPTY-OBJECT {} ``` ### Examples ### Get notified when Wix doesn't accept your custom charges. The data payload includes the following object as an encoded JWT. Here, we show the request and response objects decoded. ```curl curl -X POST \ 'https://provider.example.com/v1/charges-rejected' \ -H 'Authorization: ' \ -d '{ "data": { "request": { "subscriptionId": "efa6b37d-74c6-44bb-b639-28c4af3957dd", "currency": "USD", "chargeIds": [ "Some Charge Id 1", "Some Charge Id 2" ], "chargeLimit": "1000.00", "reasons": [ "CHARGE_LIMIT_EXCEEDED" ] }, "metadata": { "requestId": "1680014776.67327419774788218037", "identity": { "identityType": "APP", "appId": "365288ae-38f4-4932-92d5-d45c596c7260" }, "instanceId": "3aa496c3-aa49-4369-84e6-3fa1876f191d" } }, "aud": "6675724b-bf3e-482a-9a00-65616953b570", "iss": "wix.com", "iat": 1680014777, "exp": 1683614777 }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.appBilling.CustomChargesProvider.chargesRejectedEvent(request, metadata) Description: Triggered in case Wix doesn't accept the charges you've returned in the List Charges method. You aren't allowed to charge a site owner more than the charge limit. Wix call List Charges in regular intervals until the sum of all charges is lower than the charge limit. Wix doesn't create an invoice in case the charges aren't accepted. Method parameters: param name: metadata | type: Context | description: this message is not directly used by any service, it exists to describe the expected parameters that SHOULD be provided to invoked Velo methods as part of open-platform. e.g. SPIs, event-handlers, etc.. NOTE: this context object MUST be provided as the last argument in each Velo method signature. Example: ```typescript export function wixStores_onOrderCanceled({ event, metadata }: OrderCanceledEvent) { ... } ``` - name: requestId | type: string | description: A unique identifier of the request. You may print this GUID to your logs to help with future debugging and easier correlation with Wix's logs. - name: currency | type: string | description: [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 3-letter currency code. - name: identity | type: IdentificationData | description: An object that describes the identity that triggered this request. - ONE-OF: - name: anonymousVisitorId | type: string | description: GUID of a site visitor that has not logged in to the site. - name: memberId | type: string | description: GUID of a site visitor that has logged in to the site. - name: wixUserId | type: string | description: GUID of a Wix user (site owner, contributor, etc.). - name: appId | type: string | description: GUID of an app. - name: languages | type: array | description: A string representing a language and region in the format of `"xx-XX"`. First 2 letters represent the language code according to ISO 639-1. This is followed by a dash "-", and then a by 2 capital letters representing the region according to ISO 3166-2. For example, `"en-US"`. - name: instanceId | type: string | description: The service provider app's instance GUID. param name: request | type: ChargesRejectedRequest - name: subscriptionId | type: string | description: GUID of the subscription for which Wix hasn't accepted your custom charges. To track usage and billing for apps, we recommend to use `instanceId` instead of the `subscriptionId`. - name: currency | type: string | description: Supported values: `AUD`, `BRL`, `CAD`, `EUR`, `GBP`, `ILS`, `INR`, `JPY`, `MXN`, `PLN`, `RUB`, `TRY`, `USD`. 3-letter currency code in [ISO-4217 alphabetic](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format of the charges. Wix may add supported currencies in the future. - name: chargeIds | type: array | description: IDs of the rejected charges. Max: 5 charges - name: chargeLimit | type: string | description: Maximum amount that your app may charge the customer per billing cycle. Min: `0.50` - name: reasons | type: array | description: Information about why Wix has rejected your app's charges. Max: 20 reasons - enum: - UNKNOWN: There is no information about why Wix has rejected the charges. - CHARGE_LIMIT_EXCEEDED: The sum of the charges is higher than the limit that you may charge the customer per billing cycle. - TOO_MANY_CHARGES: You can't provide more than 5 charges per invoice. - INVALID_FORMAT: You must submit charges as whole numbers or use a dot to separate major and minor units. For example, `10` or `1.50`. Currently, Wix doesn't validate whether the submitted number of decimals for the minor unit is supported for the given currency. Return type: PROMISE EMPTY-OBJECT {} ``` ### Examples ### Example of a charges rejected event ```javascript import { customCharges } from '@wix/app-management/service-plugins'; customCharges.provideHandlers({ chargesRejectedEvent: async ( payload ) => { const {request, metadata} = payload; // Use the `request` and `metadata` received from Wix and // apply custom logic. return {} } }); ``` ### chargesRejectedEvent (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { customCharges } from '@wix/app-management/service-plugins'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { customCharges }, // Include the auth strategy and host as relevant }); async function chargesRejectedEvent(request,metadata) { const response = await myWixClient.customCharges.chargesRejectedEvent(request,metadata); }; ``` ---