Migrating from window.ReCharge to the Recharge JavaScript SDK

Recharge is depreciating the window.ReCharge global object to improve customer portal performance and align merchants with our modern, secure JavaScript SDK.

This guide outlines feature-by-feature migration paths, and maps all legacy window.ReCharge APIs to their SDK equivalents.

📘

Tip

If your use case isn’t covered in this guide, contact the Recharge Support team for additional assistance.


Getting Started

Initialize the SDK

initRecharge(options)

Authentication & Session Handling

  • Login via Shopify App Proxy: loginShopifyAppProxy
  • Fetch store/customer context:
    • getStoreSettings
    • getCustomer

See Script Setup in the SDK docs for more information.


Subscriptions

Legacy

window.ReCharge.subscriptions

SDK equivalents

  • listSubscriptions(params: SubscriptionListParams)
  • getSubscription(options: GetSubscriptionOptions)
  • createSubscription
  • updateSubscription
  • cancelSubscription
  • activateSubscription
  • updateSubscriptions (bulk)
  • updateSubscriptionChargeDate
  • updateSubscriptionAddress

Common migrations

Active subscriptions

Legacy

window.ReCharge.subscriptions.filter(s => s.status === 'ACTIVE');

SDK

listSubscriptions({ status: 'ACTIVE' }) 
// or list + filter if status filter is unsupported

Find a subscription ID

Legacy

window.ReCharge.subscriptions.find(...)

SDK

getSubscription({ id })

Bulk edits

Legacy

Manually iterating over subscriptions in window.ReCharge

SDK

updateSubscriptions({ subscriptions: [...] })

Charges

Legacy

  • window.ReCharge.charges
  • Deriving subscription_id from: window.ReCharge.charges[0].line_items[0].subscription_id

SDK equivalents

  • listCharges(params: ChargeListParams)
  • getCharge(options: GetChargeOptions)
  • processCharge
  • skipCharge
  • unskipCharge
  • skipSubscriptionCharge
  • skipFutureCharge
  • skipGiftSubscriptionCharge
  • delayOrder

Common migrations

Replace manual caching

Legacy

window.ReCharge.charges = ...

SDK

Use your own helper and store:

listCharges({ status: 'queued' })

Resolve subscription from charge

Legacy

const id = window.ReCharge?.charges?.[0]?.line_items?.[0]?.subscription_id;

SDK

const charge = getCharge({ id });
const subscriptionId = charge.line_items[0].subscription_id;
getSubscription({ id: subscriptionId });

Customer

Legacy

window.ReCharge.customer.* (email, name, hash, timestamps, etc.)

SDK equivalents

  • getCustomer
  • updateCustomer

Common migrations

Get customer email

Legacy

window.ReCharge?.customer?.email

SDK

const customer = getCustomer();
customer.email;

Addresses

Legacy

window.ReCharge.addresses

SDK equivalents

  • listAddresses
  • getAddress
  • createAddress
  • updateAddress
  • deleteAddress
  • mergeAddresses

Common migrations

Replace passive waiting/interception with explicit fetching

Legacy

Relying on automatic updates to window.ReCharge.addresses

SDK

const result = listAddresses();
applyRestrictions(result.addresses);

// re-run whenever you change addresses or detect updates

Onetimes, Orders, Payments, Metafields

Onetimes

  • listOnetimes
  • getOnetime
  • createOnetime
  • updateOnetime
  • deleteOnetime

Orders

  • listOrders
  • getOrder
  • delayOrder (where applicable)

Payment Methods

  • listPaymentMethods
  • getPaymentMethod
  • createPaymentMethod
  • updatePaymentMethod

Credits, Discounts, Gifting

Credits

  • getCreditSummary
  • listCreditAccounts
  • setApplyCreditsToNextCharge (apply credit)

Discounts

  • applyDiscountToAddress
  • removeDiscountsFromAddress
  • applyDiscountToCharge
  • removeDiscountsFromCharge

Gifting

  • listGiftPurchases
  • getGiftPurchase
  • getGiftRedemptionLandingPageURL

Auth/Session and token replacement

Legacy tokens

  • window.ReCharge.token (used in iframes and URLs)

SDK replacements

  • Use the login/session flows instead of exposing tokens in the DOM
  • For portal links/access, use: getCustomerPortalAccess() to return scoped, time-bound access details.

Common migrations

Token in iframe URL

Legacy

...&token=${window.ReCharge.token}

SDK

getCustomerPortalAccess()