@rechargeapps/storefront-client 0.17.2 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/api/address.js +10 -0
- package/dist/cjs/api/address.js.map +1 -1
- package/dist/cjs/api/charge.js +8 -0
- package/dist/cjs/api/charge.js.map +1 -1
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/address.js +9 -1
- package/dist/esm/api/address.js.map +1 -1
- package/dist/esm/api/charge.js +7 -1
- package/dist/esm/api/charge.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/index.d.ts +25 -15
- package/dist/umd/recharge-client.min.js +9 -9
- package/package.json +2 -3
package/dist/cjs/api/address.js
CHANGED
|
@@ -19,6 +19,14 @@ async function updateAddress(session, id, updateRequest) {
|
|
|
19
19
|
const { address } = await request.rechargeApiRequest("put", `/addresses`, { id, data: updateRequest }, session);
|
|
20
20
|
return address;
|
|
21
21
|
}
|
|
22
|
+
async function applyDiscountToAddress(session, id, discountId) {
|
|
23
|
+
const { address } = await request.rechargeApiRequest("put", `/addresses`, { id, data: { discounts: [{ id: discountId }] } }, session);
|
|
24
|
+
return address;
|
|
25
|
+
}
|
|
26
|
+
async function removeDiscountsFromAddress(session, id) {
|
|
27
|
+
const { address } = await request.rechargeApiRequest("put", `/addresses`, { id, data: { discounts: [] } }, session);
|
|
28
|
+
return address;
|
|
29
|
+
}
|
|
22
30
|
function deleteAddress(session, id) {
|
|
23
31
|
return request.rechargeApiRequest("delete", `/addresses`, { id }, session);
|
|
24
32
|
}
|
|
@@ -35,11 +43,13 @@ async function skipFutureCharge(session, id, skipRequest) {
|
|
|
35
43
|
return charge;
|
|
36
44
|
}
|
|
37
45
|
|
|
46
|
+
exports.applyDiscountToAddress = applyDiscountToAddress;
|
|
38
47
|
exports.createAddress = createAddress;
|
|
39
48
|
exports.deleteAddress = deleteAddress;
|
|
40
49
|
exports.getAddress = getAddress;
|
|
41
50
|
exports.listAddresses = listAddresses;
|
|
42
51
|
exports.mergeAddresses = mergeAddresses;
|
|
52
|
+
exports.removeDiscountsFromAddress = removeDiscountsFromAddress;
|
|
43
53
|
exports.skipFutureCharge = skipFutureCharge;
|
|
44
54
|
exports.updateAddress = updateAddress;
|
|
45
55
|
//# sourceMappingURL=address.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.js","sources":["../../../src/api/address.ts"],"sourcesContent":["import { rechargeApiRequest } from '../utils/request';\nimport {\n AddressResponse,\n AddressListParams,\n CreateAddressRequest,\n UpdateAddressRequest,\n AddressListResponse,\n MergeAddressesRequest,\n SkipFutureChargeAddressRequest,\n SkipFutureChargeAddressResponse,\n} from '../types/address';\nimport { Session } from '../types/session';\n\n/** Returns all addresses from the store, or addresses for the customer given in the parameter. */\nexport function listAddresses(session: Session, query?: AddressListParams) {\n return rechargeApiRequest<AddressListResponse>('get', `/addresses`, { query }, session);\n}\n\n/** Retrieves address for customer based on specified address id. */\nexport async function getAddress(session: Session, id: string | number) {\n const { address } = await rechargeApiRequest<AddressResponse>('get', `/addresses`, { id }, session);\n return address;\n}\n\n/** Create a new address for a customer. */\nexport async function createAddress(session: Session, createRequest: CreateAddressRequest) {\n const { address } = await rechargeApiRequest<AddressResponse>('post', `/addresses`, { data: createRequest }, session);\n return address;\n}\n\n/** Updates an existing address to match the specified parameters. */\nexport async function updateAddress(session: Session, id: string | number, updateRequest: UpdateAddressRequest) {\n const { address } = await rechargeApiRequest<AddressResponse>(\n 'put',\n `/addresses`,\n { id, data: updateRequest },\n session\n );\n return address;\n}\n\n/** Deletes an address. Only Addresses with no active Subscriptions can be deleted. */\nexport function deleteAddress(session: Session, id: string | number) {\n return rechargeApiRequest<void>('delete', `/addresses`, { id }, session);\n}\n\n/**\n * Merges up to 10 source addresses into 1 target address.\n */\nexport async function mergeAddresses(session: Session, mergeRequest: MergeAddressesRequest) {\n const { address } = await rechargeApiRequest<AddressResponse>(\n 'post',\n `/addresses/merge`,\n {\n data: mergeRequest,\n },\n session\n );\n return address;\n}\n\n/**\n * Skip a Charge in the future for one or multiple Subscriptions associated with the Address.\n */\nexport async function skipFutureCharge(\n session: Session,\n id: string | number,\n skipRequest: SkipFutureChargeAddressRequest\n) {\n const { charge } = await rechargeApiRequest<SkipFutureChargeAddressResponse>(\n 'post',\n `/addresses/${id}/charges/skip`,\n {\n data: skipRequest,\n },\n session\n );\n return charge;\n}\n"],"names":["rechargeApiRequest"],"mappings":";;;;;;AACO,SAAS,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE;AAC9C,EAAE,OAAOA,0BAAkB,CAAC,KAAK,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;AACrE,CAAC;AACM,eAAe,UAAU,CAAC,OAAO,EAAE,EAAE,EAAE;AAC9C,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAMA,0BAAkB,CAAC,KAAK,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AACrF,EAAE,OAAO,OAAO,CAAC;AACjB,CAAC;AACM,eAAe,aAAa,CAAC,OAAO,EAAE,aAAa,EAAE;AAC5D,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAMA,0BAAkB,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,OAAO,CAAC,CAAC;AACvG,EAAE,OAAO,OAAO,CAAC;AACjB,CAAC;AACM,eAAe,aAAa,CAAC,OAAO,EAAE,EAAE,EAAE,aAAa,EAAE;AAChE,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAMA,0BAAkB,CAAC,KAAK,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,OAAO,CAAC,CAAC;AAC1G,EAAE,OAAO,OAAO,CAAC;AACjB,CAAC;AACM,SAAS,aAAa,CAAC,OAAO,EAAE,EAAE,EAAE;AAC3C,EAAE,OAAOA,0BAAkB,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AACrE,CAAC;AACM,eAAe,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE;AAC5D,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAMA,0BAAkB,CAAC,MAAM,EAAE,CAAC,gBAAgB,CAAC,EAAE;AAC3E,IAAI,IAAI,EAAE,YAAY;AACtB,GAAG,EAAE,OAAO,CAAC,CAAC;AACd,EAAE,OAAO,OAAO,CAAC;AACjB,CAAC;AACM,eAAe,gBAAgB,CAAC,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE;AACjE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAMA,0BAAkB,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,aAAa,CAAC,EAAE;AACvF,IAAI,IAAI,EAAE,WAAW;AACrB,GAAG,EAAE,OAAO,CAAC,CAAC;AACd,EAAE,OAAO,MAAM,CAAC;AAChB
|
|
1
|
+
{"version":3,"file":"address.js","sources":["../../../src/api/address.ts"],"sourcesContent":["import { rechargeApiRequest } from '../utils/request';\nimport {\n AddressResponse,\n AddressListParams,\n CreateAddressRequest,\n UpdateAddressRequest,\n AddressListResponse,\n MergeAddressesRequest,\n SkipFutureChargeAddressRequest,\n SkipFutureChargeAddressResponse,\n} from '../types/address';\nimport { Session } from '../types/session';\n\n/** Returns all addresses from the store, or addresses for the customer given in the parameter. */\nexport function listAddresses(session: Session, query?: AddressListParams) {\n return rechargeApiRequest<AddressListResponse>('get', `/addresses`, { query }, session);\n}\n\n/** Retrieves address for customer based on specified address id. */\nexport async function getAddress(session: Session, id: string | number) {\n const { address } = await rechargeApiRequest<AddressResponse>('get', `/addresses`, { id }, session);\n return address;\n}\n\n/** Create a new address for a customer. */\nexport async function createAddress(session: Session, createRequest: CreateAddressRequest) {\n const { address } = await rechargeApiRequest<AddressResponse>('post', `/addresses`, { data: createRequest }, session);\n return address;\n}\n\n/** Updates an existing address to match the specified parameters. */\nexport async function updateAddress(session: Session, id: string | number, updateRequest: UpdateAddressRequest) {\n const { address } = await rechargeApiRequest<AddressResponse>(\n 'put',\n `/addresses`,\n { id, data: updateRequest },\n session\n );\n return address;\n}\n\n/** Apply discount to an address. Addresses are currently limited to a single discount. */\nexport async function applyDiscountToAddress(session: Session, id: string | number, discountId: number) {\n const { address } = await rechargeApiRequest<AddressResponse>(\n 'put',\n `/addresses`,\n { id, data: { discounts: [{ id: discountId }] } },\n session\n );\n return address;\n}\n\n/** Removes all discounts from an address. */\nexport async function removeDiscountsFromAddress(session: Session, id: string | number) {\n const { address } = await rechargeApiRequest<AddressResponse>(\n 'put',\n `/addresses`,\n { id, data: { discounts: [] } },\n session\n );\n return address;\n}\n\n/** Deletes an address. Only Addresses with no active Subscriptions can be deleted. */\nexport function deleteAddress(session: Session, id: string | number) {\n return rechargeApiRequest<void>('delete', `/addresses`, { id }, session);\n}\n\n/**\n * Merges up to 10 source addresses into 1 target address.\n */\nexport async function mergeAddresses(session: Session, mergeRequest: MergeAddressesRequest) {\n const { address } = await rechargeApiRequest<AddressResponse>(\n 'post',\n `/addresses/merge`,\n {\n data: mergeRequest,\n },\n session\n );\n return address;\n}\n\n/**\n * Skip a Charge in the future for one or multiple Subscriptions associated with the Address.\n */\nexport async function skipFutureCharge(\n session: Session,\n id: string | number,\n skipRequest: SkipFutureChargeAddressRequest\n) {\n const { charge } = await rechargeApiRequest<SkipFutureChargeAddressResponse>(\n 'post',\n `/addresses/${id}/charges/skip`,\n {\n data: skipRequest,\n },\n session\n );\n return charge;\n}\n"],"names":["rechargeApiRequest"],"mappings":";;;;;;AACO,SAAS,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE;AAC9C,EAAE,OAAOA,0BAAkB,CAAC,KAAK,EAAE,CAAC,UAAU,C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MAAMA,0BAAkB,CAAC,KAAK,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AAC9G,EAAE,OAAO,OAAO,CAAC;AACjB,CAAC;AACM,SAAS,aAAa,CAAC,OAAO,EAAE,EAAE,EAAE;AAC3C,EAAE,OAAOA,0BAAkB,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AACrE,CAAC;AACM,eAAe,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE;AAC5D,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAMA,0BAAkB,CAAC,MAAM,EAAE,CAAC,gBAAgB,CAAC,EAAE;AAC3E,IAAI,IAAI,EAAE,YAAY;AACtB,GAAG,EAAE,OAAO,CAAC,CAAC;AACd,EAAE,OAAO,OAAO,CAAC;AACjB,CAAC;AACM,eAAe,gBAAgB,CAAC,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE;AACjE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAMA,0BAAkB,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,aAAa,CAAC,EAAE;AACvF,IAAI,IAAI,EAAE,WAAW;AACrB,GAAG,EAAE,OAAO,CAAC,CAAC;AACd,EAAE,OAAO,MAAM,CAAC;AAChB;;;;;;;;;;;;"}
|
package/dist/cjs/api/charge.js
CHANGED
|
@@ -12,12 +12,18 @@ function listCharges(session, query) {
|
|
|
12
12
|
return request.rechargeApiRequest("get", `/charges`, { query }, session);
|
|
13
13
|
}
|
|
14
14
|
async function applyDiscount(session, id, applyRequest) {
|
|
15
|
+
return applyDiscountToCharge(session, id, applyRequest);
|
|
16
|
+
}
|
|
17
|
+
async function applyDiscountToCharge(session, id, applyRequest) {
|
|
15
18
|
const { charge } = await request.rechargeApiRequest("post", `/charges/${id}/apply_discount`, {
|
|
16
19
|
data: applyRequest
|
|
17
20
|
}, session);
|
|
18
21
|
return charge;
|
|
19
22
|
}
|
|
20
23
|
async function removeDiscount(session, id) {
|
|
24
|
+
return removeDiscountsFromCharge(session, id);
|
|
25
|
+
}
|
|
26
|
+
async function removeDiscountsFromCharge(session, id) {
|
|
21
27
|
const { charge } = await request.rechargeApiRequest("post", `/charges/${id}/remove_discount`, {}, session);
|
|
22
28
|
return charge;
|
|
23
29
|
}
|
|
@@ -35,10 +41,12 @@ async function processCharge(session, id) {
|
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
exports.applyDiscount = applyDiscount;
|
|
44
|
+
exports.applyDiscountToCharge = applyDiscountToCharge;
|
|
38
45
|
exports.getCharge = getCharge;
|
|
39
46
|
exports.listCharges = listCharges;
|
|
40
47
|
exports.processCharge = processCharge;
|
|
41
48
|
exports.removeDiscount = removeDiscount;
|
|
49
|
+
exports.removeDiscountsFromCharge = removeDiscountsFromCharge;
|
|
42
50
|
exports.skipCharge = skipCharge;
|
|
43
51
|
exports.unskipCharge = unskipCharge;
|
|
44
52
|
//# sourceMappingURL=charge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"charge.js","sources":["../../../src/api/charge.ts"],"sourcesContent":["import { ApplyDiscountRequest, ChargeListParams, ChargeListResponse, ChargeResponse } from '../types/charge';\nimport { Session } from '../types/session';\nimport { rechargeApiRequest } from '../utils/request';\n\n/* Retrieve a Charge using the charge_id. */\nexport async function getCharge(session: Session, id: number | string) {\n const { charge } = await rechargeApiRequest<ChargeResponse>('get', `/charges`, { id }, session);\n return charge;\n}\n\n/** Lists charges */\nexport function listCharges(session: Session, query?: ChargeListParams) {\n return rechargeApiRequest<ChargeListResponse>('get', `/charges`, { query }, session);\n}\n\n/**\n * You cannot add a Discount to an existing queued Charge if the Charge or the associated Address already has one.\n * You can provide either discount_id or discount_code. If both parameters are passed, the value for discount_id will take precedence.\n * 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.\n */\nexport async function
|
|
1
|
+
{"version":3,"file":"charge.js","sources":["../../../src/api/charge.ts"],"sourcesContent":["import { ApplyDiscountRequest, ChargeListParams, ChargeListResponse, ChargeResponse } from '../types/charge';\nimport { Session } from '../types/session';\nimport { rechargeApiRequest } from '../utils/request';\n\n/* Retrieve a Charge using the charge_id. */\nexport async function getCharge(session: Session, id: number | string) {\n const { charge } = await rechargeApiRequest<ChargeResponse>('get', `/charges`, { id }, session);\n return charge;\n}\n\n/** Lists charges */\nexport function listCharges(session: Session, query?: ChargeListParams) {\n return rechargeApiRequest<ChargeListResponse>('get', `/charges`, { query }, session);\n}\n\n/**\n * @deprecated will be removed at version 1.0 - replaced with applyDiscountToCharge\n */\nexport async function applyDiscount(session: Session, id: number | string, applyRequest: ApplyDiscountRequest) {\n return applyDiscountToCharge(session, id, applyRequest);\n}\n\n/**\n * You cannot add a Discount to an existing queued Charge if the Charge or the associated Address already has one.\n * You can provide either discount_id or discount_code. If both parameters are passed, the value for discount_id will take precedence.\n * 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.\n */\nexport async function applyDiscountToCharge(session: Session, id: number | string, applyRequest: ApplyDiscountRequest) {\n const { charge } = await rechargeApiRequest<ChargeResponse>(\n 'post',\n `/charges/${id}/apply_discount`,\n {\n data: applyRequest,\n },\n session\n );\n return charge;\n}\n\n/**\n * @deprecated will be removed at version 1.0 - replaced with removeDiscountsFromCharge\n */\nexport async function removeDiscount(session: Session, id: number | string) {\n return removeDiscountsFromCharge(session, id);\n}\n\n/**\n * Remove all Discounts from a Charge without destroying the Discount.\n * 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.\n * If the Discount is on the parent Address, you cannot remove it using charge_id.\n * 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.\n * If you pass both parameters, it will remove the Discount from the Address.\n */\nexport async function removeDiscountsFromCharge(session: Session, id: number | string) {\n const { charge } = await rechargeApiRequest<ChargeResponse>('post', `/charges/${id}/remove_discount`, {}, session);\n return charge;\n}\n\n/* Skip a Charge. */\nexport async function skipCharge(session: Session, id: number | string) {\n const { charge } = await rechargeApiRequest<ChargeResponse>('post', `/charges/${id}/skip`, {}, session);\n return charge;\n}\n\n/* Unskip a Charge. */\nexport async function unskipCharge(session: Session, id: number | string) {\n const { charge } = await rechargeApiRequest<ChargeResponse>('post', `/charges/${id}/unskip`, {}, session);\n return charge;\n}\n\n/* Process a Charge. */\nexport async function processCharge(session: Session, id: number | string) {\n const { charge } = await rechargeApiRequest<ChargeResponse>('post', `/charges/${id}/process`, {}, session);\n return charge;\n}\n"],"names":["rechargeApiRequest"],"mappings":";;;;;;AACO,eAAe,SAAS,CAAC,OAAO,EAAE,EAAE,EAAE;AAC7C,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAMA,0BAAkB,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AAClF,EAAE,OAAO,MAAM,CAAC;AAChB,CAAC;AACM,SAAS,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE;AAC5C,EAAE,OAAOA,0BAAkB,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;AACnE,CAAC;AACM,eAAe,aAAa,CAAC,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE;AAC/D,EAAE,OAAO,qBAAqB,CAAC,OAAO,EAAE,EAAE,EAAE,YAAY,CAAC,CAAC;AAC1D,CAAC;AACM,eAAe,qBAAqB,CAAC,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE;AACvE,EAAE,MAAM,EAAE,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,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AAC7F,EAAE,OAAO,MAAM,CAAC;AAChB;;;;;;;;;;;;"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -18,20 +18,24 @@ var init = require('./utils/init.js');
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
+
exports.applyDiscountToAddress = address.applyDiscountToAddress;
|
|
21
22
|
exports.createAddress = address.createAddress;
|
|
22
23
|
exports.deleteAddress = address.deleteAddress;
|
|
23
24
|
exports.getAddress = address.getAddress;
|
|
24
25
|
exports.listAddresses = address.listAddresses;
|
|
25
26
|
exports.mergeAddresses = address.mergeAddresses;
|
|
27
|
+
exports.removeDiscountsFromAddress = address.removeDiscountsFromAddress;
|
|
26
28
|
exports.skipFutureCharge = address.skipFutureCharge;
|
|
27
29
|
exports.updateAddress = address.updateAddress;
|
|
28
30
|
exports.loginShopifyApi = auth.loginShopifyApi;
|
|
29
31
|
exports.loginShopifyAppProxy = auth.loginShopifyAppProxy;
|
|
30
32
|
exports.applyDiscount = charge.applyDiscount;
|
|
33
|
+
exports.applyDiscountToCharge = charge.applyDiscountToCharge;
|
|
31
34
|
exports.getCharge = charge.getCharge;
|
|
32
35
|
exports.listCharges = charge.listCharges;
|
|
33
36
|
exports.processCharge = charge.processCharge;
|
|
34
37
|
exports.removeDiscount = charge.removeDiscount;
|
|
38
|
+
exports.removeDiscountsFromCharge = charge.removeDiscountsFromCharge;
|
|
35
39
|
exports.skipCharge = charge.skipCharge;
|
|
36
40
|
exports.unskipCharge = charge.unskipCharge;
|
|
37
41
|
exports.getCDNBundleSettings = cdn.getCDNBundleSettings;
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/esm/api/address.js
CHANGED
|
@@ -15,6 +15,14 @@ async function updateAddress(session, id, updateRequest) {
|
|
|
15
15
|
const { address } = await rechargeApiRequest("put", `/addresses`, { id, data: updateRequest }, session);
|
|
16
16
|
return address;
|
|
17
17
|
}
|
|
18
|
+
async function applyDiscountToAddress(session, id, discountId) {
|
|
19
|
+
const { address } = await rechargeApiRequest("put", `/addresses`, { id, data: { discounts: [{ id: discountId }] } }, session);
|
|
20
|
+
return address;
|
|
21
|
+
}
|
|
22
|
+
async function removeDiscountsFromAddress(session, id) {
|
|
23
|
+
const { address } = await rechargeApiRequest("put", `/addresses`, { id, data: { discounts: [] } }, session);
|
|
24
|
+
return address;
|
|
25
|
+
}
|
|
18
26
|
function deleteAddress(session, id) {
|
|
19
27
|
return rechargeApiRequest("delete", `/addresses`, { id }, session);
|
|
20
28
|
}
|
|
@@ -31,5 +39,5 @@ async function skipFutureCharge(session, id, skipRequest) {
|
|
|
31
39
|
return charge;
|
|
32
40
|
}
|
|
33
41
|
|
|
34
|
-
export { createAddress, deleteAddress, getAddress, listAddresses, mergeAddresses, skipFutureCharge, updateAddress };
|
|
42
|
+
export { applyDiscountToAddress, createAddress, deleteAddress, getAddress, listAddresses, mergeAddresses, removeDiscountsFromAddress, skipFutureCharge, updateAddress };
|
|
35
43
|
//# sourceMappingURL=address.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.js","sources":["../../../src/api/address.ts"],"sourcesContent":["import { rechargeApiRequest } from '../utils/request';\nimport {\n AddressResponse,\n AddressListParams,\n CreateAddressRequest,\n UpdateAddressRequest,\n AddressListResponse,\n MergeAddressesRequest,\n SkipFutureChargeAddressRequest,\n SkipFutureChargeAddressResponse,\n} from '../types/address';\nimport { Session } from '../types/session';\n\n/** Returns all addresses from the store, or addresses for the customer given in the parameter. */\nexport function listAddresses(session: Session, query?: AddressListParams) {\n return rechargeApiRequest<AddressListResponse>('get', `/addresses`, { query }, session);\n}\n\n/** Retrieves address for customer based on specified address id. */\nexport async function getAddress(session: Session, id: string | number) {\n const { address } = await rechargeApiRequest<AddressResponse>('get', `/addresses`, { id }, session);\n return address;\n}\n\n/** Create a new address for a customer. */\nexport async function createAddress(session: Session, createRequest: CreateAddressRequest) {\n const { address } = await rechargeApiRequest<AddressResponse>('post', `/addresses`, { data: createRequest }, session);\n return address;\n}\n\n/** Updates an existing address to match the specified parameters. */\nexport async function updateAddress(session: Session, id: string | number, updateRequest: UpdateAddressRequest) {\n const { address } = await rechargeApiRequest<AddressResponse>(\n 'put',\n `/addresses`,\n { id, data: updateRequest },\n session\n );\n return address;\n}\n\n/** Deletes an address. Only Addresses with no active Subscriptions can be deleted. */\nexport function deleteAddress(session: Session, id: string | number) {\n return rechargeApiRequest<void>('delete', `/addresses`, { id }, session);\n}\n\n/**\n * Merges up to 10 source addresses into 1 target address.\n */\nexport async function mergeAddresses(session: Session, mergeRequest: MergeAddressesRequest) {\n const { address } = await rechargeApiRequest<AddressResponse>(\n 'post',\n `/addresses/merge`,\n {\n data: mergeRequest,\n },\n session\n );\n return address;\n}\n\n/**\n * Skip a Charge in the future for one or multiple Subscriptions associated with the Address.\n */\nexport async function skipFutureCharge(\n session: Session,\n id: string | number,\n skipRequest: SkipFutureChargeAddressRequest\n) {\n const { charge } = await rechargeApiRequest<SkipFutureChargeAddressResponse>(\n 'post',\n `/addresses/${id}/charges/skip`,\n {\n data: skipRequest,\n },\n session\n );\n return charge;\n}\n"],"names":[],"mappings":";;AACO,SAAS,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE;AAC9C,EAAE,OAAO,kBAAkB,CAAC,KAAK,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;AACrE,CAAC;AACM,eAAe,UAAU,CAAC,OAAO,EAAE,EAAE,EAAE;AAC9C,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG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AE,EAAE,CAAC,aAAa,CAAC,EAAE;AACvF,IAAI,IAAI,EAAE,WAAW;AACrB,GAAG,EAAE,OAAO,CAAC,CAAC;AACd,EAAE,OAAO,MAAM,CAAC;AAChB;;;;"}
|
|
1
|
+
{"version":3,"file":"address.js","sources":["../../../src/api/address.ts"],"sourcesContent":["import { rechargeApiRequest } from '../utils/request';\nimport {\n AddressResponse,\n AddressListParams,\n CreateAddressRequest,\n UpdateAddressRequest,\n AddressListResponse,\n MergeAddressesRequest,\n SkipFutureChargeAddressRequest,\n SkipFutureChargeAddressResponse,\n} from '../types/address';\nimport { Session } from '../types/session';\n\n/** Returns all addresses from the store, or addresses for the customer given in the parameter. */\nexport function listAddresses(session: Session, query?: AddressListParams) {\n return rechargeApiRequest<AddressListResponse>('get', `/addresses`, { query }, session);\n}\n\n/** Retrieves address for customer based on specified address id. */\nexport async function getAddress(session: Session, id: string | number) {\n const { address } = await rechargeApiRequest<AddressResponse>('get', `/addresses`, { id }, session);\n return address;\n}\n\n/** Create a new address for a customer. */\nexport async function createAddress(session: Session, createRequest: CreateAddressRequest) {\n const { address } = await rechargeApiRequest<AddressResponse>('post', `/addresses`, { data: createRequest }, session);\n return address;\n}\n\n/** Updates an existing address to match the specified parameters. */\nexport async function updateAddress(session: Session, id: string | number, updateRequest: UpdateAddressRequest) {\n const { address } = await rechargeApiRequest<AddressResponse>(\n 'put',\n `/addresses`,\n { id, data: updateRequest },\n session\n );\n return address;\n}\n\n/** Apply discount to an address. Addresses are currently limited to a single discount. */\nexport async function applyDiscountToAddress(session: Session, id: string | number, discountId: number) {\n const { address } = await rechargeApiRequest<AddressResponse>(\n 'put',\n `/addresses`,\n { id, data: { discounts: [{ id: discountId }] } },\n session\n );\n return address;\n}\n\n/** Removes all discounts from an address. */\nexport async function removeDiscountsFromAddress(session: Session, id: string | number) {\n const { address } = await rechargeApiRequest<AddressResponse>(\n 'put',\n `/addresses`,\n { id, data: { discounts: [] } },\n session\n );\n return address;\n}\n\n/** Deletes an address. Only Addresses with no active Subscriptions can be deleted. */\nexport function deleteAddress(session: Session, id: string | number) {\n return rechargeApiRequest<void>('delete', `/addresses`, { id }, session);\n}\n\n/**\n * Merges up to 10 source addresses into 1 target address.\n */\nexport async function mergeAddresses(session: Session, mergeRequest: MergeAddressesRequest) {\n const { address } = await rechargeApiRequest<AddressResponse>(\n 'post',\n `/addresses/merge`,\n {\n data: mergeRequest,\n },\n session\n );\n return address;\n}\n\n/**\n * Skip a Charge in the future for one or multiple Subscriptions associated with the Address.\n */\nexport async function skipFutureCharge(\n session: Session,\n id: string | number,\n skipRequest: SkipFutureChargeAddressRequest\n) {\n const { charge } = await rechargeApiRequest<SkipFutureChargeAddressResponse>(\n 'post',\n `/addresses/${id}/charges/skip`,\n {\n data: skipRequest,\n },\n session\n );\n return charge;\n}\n"],"names":[],"mappings":";;AACO,SAAS,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE;AAC9C,EAAE,OAAO,kBAAkB,CAAC,KAAK,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;AACrE,CAAC;AACM,eAAe,UAAU,CAAC,OAAO,EAAE,EAAE,EAAE;AAC9C,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,kBAAkB,CAAC,KAAK,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AACrF,EAAE,OAAO,OAAO,CAAC;AACjB,CAAC;AACM,eAAe,aAAa,CAAC,OAAO,EAAE,aAAa,EAAE;AAC5D,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,kBAAkB,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,OAAO,CAAC,CAAC;AACvG,EAAE,OAAO,OAAO,CAAC;AACjB,CAAC;AACM,eAAe,aAAa,CAAC,OAAO,EAAE,EAAE,EAAE,aAAa,EAAE;AAChE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AACjB,CAAC;AACM,eAAe,gBAAgB,CAAC,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE;AACjE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,kBAAkB,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,aAAa,CAAC,EAAE;AACvF,IAAI,IAAI,EAAE,WAAW;AACrB,GAAG,EAAE,OAAO,CAAC,CAAC;AACd,EAAE,OAAO,MAAM,CAAC;AAChB;;;;"}
|
package/dist/esm/api/charge.js
CHANGED
|
@@ -8,12 +8,18 @@ function listCharges(session, query) {
|
|
|
8
8
|
return rechargeApiRequest("get", `/charges`, { query }, session);
|
|
9
9
|
}
|
|
10
10
|
async function applyDiscount(session, id, applyRequest) {
|
|
11
|
+
return applyDiscountToCharge(session, id, applyRequest);
|
|
12
|
+
}
|
|
13
|
+
async function applyDiscountToCharge(session, id, applyRequest) {
|
|
11
14
|
const { charge } = await rechargeApiRequest("post", `/charges/${id}/apply_discount`, {
|
|
12
15
|
data: applyRequest
|
|
13
16
|
}, session);
|
|
14
17
|
return charge;
|
|
15
18
|
}
|
|
16
19
|
async function removeDiscount(session, id) {
|
|
20
|
+
return removeDiscountsFromCharge(session, id);
|
|
21
|
+
}
|
|
22
|
+
async function removeDiscountsFromCharge(session, id) {
|
|
17
23
|
const { charge } = await rechargeApiRequest("post", `/charges/${id}/remove_discount`, {}, session);
|
|
18
24
|
return charge;
|
|
19
25
|
}
|
|
@@ -30,5 +36,5 @@ async function processCharge(session, id) {
|
|
|
30
36
|
return charge;
|
|
31
37
|
}
|
|
32
38
|
|
|
33
|
-
export { applyDiscount, getCharge, listCharges, processCharge, removeDiscount, skipCharge, unskipCharge };
|
|
39
|
+
export { applyDiscount, applyDiscountToCharge, getCharge, listCharges, processCharge, removeDiscount, removeDiscountsFromCharge, skipCharge, unskipCharge };
|
|
34
40
|
//# sourceMappingURL=charge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"charge.js","sources":["../../../src/api/charge.ts"],"sourcesContent":["import { ApplyDiscountRequest, ChargeListParams, ChargeListResponse, ChargeResponse } from '../types/charge';\nimport { Session } from '../types/session';\nimport { rechargeApiRequest } from '../utils/request';\n\n/* Retrieve a Charge using the charge_id. */\nexport async function getCharge(session: Session, id: number | string) {\n const { charge } = await rechargeApiRequest<ChargeResponse>('get', `/charges`, { id }, session);\n return charge;\n}\n\n/** Lists charges */\nexport function listCharges(session: Session, query?: ChargeListParams) {\n return rechargeApiRequest<ChargeListResponse>('get', `/charges`, { query }, session);\n}\n\n/**\n * You cannot add a Discount to an existing queued Charge if the Charge or the associated Address already has one.\n * You can provide either discount_id or discount_code. If both parameters are passed, the value for discount_id will take precedence.\n * 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.\n */\nexport async function
|
|
1
|
+
{"version":3,"file":"charge.js","sources":["../../../src/api/charge.ts"],"sourcesContent":["import { ApplyDiscountRequest, ChargeListParams, ChargeListResponse, ChargeResponse } from '../types/charge';\nimport { Session } from '../types/session';\nimport { rechargeApiRequest } from '../utils/request';\n\n/* Retrieve a Charge using the charge_id. */\nexport async function getCharge(session: Session, id: number | string) {\n const { charge } = await rechargeApiRequest<ChargeResponse>('get', `/charges`, { id }, session);\n return charge;\n}\n\n/** Lists charges */\nexport function listCharges(session: Session, query?: ChargeListParams) {\n return rechargeApiRequest<ChargeListResponse>('get', `/charges`, { query }, session);\n}\n\n/**\n * @deprecated will be removed at version 1.0 - replaced with applyDiscountToCharge\n */\nexport async function applyDiscount(session: Session, id: number | string, applyRequest: ApplyDiscountRequest) {\n return applyDiscountToCharge(session, id, applyRequest);\n}\n\n/**\n * You cannot add a Discount to an existing queued Charge if the Charge or the associated Address already has one.\n * You can provide either discount_id or discount_code. If both parameters are passed, the value for discount_id will take precedence.\n * 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.\n */\nexport async function applyDiscountToCharge(session: Session, id: number | string, applyRequest: ApplyDiscountRequest) {\n const { charge } = await rechargeApiRequest<ChargeResponse>(\n 'post',\n `/charges/${id}/apply_discount`,\n {\n data: applyRequest,\n },\n session\n );\n return charge;\n}\n\n/**\n * @deprecated will be removed at version 1.0 - replaced with removeDiscountsFromCharge\n */\nexport async function removeDiscount(session: Session, id: number | string) {\n return removeDiscountsFromCharge(session, id);\n}\n\n/**\n * Remove all Discounts from a Charge without destroying the Discount.\n * 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.\n * If the Discount is on the parent Address, you cannot remove it using charge_id.\n * 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.\n * If you pass both parameters, it will remove the Discount from the Address.\n */\nexport async function removeDiscountsFromCharge(session: Session, id: number | string) {\n const { charge } = await rechargeApiRequest<ChargeResponse>('post', `/charges/${id}/remove_discount`, {}, session);\n return charge;\n}\n\n/* Skip a Charge. */\nexport async function skipCharge(session: Session, id: number | string) {\n const { charge } = await rechargeApiRequest<ChargeResponse>('post', `/charges/${id}/skip`, {}, session);\n return charge;\n}\n\n/* Unskip a Charge. */\nexport async function unskipCharge(session: Session, id: number | string) {\n const { charge } = await rechargeApiRequest<ChargeResponse>('post', `/charges/${id}/unskip`, {}, session);\n return charge;\n}\n\n/* Process a Charge. */\nexport async function processCharge(session: Session, id: number | string) {\n const { charge } = await rechargeApiRequest<ChargeResponse>('post', `/charges/${id}/process`, {}, session);\n return charge;\n}\n"],"names":[],"mappings":";;AACO,eAAe,SAAS,CAAC,OAAO,EAAE,EAAE,EAAE;AAC7C,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,kBAAkB,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,CA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F,EAAE,OAAO,MAAM,CAAC;AAChB,CAAC;AACM,eAAe,YAAY,CAAC,OAAO,EAAE,EAAE,EAAE;AAChD,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,kBAAkB,CAAC,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AAC5F,EAAE,OAAO,MAAM,CAAC;AAChB,CAAC;AACM,eAAe,aAAa,CAAC,OAAO,EAAE,EAAE,EAAE;AACjD,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,kBAAkB,CAAC,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AAC7F,EAAE,OAAO,MAAM,CAAC;AAChB;;;;"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { createAddress, deleteAddress, getAddress, listAddresses, mergeAddresses, skipFutureCharge, updateAddress } from './api/address.js';
|
|
1
|
+
export { applyDiscountToAddress, createAddress, deleteAddress, getAddress, listAddresses, mergeAddresses, removeDiscountsFromAddress, skipFutureCharge, updateAddress } from './api/address.js';
|
|
2
2
|
export { loginShopifyApi, loginShopifyAppProxy } from './api/auth.js';
|
|
3
|
-
export { applyDiscount, getCharge, listCharges, processCharge, removeDiscount, skipCharge, unskipCharge } from './api/charge.js';
|
|
3
|
+
export { applyDiscount, applyDiscountToCharge, getCharge, listCharges, processCharge, removeDiscount, removeDiscountsFromCharge, skipCharge, unskipCharge } from './api/charge.js';
|
|
4
4
|
export { getCDNBundleSettings, getCDNProduct, getCDNProductAndSettings, getCDNProducts, getCDNProductsAndSettings, getCDNStoreSettings, getCDNWidgetSettings, resetCDNCache } from './api/cdn.js';
|
|
5
5
|
export { getBundleId, getDynamicBundleItems, validateBundle, validateDynamicBundle } from './api/bundle.js';
|
|
6
6
|
export { activateMembership, cancelMembership, getMembership, listMemberships } from './api/membership.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -100,13 +100,13 @@ interface TaxLine {
|
|
|
100
100
|
}
|
|
101
101
|
interface Discount {
|
|
102
102
|
/** The ID of the Discount. */
|
|
103
|
-
id:
|
|
103
|
+
id: number;
|
|
104
104
|
/** The code of the Discount. */
|
|
105
|
-
code
|
|
105
|
+
code?: string;
|
|
106
106
|
/** The value of the Discount. */
|
|
107
|
-
value
|
|
107
|
+
value?: number;
|
|
108
108
|
/** The type of the value of the Discount. */
|
|
109
|
-
value_type
|
|
109
|
+
value_type?: 'percentage' | 'fixed_amount' | 'shipping';
|
|
110
110
|
}
|
|
111
111
|
interface AnalyticsData {
|
|
112
112
|
utm_params: {
|
|
@@ -304,7 +304,7 @@ interface Charge {
|
|
|
304
304
|
/** An object containing the associated external transaction ID. */
|
|
305
305
|
external_transaction_id: ExternalTransactionId;
|
|
306
306
|
/** A list of line_item objects, each containing information about a distinct purchase item. */
|
|
307
|
-
line_items: LineItem;
|
|
307
|
+
line_items: LineItem[];
|
|
308
308
|
/** Notes associated with the Charge. */
|
|
309
309
|
note: string;
|
|
310
310
|
/** An array of name-value pairs of order attributes on the Charge. */
|
|
@@ -419,9 +419,7 @@ interface CreateAddressRequest {
|
|
|
419
419
|
/** 2-letter country code. */
|
|
420
420
|
country_code: string;
|
|
421
421
|
/** A list of discounts applied on the address. These discounts will apply to future recurring charges associated with this address. */
|
|
422
|
-
discounts?:
|
|
423
|
-
id: number;
|
|
424
|
-
}[];
|
|
422
|
+
discounts?: Discount[];
|
|
425
423
|
/** The customer’s first name associated with the address. */
|
|
426
424
|
first_name: string;
|
|
427
425
|
/** The customer’s last name associated with the address. */
|
|
@@ -487,9 +485,7 @@ interface Address {
|
|
|
487
485
|
/** Unique numeric identifier for the customer associated with the address. */
|
|
488
486
|
customer_id: number;
|
|
489
487
|
/** A list of discounts applied on the address. These discounts will apply to future recurring charges associated with this address. */
|
|
490
|
-
discounts
|
|
491
|
-
id: number;
|
|
492
|
-
}[];
|
|
488
|
+
discounts: Discount[];
|
|
493
489
|
/** The customer’s first name associated with the address. */
|
|
494
490
|
first_name: string;
|
|
495
491
|
/** The customer’s last name associated with the address. */
|
|
@@ -557,6 +553,10 @@ declare function getAddress(session: Session, id: string | number): Promise<Addr
|
|
|
557
553
|
declare function createAddress(session: Session, createRequest: CreateAddressRequest): Promise<Address>;
|
|
558
554
|
/** Updates an existing address to match the specified parameters. */
|
|
559
555
|
declare function updateAddress(session: Session, id: string | number, updateRequest: UpdateAddressRequest): Promise<Address>;
|
|
556
|
+
/** Apply discount to an address. Addresses are currently limited to a single discount. */
|
|
557
|
+
declare function applyDiscountToAddress(session: Session, id: string | number, discountId: number): Promise<Address>;
|
|
558
|
+
/** Removes all discounts from an address. */
|
|
559
|
+
declare function removeDiscountsFromAddress(session: Session, id: string | number): Promise<Address>;
|
|
560
560
|
/** Deletes an address. Only Addresses with no active Subscriptions can be deleted. */
|
|
561
561
|
declare function deleteAddress(session: Session, id: string | number): Promise<void>;
|
|
562
562
|
/**
|
|
@@ -574,20 +574,28 @@ declare function loginShopifyApi(shopifyStorefrontToken: string, shopifyCustomer
|
|
|
574
574
|
declare function getCharge(session: Session, id: number | string): Promise<Charge>;
|
|
575
575
|
/** Lists charges */
|
|
576
576
|
declare function listCharges(session: Session, query?: ChargeListParams): Promise<ChargeListResponse>;
|
|
577
|
+
/**
|
|
578
|
+
* @deprecated will be removed at version 1.0 - replaced with applyDiscountToCharge
|
|
579
|
+
*/
|
|
580
|
+
declare function applyDiscount(session: Session, id: number | string, applyRequest: ApplyDiscountRequest): Promise<Charge>;
|
|
577
581
|
/**
|
|
578
582
|
* You cannot add a Discount to an existing queued Charge if the Charge or the associated Address already has one.
|
|
579
583
|
* You can provide either discount_id or discount_code. If both parameters are passed, the value for discount_id will take precedence.
|
|
580
584
|
* 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.
|
|
581
585
|
*/
|
|
582
|
-
declare function
|
|
586
|
+
declare function applyDiscountToCharge(session: Session, id: number | string, applyRequest: ApplyDiscountRequest): Promise<Charge>;
|
|
583
587
|
/**
|
|
584
|
-
*
|
|
588
|
+
* @deprecated will be removed at version 1.0 - replaced with removeDiscountsFromCharge
|
|
589
|
+
*/
|
|
590
|
+
declare function removeDiscount(session: Session, id: number | string): Promise<Charge>;
|
|
591
|
+
/**
|
|
592
|
+
* Remove all Discounts from a Charge without destroying the Discount.
|
|
585
593
|
* 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.
|
|
586
594
|
* If the Discount is on the parent Address, you cannot remove it using charge_id.
|
|
587
595
|
* 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.
|
|
588
596
|
* If you pass both parameters, it will remove the Discount from the Address.
|
|
589
597
|
*/
|
|
590
|
-
declare function
|
|
598
|
+
declare function removeDiscountsFromCharge(session: Session, id: number | string): Promise<Charge>;
|
|
591
599
|
declare function skipCharge(session: Session, id: number | string): Promise<Charge>;
|
|
592
600
|
declare function unskipCharge(session: Session, id: number | string): Promise<Charge>;
|
|
593
601
|
declare function processCharge(session: Session, id: number | string): Promise<Charge>;
|
|
@@ -869,6 +877,8 @@ interface CDNBaseWidgetSettings {
|
|
|
869
877
|
subscribe_without_discount_message: string;
|
|
870
878
|
subscription_details_verbiage: string;
|
|
871
879
|
translations: Translations;
|
|
880
|
+
/** Whether or not plans data will be used on the widget */
|
|
881
|
+
use_plans_data?: boolean;
|
|
872
882
|
widget_charge_every: string;
|
|
873
883
|
widget_deliver_every: string;
|
|
874
884
|
widget_icon: WidgetIconColor;
|
|
@@ -1588,4 +1598,4 @@ declare const api: {
|
|
|
1588
1598
|
};
|
|
1589
1599
|
declare function initRecharge(opt?: InitOptions): void;
|
|
1590
1600
|
|
|
1591
|
-
export { ActivateMembershipRequest, Address, AddressListParams, AddressListResponse, AddressResponse, AddressSortBy, AnalyticsData, ApplyDiscountRequest, AssociatedAddress, Bundle, BundleItem, BundleProperties, BundleSelection, BundleTranslations, CDNBaseWidgetSettings, CDNBundleLayoutSettings, CDNBundleSettings, CDNBundleStep, CDNBundleStepOption, CDNBundleVariant, CDNBundleVariantOptionSource, CDNBundleVariantSelectionDefault, CDNPrices, CDNProduct, CDNProductAndSettings, CDNProductKeyObject, CDNProductOption, CDNProductOptionValue, CDNProductRaw, CDNProductResource, CDNProductsAndSettings, CDNProductsAndSettingsResource, CDNSellingPlan, CDNSellingPlanAllocations, CDNSellingPlanGroup, CDNStoreSettings, CDNSubscriptionOption, CDNVariant, CDNVariantOptionValue, CDNWidgetSettings, CDNWidgetSettingsRaw, CDNWidgetSettingsResource, CRUDRequestOptions, CancelMembershipRequest, CancelSubscriptionRequest, ChannelSettings, Charge, ChargeListParams, ChargeListResponse, ChargeResponse, ChargeSortBy, ChargeStatus, ColorString, CreateAddressRequest, CreateOnetimeRequest, CreateSubscriptionRequest, Customer, CustomerDeliveryScheduleParams, CustomerDeliveryScheduleResponse, CustomerIncludes, CustomerOptionalUpdateProps, Delivery, Discount, ExternalId, ExternalTransactionId, FirstOption, GetCustomerOptions, GetRequestOptions, HTMLString, InitOptions, IntervalUnit, IsoDateString, LineItem, ListParams, LoginResponse, Membership, MembershipIncludes, MembershipListParams, MembershipListResponse, MembershipResponse, MembershipStatus, MembershipsSortBy, MergeAddressesRequest, Method, Onetime, OnetimeCreateProps, OnetimeListParams, OnetimeOptionalCreateProps, OnetimeOptionalUpdateProps, OnetimeRequiredCreateProps, OnetimesResponse, OnetimesSortBy, Order, OrderListParams, OrderSortBy, OrderStatus, OrderType, OrdersResponse, PaymentDetails, PaymentMethod, PaymentMethodListParams, PaymentMethodOptionalUpdateProps, PaymentMethodSortBy, PaymentMethodStatus, PaymentMethodsResponse, PaymentType, Plan, PlanListParams, PlanSortBy, PlanType, PlansResponse, PriceAdjustmentsType, ProcessorName, ProductImage, Property, Request, RequestHeaders, RequestOptions, RequestOptionsHeaders, Session, ShippingLine, SkipFutureChargeAddressRequest, SkipFutureChargeAddressResponse, StorefrontEnvironment, StorefrontOptions, StorefrontPurchaseOption, SubType, Subscription, SubscriptionListParams, SubscriptionOptionalCreateProps, SubscriptionOptionalUpdateProps, SubscriptionPreferences, SubscriptionRequiredCreateProps, SubscriptionSortBy, SubscriptionStatus, SubscriptionsResponse, TaxLine, Translations, UpdateAddressRequest, UpdateCustomerRequest, UpdateOnetimeRequest, UpdatePaymentMethodRequest, UpdateSubscriptionParams, UpdateSubscriptionRequest, WidgetIconColor, WidgetTemplateType, activateMembership, activateSubscription, api, applyDiscount, cancelMembership, cancelSubscription, createAddress, createOnetime, createSubscription, deleteAddress, deleteOnetime, getAddress, getBundleId, getCDNBundleSettings, getCDNProduct, getCDNProductAndSettings, getCDNProducts, getCDNProductsAndSettings, getCDNStoreSettings, getCDNWidgetSettings, getCharge, getCustomer, getDeliverySchedule, getDynamicBundleItems, getMembership, getOnetime, getOrder, getPaymentMethod, getPlan, getSubscription, initRecharge, listAddresses, listCharges, listMemberships, listOnetimes, listOrders, listPaymentMethods, listPlans, listSubscriptions, loginShopifyApi, loginShopifyAppProxy, membershipIncludes, mergeAddresses, processCharge, removeDiscount, resetCDNCache, skipCharge, skipFutureCharge, skipSubscriptionCharge, unskipCharge, updateAddress, updateCustomer, updateOnetime, updatePaymentMethod, updateSubscription, updateSubscriptionAddress, updateSubscriptionChargeDate, validateBundle, validateDynamicBundle };
|
|
1601
|
+
export { ActivateMembershipRequest, Address, AddressListParams, AddressListResponse, AddressResponse, AddressSortBy, AnalyticsData, ApplyDiscountRequest, AssociatedAddress, Bundle, BundleItem, BundleProperties, BundleSelection, BundleTranslations, CDNBaseWidgetSettings, CDNBundleLayoutSettings, CDNBundleSettings, CDNBundleStep, CDNBundleStepOption, CDNBundleVariant, CDNBundleVariantOptionSource, CDNBundleVariantSelectionDefault, CDNPrices, CDNProduct, CDNProductAndSettings, CDNProductKeyObject, CDNProductOption, CDNProductOptionValue, CDNProductRaw, CDNProductResource, CDNProductsAndSettings, CDNProductsAndSettingsResource, CDNSellingPlan, CDNSellingPlanAllocations, CDNSellingPlanGroup, CDNStoreSettings, CDNSubscriptionOption, CDNVariant, CDNVariantOptionValue, CDNWidgetSettings, CDNWidgetSettingsRaw, CDNWidgetSettingsResource, CRUDRequestOptions, CancelMembershipRequest, CancelSubscriptionRequest, ChannelSettings, Charge, ChargeListParams, ChargeListResponse, ChargeResponse, ChargeSortBy, ChargeStatus, ColorString, CreateAddressRequest, CreateOnetimeRequest, CreateSubscriptionRequest, Customer, CustomerDeliveryScheduleParams, CustomerDeliveryScheduleResponse, CustomerIncludes, CustomerOptionalUpdateProps, Delivery, Discount, ExternalId, ExternalTransactionId, FirstOption, GetCustomerOptions, GetRequestOptions, HTMLString, InitOptions, IntervalUnit, IsoDateString, LineItem, ListParams, LoginResponse, Membership, MembershipIncludes, MembershipListParams, MembershipListResponse, MembershipResponse, MembershipStatus, MembershipsSortBy, MergeAddressesRequest, Method, Onetime, OnetimeCreateProps, OnetimeListParams, OnetimeOptionalCreateProps, OnetimeOptionalUpdateProps, OnetimeRequiredCreateProps, OnetimesResponse, OnetimesSortBy, Order, OrderListParams, OrderSortBy, OrderStatus, OrderType, OrdersResponse, PaymentDetails, PaymentMethod, PaymentMethodListParams, PaymentMethodOptionalUpdateProps, PaymentMethodSortBy, PaymentMethodStatus, PaymentMethodsResponse, PaymentType, Plan, PlanListParams, PlanSortBy, PlanType, PlansResponse, PriceAdjustmentsType, ProcessorName, ProductImage, Property, Request, RequestHeaders, RequestOptions, RequestOptionsHeaders, Session, ShippingLine, SkipFutureChargeAddressRequest, SkipFutureChargeAddressResponse, StorefrontEnvironment, StorefrontOptions, StorefrontPurchaseOption, SubType, Subscription, SubscriptionListParams, SubscriptionOptionalCreateProps, SubscriptionOptionalUpdateProps, SubscriptionPreferences, SubscriptionRequiredCreateProps, SubscriptionSortBy, SubscriptionStatus, SubscriptionsResponse, TaxLine, Translations, UpdateAddressRequest, UpdateCustomerRequest, UpdateOnetimeRequest, UpdatePaymentMethodRequest, UpdateSubscriptionParams, UpdateSubscriptionRequest, WidgetIconColor, WidgetTemplateType, activateMembership, activateSubscription, api, applyDiscount, applyDiscountToAddress, applyDiscountToCharge, cancelMembership, cancelSubscription, createAddress, createOnetime, createSubscription, deleteAddress, deleteOnetime, getAddress, getBundleId, getCDNBundleSettings, getCDNProduct, getCDNProductAndSettings, getCDNProducts, getCDNProductsAndSettings, getCDNStoreSettings, getCDNWidgetSettings, getCharge, getCustomer, getDeliverySchedule, getDynamicBundleItems, getMembership, getOnetime, getOrder, getPaymentMethod, getPlan, getSubscription, initRecharge, listAddresses, listCharges, listMemberships, listOnetimes, listOrders, listPaymentMethods, listPlans, listSubscriptions, loginShopifyApi, loginShopifyAppProxy, membershipIncludes, mergeAddresses, processCharge, removeDiscount, removeDiscountsFromAddress, removeDiscountsFromCharge, resetCDNCache, skipCharge, skipFutureCharge, skipSubscriptionCharge, unskipCharge, updateAddress, updateCustomer, updateOnetime, updatePaymentMethod, updateSubscription, updateSubscriptionAddress, updateSubscriptionChargeDate, validateBundle, validateDynamicBundle };
|