@shopify/shopify-app-remix
Version:
Shopify Remix - to simplify the building of Shopify Apps with Remix
1 lines • 2.16 kB
Source Map (JSON)
{"version":3,"file":"cancel.mjs","sources":["../../../../../../../src/server/authenticate/admin/billing/cancel.ts"],"sourcesContent":["import {HttpResponseError, Session} from '@shopify/shopify-api';\n\nimport type {BasicParams} from '../../../types';\nimport {redirectToAuthPage} from '../helpers';\nimport {invalidateAccessToken} from '../../helpers';\n\nimport type {CancelBillingOptions} from './types';\n\nexport function cancelBillingFactory(\n params: BasicParams,\n request: Request,\n session: Session,\n) {\n return async function cancelBilling(options: CancelBillingOptions) {\n const {api, logger} = params;\n\n logger.debug('Cancelling billing', {shop: session.shop, ...options});\n\n try {\n return await api.billing.cancel({\n session,\n subscriptionId: options.subscriptionId,\n isTest: options.isTest,\n prorate: options.prorate,\n });\n } catch (error) {\n if (error instanceof HttpResponseError && error.response.code === 401) {\n logger.debug('API token was invalid, redirecting to OAuth', {\n shop: session.shop,\n });\n await invalidateAccessToken(params, session);\n throw await redirectToAuthPage(params, request, session.shop);\n } else {\n throw error;\n }\n }\n };\n}\n"],"names":[],"mappings":";;;;;;SAQgB,oBAAoB,CAClC,MAAmB,EACnB,OAAgB,EAChB,OAAgB,EAAA;AAEhB,IAAA,OAAO,eAAe,aAAa,CAAC,OAA6B,EAAA;AAC/D,QAAA,MAAM,EAAC,GAAG,EAAE,MAAM,EAAC,GAAG,MAAM;AAE5B,QAAA,MAAM,CAAC,KAAK,CAAC,oBAAoB,EAAE,EAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,GAAG,OAAO,EAAC,CAAC;AAEpE,QAAA,IAAI;AACF,YAAA,OAAO,MAAM,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC;gBAC9B,OAAO;gBACP,cAAc,EAAE,OAAO,CAAC,cAAc;gBACtC,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,OAAO,EAAE,OAAO,CAAC,OAAO;AACzB,aAAA,CAAC;QACJ;QAAE,OAAO,KAAK,EAAE;AACd,YAAA,IAAI,KAAK,YAAY,iBAAiB,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,KAAK,GAAG,EAAE;AACrE,gBAAA,MAAM,CAAC,KAAK,CAAC,6CAA6C,EAAE;oBAC1D,IAAI,EAAE,OAAO,CAAC,IAAI;AACnB,iBAAA,CAAC;AACF,gBAAA,MAAM,qBAAqB,CAAC,MAAM,EAAE,OAAO,CAAC;gBAC5C,MAAM,MAAM,kBAAkB,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC;YAC/D;iBAAO;AACL,gBAAA,MAAM,KAAK;YACb;QACF;AACF,IAAA,CAAC;AACH;;;;"}