Skip to main content

Gifts

Methods for handling gifts for the currently logged in customer.

listGiftPurchases v1.11.0 read gift_purchases Types

Get all gifts available to the customer

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

getGiftPurchase v1.11.0 read gift_purchases Types

Get a specific gift for the customer

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

Redeeming a gift

When redeeming a gift there are two key pieces for the gift to get redeemed correctly.

  1. Create or use an address that has the property is_gift: true
  2. Creating a new subscription and include gift_id: {gift_credit_account_id}

Create gift address v1.11.0 write customers Types

Creates a gift address for a customer.

import { createAddress } from '@rechargeapps/storefront-client';
await createAddress(session, {
is_gift: true,
customer_id: 123,
address1: 'Dummy Address',
city: 'Omaha',
country_code: 'US',
first_name: 'Test',
last_name: 'Address',
phone: '123456789',
province: 'Nebraska',
zip: '68144',
});

Create gift subscription v1.11.0 write subscriptions Types

Create a gift subscription.

import { createSubscription } from '@rechargeapps/storefront-client';
await createSubscription(session, {
address_id: 75875888, // must be an address that has `is_gift: true`
gift_id: 123,
charge_interval_frequency: 30,
next_charge_scheduled_at: '2022-10-18',
order_interval_frequency: 1,
order_interval_unit: 'day',
quantity: 1,
external_variant_id: {
ecommerce: '31589634277439',
},
external_product_id: {
ecommerce: '4378133856319',
},
});