Skip to main content

Charges

Methods to work with Recharge charges.

listCharges v1.0.0 read orders Types

Get a paginated list of charges for the user.

import { listCharges } from '@rechargeapps/storefront-client';
await listCharges(session, {
limit: 25,
sort_by: 'id-asc',
});

getCharge v1.0.0 read orders Types

Get a charge by id.

import { getCharge } from '@rechargeapps/storefront-client';
await getCharge(session, 123);

applyDiscountToCharge v1.0.0 write orders Types

Apply a discount to a charge.

You cannot add a Discount to an existing queued Charge if the Charge or the associated Address already has one. If a Charge has a Discount and it gets updated, or a regeneration occurs, the Discount will be lost. Regeneration is a process that refreshes the Charge JSON with new data in the case of the Subscription or Address being updated.

import { applyDiscountToCharge } from '@rechargeapps/storefront-client';
await applyDiscountToCharge(session, 123, 'discount_code');

removeDiscountsFromCharge v1.0.0 write orders Types

Remove all Discounts from a Charge without destroying the Discount.

In most cases the Discount should be removed from the Address. When the Discount is removed from the Address, the Discount is also removed from any future Charges. If the Discount is on the parent Address, you cannot remove it using charge_id. When removing your Discount, it is preferable to pass the address_id so that the Discount stays removed if the Charge is regenerated. Only pass charge_id in edge cases in which there are two or more Charges on a parent Address and you only want to remove the Discount from one Charge. If you pass both parameters, it will remove the Discount from the Address.

import { removeDiscountsFromCharge } from '@rechargeapps/storefront-client';
await removeDiscountsFromCharge(session, 123);

skipCharge v1.0.0 write orders Types

Skip a charge.

Takes a charge id and an array of purchaseItemIds of items to skip.

import { skipCharge } from '@rechargeapps/storefront-client';
await skipCharge(session, 123, [1234, 2345]);

unskipCharge v1.0.0 write orders Types

Unskip a charge.

Takes a charge id and an array of purchaseItemIds of items to unskip.

import { unskipCharge } from '@rechargeapps/storefront-client';
await unskipCharge(session, 123, [1234, 2345]);

processCharge v1.0.0 write payments Types

Process a charge.

import { processCharge } from '@rechargeapps/storefront-client';
await processCharge(session, 123);