@xyo-network/rebilly-payment-card-authorization-plugin 2.99.3 → 2.99.5
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/browser/Api/PaymentCardToken/Response.d.cts +1 -1
- package/dist/browser/Api/PaymentCardToken/Response.d.mts +1 -1
- package/dist/browser/Api/PaymentCardToken/Response.d.ts +1 -1
- package/dist/browser/Api/PaymentCardToken/index.d.cts +2 -2
- package/dist/browser/Api/PaymentCardToken/index.d.mts +2 -2
- package/dist/browser/Api/PaymentCardToken/index.d.ts +2 -2
- package/dist/browser/Api/index.d.cts +1 -1
- package/dist/browser/Api/index.d.mts +1 -1
- package/dist/browser/Api/index.d.ts +1 -1
- package/dist/browser/Config.d.cts.map +1 -1
- package/dist/browser/Config.d.mts.map +1 -1
- package/dist/browser/Config.d.ts.map +1 -1
- package/dist/browser/Params.d.cts +1 -1
- package/dist/browser/Params.d.mts +1 -1
- package/dist/browser/Params.d.ts +1 -1
- package/dist/browser/Sentinel.d.cts +1 -1
- package/dist/browser/Sentinel.d.mts +1 -1
- package/dist/browser/Sentinel.d.ts +1 -1
- package/dist/browser/index.cjs +51 -32
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.d.cts +4 -4
- package/dist/browser/index.d.mts +4 -4
- package/dist/browser/index.d.ts +4 -4
- package/dist/browser/{index.js → index.mjs} +54 -33
- package/dist/browser/index.mjs.map +1 -0
- package/dist/browser/util/index.d.cts +1 -1
- package/dist/browser/util/index.d.mts +1 -1
- package/dist/browser/util/index.d.ts +1 -1
- package/dist/browser/util/toTokenRequest.d.cts +1 -1
- package/dist/browser/util/toTokenRequest.d.mts +1 -1
- package/dist/browser/util/toTokenRequest.d.ts +1 -1
- package/dist/neutral/Api/PaymentCardToken/Response.d.cts +1 -1
- package/dist/neutral/Api/PaymentCardToken/Response.d.mts +1 -1
- package/dist/neutral/Api/PaymentCardToken/Response.d.ts +1 -1
- package/dist/neutral/Api/PaymentCardToken/index.d.cts +2 -2
- package/dist/neutral/Api/PaymentCardToken/index.d.mts +2 -2
- package/dist/neutral/Api/PaymentCardToken/index.d.ts +2 -2
- package/dist/neutral/Api/index.d.cts +1 -1
- package/dist/neutral/Api/index.d.mts +1 -1
- package/dist/neutral/Api/index.d.ts +1 -1
- package/dist/neutral/Config.d.cts.map +1 -1
- package/dist/neutral/Config.d.mts.map +1 -1
- package/dist/neutral/Config.d.ts.map +1 -1
- package/dist/neutral/Params.d.cts +1 -1
- package/dist/neutral/Params.d.mts +1 -1
- package/dist/neutral/Params.d.ts +1 -1
- package/dist/neutral/Sentinel.d.cts +1 -1
- package/dist/neutral/Sentinel.d.mts +1 -1
- package/dist/neutral/Sentinel.d.ts +1 -1
- package/dist/neutral/index.cjs +51 -32
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.d.cts +4 -4
- package/dist/neutral/index.d.mts +4 -4
- package/dist/neutral/index.d.ts +4 -4
- package/dist/neutral/{index.js → index.mjs} +54 -33
- package/dist/neutral/index.mjs.map +1 -0
- package/dist/neutral/util/index.d.cts +1 -1
- package/dist/neutral/util/index.d.mts +1 -1
- package/dist/neutral/util/index.d.ts +1 -1
- package/dist/neutral/util/toTokenRequest.d.cts +1 -1
- package/dist/neutral/util/toTokenRequest.d.mts +1 -1
- package/dist/neutral/util/toTokenRequest.d.ts +1 -1
- package/dist/node/Api/PaymentCardToken/Response.d.cts +1 -1
- package/dist/node/Api/PaymentCardToken/Response.d.mts +1 -1
- package/dist/node/Api/PaymentCardToken/Response.d.ts +1 -1
- package/dist/node/Api/PaymentCardToken/index.d.cts +2 -2
- package/dist/node/Api/PaymentCardToken/index.d.mts +2 -2
- package/dist/node/Api/PaymentCardToken/index.d.ts +2 -2
- package/dist/node/Api/index.d.cts +1 -1
- package/dist/node/Api/index.d.mts +1 -1
- package/dist/node/Api/index.d.ts +1 -1
- package/dist/node/Config.d.cts.map +1 -1
- package/dist/node/Config.d.mts.map +1 -1
- package/dist/node/Config.d.ts.map +1 -1
- package/dist/node/Params.d.cts +1 -1
- package/dist/node/Params.d.mts +1 -1
- package/dist/node/Params.d.ts +1 -1
- package/dist/node/Sentinel.d.cts +1 -1
- package/dist/node/Sentinel.d.mts +1 -1
- package/dist/node/Sentinel.d.ts +1 -1
- package/dist/node/index.cjs +54 -34
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +4 -4
- package/dist/node/index.d.mts +4 -4
- package/dist/node/index.d.ts +4 -4
- package/dist/node/{index.js → index.mjs} +57 -35
- package/dist/node/index.mjs.map +1 -0
- package/dist/node/util/index.d.cts +1 -1
- package/dist/node/util/index.d.mts +1 -1
- package/dist/node/util/index.d.ts +1 -1
- package/dist/node/util/toTokenRequest.d.cts +1 -1
- package/dist/node/util/toTokenRequest.d.mts +1 -1
- package/dist/node/util/toTokenRequest.d.ts +1 -1
- package/package.json +18 -18
- package/src/Api/PaymentCardToken/Response.ts +1 -1
- package/src/Api/PaymentCardToken/index.ts +2 -2
- package/src/Api/index.ts +1 -1
- package/src/Config.ts +2 -2
- package/src/Params.ts +1 -1
- package/src/Sentinel.ts +4 -4
- package/src/index.ts +4 -4
- package/src/util/index.ts +1 -1
- package/src/util/toTokenRequest.ts +1 -1
- package/dist/browser/index.js.map +0 -1
- package/dist/neutral/index.js.map +0 -1
- package/dist/node/index.js.map +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './Request.
|
|
2
|
-
export * from './Response.
|
|
1
|
+
export * from './Request.ts';
|
|
2
|
+
export * from './Response.ts';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './Request.
|
|
2
|
-
export * from './Response.
|
|
1
|
+
export * from './Request.ts';
|
|
2
|
+
export * from './Response.ts';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './PaymentCardToken/index.
|
|
1
|
+
export * from './PaymentCardToken/index.ts';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './PaymentCardToken/index.
|
|
1
|
+
export * from './PaymentCardToken/index.ts';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/node/Api/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './PaymentCardToken/index.
|
|
1
|
+
export * from './PaymentCardToken/index.ts';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../src/Config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAA;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAI5D,eAAO,MAAM,mDAAmD,uFAA4D,CAAA;AAC5H,MAAM,MAAM,mDAAmD,GAAG,OAAO,mDAAmD,CAAA;AAK5H,MAAM,MAAM,6CAA6C,GAAG,cAAc,CAAC;IAIzE,MAAM,EAAE,mDAAmD,CAAA;CAC5D,CAAC,
|
|
1
|
+
{"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../src/Config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAA;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAI5D,eAAO,MAAM,mDAAmD,uFAA4D,CAAA;AAC5H,MAAM,MAAM,mDAAmD,GAAG,OAAO,mDAAmD,CAAA;AAK5H,MAAM,MAAM,6CAA6C,GAAG,cAAc,CAAC;IAIzE,MAAM,EAAE,mDAAmD,CAAA;CAC5D,CAAC,GACF,OAAO,CAAC,wBAAwB,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../src/Config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAA;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAI5D,eAAO,MAAM,mDAAmD,uFAA4D,CAAA;AAC5H,MAAM,MAAM,mDAAmD,GAAG,OAAO,mDAAmD,CAAA;AAK5H,MAAM,MAAM,6CAA6C,GAAG,cAAc,CAAC;IAIzE,MAAM,EAAE,mDAAmD,CAAA;CAC5D,CAAC,
|
|
1
|
+
{"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../src/Config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAA;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAI5D,eAAO,MAAM,mDAAmD,uFAA4D,CAAA;AAC5H,MAAM,MAAM,mDAAmD,GAAG,OAAO,mDAAmD,CAAA;AAK5H,MAAM,MAAM,6CAA6C,GAAG,cAAc,CAAC;IAIzE,MAAM,EAAE,mDAAmD,CAAA;CAC5D,CAAC,GACF,OAAO,CAAC,wBAAwB,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../src/Config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAA;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAI5D,eAAO,MAAM,mDAAmD,uFAA4D,CAAA;AAC5H,MAAM,MAAM,mDAAmD,GAAG,OAAO,mDAAmD,CAAA;AAK5H,MAAM,MAAM,6CAA6C,GAAG,cAAc,CAAC;IAIzE,MAAM,EAAE,mDAAmD,CAAA;CAC5D,CAAC,
|
|
1
|
+
{"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../src/Config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAA;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAI5D,eAAO,MAAM,mDAAmD,uFAA4D,CAAA;AAC5H,MAAM,MAAM,mDAAmD,GAAG,OAAO,mDAAmD,CAAA;AAK5H,MAAM,MAAM,6CAA6C,GAAG,cAAc,CAAC;IAIzE,MAAM,EAAE,mDAAmD,CAAA;CAC5D,CAAC,GACF,OAAO,CAAC,wBAAwB,CAAC,CAAA"}
|
package/dist/node/Params.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnyConfigSchema } from '@xyo-network/module-model';
|
|
2
2
|
import { RebillyOrganizationSettings, RebillyPublishableApiSettings } from '@xyo-network/rebilly-payment-payload-plugin';
|
|
3
3
|
import { SentinelParams } from '@xyo-network/sentinel-model';
|
|
4
|
-
import { RebillyPaymentCardAuthorizationSentinelConfig } from './Config.
|
|
4
|
+
import { RebillyPaymentCardAuthorizationSentinelConfig } from './Config.ts';
|
|
5
5
|
export type RebillyPaymentCardAuthorizationParams = Partial<RebillyPublishableApiSettings & RebillyOrganizationSettings>;
|
|
6
6
|
export type RebillyPaymentCardAuthorizationSentinelParams<TConfig extends AnyConfigSchema<RebillyPaymentCardAuthorizationSentinelConfig> = AnyConfigSchema<RebillyPaymentCardAuthorizationSentinelConfig>, TParams extends RebillyPaymentCardAuthorizationParams = RebillyPaymentCardAuthorizationParams> = SentinelParams<TConfig, TParams>;
|
|
7
7
|
//# sourceMappingURL=Params.d.ts.map
|
package/dist/node/Params.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnyConfigSchema } from '@xyo-network/module-model';
|
|
2
2
|
import { RebillyOrganizationSettings, RebillyPublishableApiSettings } from '@xyo-network/rebilly-payment-payload-plugin';
|
|
3
3
|
import { SentinelParams } from '@xyo-network/sentinel-model';
|
|
4
|
-
import { RebillyPaymentCardAuthorizationSentinelConfig } from './Config.
|
|
4
|
+
import { RebillyPaymentCardAuthorizationSentinelConfig } from './Config.ts';
|
|
5
5
|
export type RebillyPaymentCardAuthorizationParams = Partial<RebillyPublishableApiSettings & RebillyOrganizationSettings>;
|
|
6
6
|
export type RebillyPaymentCardAuthorizationSentinelParams<TConfig extends AnyConfigSchema<RebillyPaymentCardAuthorizationSentinelConfig> = AnyConfigSchema<RebillyPaymentCardAuthorizationSentinelConfig>, TParams extends RebillyPaymentCardAuthorizationParams = RebillyPaymentCardAuthorizationParams> = SentinelParams<TConfig, TParams>;
|
|
7
7
|
//# sourceMappingURL=Params.d.ts.map
|
package/dist/node/Params.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnyConfigSchema } from '@xyo-network/module-model';
|
|
2
2
|
import { RebillyOrganizationSettings, RebillyPublishableApiSettings } from '@xyo-network/rebilly-payment-payload-plugin';
|
|
3
3
|
import { SentinelParams } from '@xyo-network/sentinel-model';
|
|
4
|
-
import { RebillyPaymentCardAuthorizationSentinelConfig } from './Config.
|
|
4
|
+
import { RebillyPaymentCardAuthorizationSentinelConfig } from './Config.ts';
|
|
5
5
|
export type RebillyPaymentCardAuthorizationParams = Partial<RebillyPublishableApiSettings & RebillyOrganizationSettings>;
|
|
6
6
|
export type RebillyPaymentCardAuthorizationSentinelParams<TConfig extends AnyConfigSchema<RebillyPaymentCardAuthorizationSentinelConfig> = AnyConfigSchema<RebillyPaymentCardAuthorizationSentinelConfig>, TParams extends RebillyPaymentCardAuthorizationParams = RebillyPaymentCardAuthorizationParams> = SentinelParams<TConfig, TParams>;
|
|
7
7
|
//# sourceMappingURL=Params.d.ts.map
|
package/dist/node/Sentinel.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import { AxiosRequestConfig } from '@xylabs/axios';
|
|
|
2
2
|
import { Payload } from '@xyo-network/payload-model';
|
|
3
3
|
import { AbstractSentinel } from '@xyo-network/sentinel-abstract';
|
|
4
4
|
import { SentinelInstance, SentinelModuleEventData } from '@xyo-network/sentinel-model';
|
|
5
|
-
import { RebillyPaymentCardAuthorizationSentinelParams } from './Params.
|
|
5
|
+
import { RebillyPaymentCardAuthorizationSentinelParams } from './Params.ts';
|
|
6
6
|
export declare class RebillyPaymentCardAuthorizationSentinel<TParams extends RebillyPaymentCardAuthorizationSentinelParams = RebillyPaymentCardAuthorizationSentinelParams, TEventData extends SentinelModuleEventData<SentinelInstance<TParams>> = SentinelModuleEventData<SentinelInstance<TParams>>> extends AbstractSentinel<TParams, TEventData> {
|
|
7
7
|
static configSchemas: string[];
|
|
8
8
|
static defaultConfigSchema: string;
|
package/dist/node/Sentinel.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { AxiosRequestConfig } from '@xylabs/axios';
|
|
|
2
2
|
import { Payload } from '@xyo-network/payload-model';
|
|
3
3
|
import { AbstractSentinel } from '@xyo-network/sentinel-abstract';
|
|
4
4
|
import { SentinelInstance, SentinelModuleEventData } from '@xyo-network/sentinel-model';
|
|
5
|
-
import { RebillyPaymentCardAuthorizationSentinelParams } from './Params.
|
|
5
|
+
import { RebillyPaymentCardAuthorizationSentinelParams } from './Params.ts';
|
|
6
6
|
export declare class RebillyPaymentCardAuthorizationSentinel<TParams extends RebillyPaymentCardAuthorizationSentinelParams = RebillyPaymentCardAuthorizationSentinelParams, TEventData extends SentinelModuleEventData<SentinelInstance<TParams>> = SentinelModuleEventData<SentinelInstance<TParams>>> extends AbstractSentinel<TParams, TEventData> {
|
|
7
7
|
static configSchemas: string[];
|
|
8
8
|
static defaultConfigSchema: string;
|
package/dist/node/Sentinel.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { AxiosRequestConfig } from '@xylabs/axios';
|
|
|
2
2
|
import { Payload } from '@xyo-network/payload-model';
|
|
3
3
|
import { AbstractSentinel } from '@xyo-network/sentinel-abstract';
|
|
4
4
|
import { SentinelInstance, SentinelModuleEventData } from '@xyo-network/sentinel-model';
|
|
5
|
-
import { RebillyPaymentCardAuthorizationSentinelParams } from './Params.
|
|
5
|
+
import { RebillyPaymentCardAuthorizationSentinelParams } from './Params.ts';
|
|
6
6
|
export declare class RebillyPaymentCardAuthorizationSentinel<TParams extends RebillyPaymentCardAuthorizationSentinelParams = RebillyPaymentCardAuthorizationSentinelParams, TEventData extends SentinelModuleEventData<SentinelInstance<TParams>> = SentinelModuleEventData<SentinelInstance<TParams>>> extends AbstractSentinel<TParams, TEventData> {
|
|
7
7
|
static configSchemas: string[];
|
|
8
8
|
static defaultConfigSchema: string;
|
package/dist/node/index.cjs
CHANGED
|
@@ -3,6 +3,8 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
8
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -16,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
18
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
19
22
|
|
|
20
23
|
// src/index.ts
|
|
21
24
|
var src_exports = {};
|
|
@@ -41,25 +44,30 @@ var import_rebilly_payment_payload_plugin = require("@xyo-network/rebilly-paymen
|
|
|
41
44
|
var import_sentinel_abstract = require("@xyo-network/sentinel-abstract");
|
|
42
45
|
|
|
43
46
|
// src/util/toTokenRequest.ts
|
|
44
|
-
var toTokenRequest = (paymentCard, billingAddress) => {
|
|
47
|
+
var toTokenRequest = /* @__PURE__ */ __name((paymentCard, billingAddress) => {
|
|
45
48
|
const { cvv, expMonth, expYear, cardNumber } = paymentCard;
|
|
46
49
|
const { schema: _, ...fields } = billingAddress;
|
|
47
50
|
return {
|
|
48
|
-
billingAddress: {
|
|
51
|
+
billingAddress: {
|
|
52
|
+
...fields
|
|
53
|
+
},
|
|
49
54
|
method: "payment-card",
|
|
50
|
-
paymentInstrument: {
|
|
55
|
+
paymentInstrument: {
|
|
56
|
+
cvv,
|
|
57
|
+
expMonth,
|
|
58
|
+
expYear,
|
|
59
|
+
pan: cardNumber
|
|
60
|
+
}
|
|
51
61
|
};
|
|
52
|
-
};
|
|
62
|
+
}, "toTokenRequest");
|
|
53
63
|
|
|
54
64
|
// src/Sentinel.ts
|
|
55
|
-
var removePrefix = (str, prefix) => {
|
|
65
|
+
var removePrefix = /* @__PURE__ */ __name((str, prefix) => {
|
|
56
66
|
const regex = new RegExp(`^${prefix}`);
|
|
57
67
|
return str.replace(regex, "");
|
|
58
|
-
};
|
|
68
|
+
}, "removePrefix");
|
|
59
69
|
var moduleName = "RebillyPaymentCardAuthorizationSentinel";
|
|
60
|
-
var
|
|
61
|
-
static configSchemas = [RebillyPaymentCardAuthorizationSentinelConfigSchema];
|
|
62
|
-
static defaultConfigSchema = RebillyPaymentCardAuthorizationSentinelConfigSchema;
|
|
70
|
+
var _RebillyPaymentCardAuthorizationSentinel = class _RebillyPaymentCardAuthorizationSentinel extends import_sentinel_abstract.AbstractSentinel {
|
|
63
71
|
_apiRoot = void 0;
|
|
64
72
|
_domain = void 0;
|
|
65
73
|
_headers = void 0;
|
|
@@ -67,54 +75,51 @@ var RebillyPaymentCardAuthorizationSentinel = class extends import_sentinel_abst
|
|
|
67
75
|
_publishableApiKey = void 0;
|
|
68
76
|
_tokenEndpoint = void 0;
|
|
69
77
|
/**
|
|
70
|
-
|
|
71
|
-
|
|
78
|
+
* The Rebilly Organization API root endpoint
|
|
79
|
+
*/
|
|
72
80
|
get apiRoot() {
|
|
73
81
|
if (!this._apiRoot) this._apiRoot = `${this.domain}/organizations/${this.organizationId}`;
|
|
74
82
|
return this._apiRoot;
|
|
75
83
|
}
|
|
76
84
|
/**
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
* The Rebilly domain
|
|
86
|
+
*/
|
|
79
87
|
get domain() {
|
|
80
88
|
if (!this._domain) this._domain = (0, import_assert.assertEx)(this.params.domain ?? this.config.domain, () => `${moduleName}: Missing domain in params/config`);
|
|
81
89
|
return this._domain;
|
|
82
90
|
}
|
|
83
91
|
/**
|
|
84
|
-
|
|
85
|
-
|
|
92
|
+
* The headers to be included in the request for each request
|
|
93
|
+
*/
|
|
86
94
|
get headers() {
|
|
87
|
-
if (!this._headers) this._headers = {
|
|
95
|
+
if (!this._headers) this._headers = {
|
|
96
|
+
Authorization: this.publishableApiKey
|
|
97
|
+
};
|
|
88
98
|
return this._headers;
|
|
89
99
|
}
|
|
90
100
|
/**
|
|
91
|
-
|
|
92
|
-
|
|
101
|
+
* True if the environment is sandbox (testing), false otherwise
|
|
102
|
+
*/
|
|
93
103
|
get isSandboxEnvironment() {
|
|
94
104
|
return this.domain.includes("sandbox");
|
|
95
105
|
}
|
|
96
106
|
/**
|
|
97
|
-
|
|
98
|
-
|
|
107
|
+
* The Rebilly organization ID
|
|
108
|
+
*/
|
|
99
109
|
get organizationId() {
|
|
100
|
-
if (!this._organizationId)
|
|
101
|
-
this._organizationId = removePrefix(
|
|
102
|
-
(0, import_assert.assertEx)(this.params.organizationId, () => `${moduleName}: Missing organizationId in params`),
|
|
103
|
-
"org_"
|
|
104
|
-
);
|
|
110
|
+
if (!this._organizationId) this._organizationId = removePrefix((0, import_assert.assertEx)(this.params.organizationId, () => `${moduleName}: Missing organizationId in params`), "org_");
|
|
105
111
|
return this._organizationId;
|
|
106
112
|
}
|
|
107
113
|
/**
|
|
108
|
-
|
|
109
|
-
|
|
114
|
+
* The Rebilly Publishable API key
|
|
115
|
+
*/
|
|
110
116
|
get publishableApiKey() {
|
|
111
|
-
if (!this._publishableApiKey)
|
|
112
|
-
this._publishableApiKey = (0, import_assert.assertEx)(this.params.publishableApiKey, () => `${moduleName}: Missing publishableApiKey in params`);
|
|
117
|
+
if (!this._publishableApiKey) this._publishableApiKey = (0, import_assert.assertEx)(this.params.publishableApiKey, () => `${moduleName}: Missing publishableApiKey in params`);
|
|
113
118
|
return this._publishableApiKey;
|
|
114
119
|
}
|
|
115
120
|
/**
|
|
116
|
-
|
|
117
|
-
|
|
121
|
+
* The Rebilly Organization token creation endpoint
|
|
122
|
+
*/
|
|
118
123
|
get tokenEndpoint() {
|
|
119
124
|
if (!this._tokenEndpoint) this._tokenEndpoint = `${this.apiRoot}/tokens`;
|
|
120
125
|
return this._tokenEndpoint;
|
|
@@ -128,20 +133,35 @@ var RebillyPaymentCardAuthorizationSentinel = class extends import_sentinel_abst
|
|
|
128
133
|
if (!paymentCard) return results;
|
|
129
134
|
const billingAddress = payloads == null ? void 0 : payloads.find(import_payment_payload_plugins.isBillingAddress);
|
|
130
135
|
if (!billingAddress) return results;
|
|
131
|
-
const axios = new import_axios.AxiosJson({
|
|
136
|
+
const axios = new import_axios.AxiosJson({
|
|
137
|
+
headers: this.headers
|
|
138
|
+
});
|
|
132
139
|
try {
|
|
133
140
|
const data = toTokenRequest(paymentCard, billingAddress);
|
|
134
141
|
const response = await axios.post(this.tokenEndpoint, data);
|
|
135
142
|
(0, import_assert.assertEx)(response.status === import_axios.HttpStatusCode.Created, () => `Failed to tokenize payment card: ${response.status}`);
|
|
136
143
|
const { id } = response.data;
|
|
137
|
-
const sources = await import_payload_builder.PayloadBuilder.dataHashes([
|
|
138
|
-
|
|
144
|
+
const sources = await import_payload_builder.PayloadBuilder.dataHashes([
|
|
145
|
+
paymentCard,
|
|
146
|
+
billingAddress
|
|
147
|
+
]);
|
|
148
|
+
results.push({
|
|
149
|
+
id,
|
|
150
|
+
schema: import_rebilly_payment_payload_plugin.RebillyPaymentAuthorizationTokenSchema,
|
|
151
|
+
sources
|
|
152
|
+
});
|
|
139
153
|
} catch (error) {
|
|
140
154
|
(_b = (_a = this.logger) == null ? void 0 : _a.error) == null ? void 0 : _b.call(_a, `${moduleName}: Error creating payment token: ${error}`);
|
|
141
155
|
}
|
|
142
156
|
return results;
|
|
143
157
|
}
|
|
144
158
|
};
|
|
159
|
+
__name(_RebillyPaymentCardAuthorizationSentinel, "RebillyPaymentCardAuthorizationSentinel");
|
|
160
|
+
__publicField(_RebillyPaymentCardAuthorizationSentinel, "configSchemas", [
|
|
161
|
+
RebillyPaymentCardAuthorizationSentinelConfigSchema
|
|
162
|
+
]);
|
|
163
|
+
__publicField(_RebillyPaymentCardAuthorizationSentinel, "defaultConfigSchema", RebillyPaymentCardAuthorizationSentinelConfigSchema);
|
|
164
|
+
var RebillyPaymentCardAuthorizationSentinel = _RebillyPaymentCardAuthorizationSentinel;
|
|
145
165
|
// Annotate the CommonJS export names for ESM import in node:
|
|
146
166
|
0 && (module.exports = {
|
|
147
167
|
RebillyPaymentCardAuthorizationSentinel,
|
package/dist/node/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/Schema.ts","../../src/Config.ts","../../src/Sentinel.ts","../../src/util/toTokenRequest.ts"],"sourcesContent":["export * from './Config.js'\nexport * from './Params.js'\nexport * from './Schema.js'\nexport * from './Sentinel.js'\n","export const RebillyPaymentCardAuthorizationSentinelSchema = 'network.xyo.sentinel.payments.payment.instrument.card.authorization.rebilly'\nexport type RebillyPaymentCardAuthorizationSentinelSchema = typeof RebillyPaymentCardAuthorizationSentinelSchema\n","import { RebillyApiDomainSettings } from '@xyo-network/rebilly-payment-payload-plugin'\nimport { SentinelConfig } from '@xyo-network/sentinel-model'\n\nimport { RebillyPaymentCardAuthorizationSentinelSchema } from './Schema.js'\n\nexport const RebillyPaymentCardAuthorizationSentinelConfigSchema = `${RebillyPaymentCardAuthorizationSentinelSchema}.config`\nexport type RebillyPaymentCardAuthorizationSentinelConfigSchema = typeof RebillyPaymentCardAuthorizationSentinelConfigSchema\n\n/*\n * The Rebilly Payment Card Authorization Sentinel Config\n */\nexport type RebillyPaymentCardAuthorizationSentinelConfig = SentinelConfig<{\n /**\n * The config schema\n */\n schema: RebillyPaymentCardAuthorizationSentinelConfigSchema\n}> &\n Partial<RebillyApiDomainSettings>\n","import { assertEx } from '@xylabs/assert'\nimport { AxiosJson, AxiosRequestConfig, HttpStatusCode } from '@xylabs/axios'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload, WithSources } from '@xyo-network/payload-model'\nimport { isBillingAddress, isPaymentCard } from '@xyo-network/payment-payload-plugins'\nimport { RebillyPaymentAuthorizationToken, RebillyPaymentAuthorizationTokenSchema } from '@xyo-network/rebilly-payment-payload-plugin'\nimport { AbstractSentinel } from '@xyo-network/sentinel-abstract'\nimport { SentinelInstance, SentinelModuleEventData } from '@xyo-network/sentinel-model'\n\nimport { CreateTokenResponse } from './Api/index.js'\nimport { RebillyPaymentCardAuthorizationSentinelConfigSchema } from './Config.js'\nimport { RebillyPaymentCardAuthorizationSentinelParams } from './Params.js'\nimport { toTokenRequest } from './util/index.js'\n\nconst removePrefix = (str: string, prefix: string) => {\n const regex = new RegExp(`^${prefix}`)\n return str.replace(regex, '')\n}\n\nconst moduleName = 'RebillyPaymentCardAuthorizationSentinel'\nexport class RebillyPaymentCardAuthorizationSentinel<\n TParams extends RebillyPaymentCardAuthorizationSentinelParams = RebillyPaymentCardAuthorizationSentinelParams,\n TEventData extends SentinelModuleEventData<SentinelInstance<TParams>> = SentinelModuleEventData<SentinelInstance<TParams>>,\n> extends AbstractSentinel<TParams, TEventData> {\n static override configSchemas = [RebillyPaymentCardAuthorizationSentinelConfigSchema]\n static override defaultConfigSchema = RebillyPaymentCardAuthorizationSentinelConfigSchema\n\n protected _apiRoot: string | undefined = undefined\n protected _domain: string | undefined = undefined\n protected _headers: AxiosRequestConfig['headers'] | undefined = undefined\n protected _organizationId: string | undefined = undefined\n protected _publishableApiKey: string | undefined = undefined\n protected _tokenEndpoint: string | undefined = undefined\n\n /**\n * The Rebilly Organization API root endpoint\n */\n protected get apiRoot() {\n if (!this._apiRoot) this._apiRoot = `${this.domain}/organizations/${this.organizationId}`\n return this._apiRoot\n }\n\n /**\n * The Rebilly domain\n */\n protected get domain() {\n if (!this._domain) this._domain = assertEx(this.params.domain ?? this.config.domain, () => `${moduleName}: Missing domain in params/config`)\n return this._domain\n }\n\n /**\n * The headers to be included in the request for each request\n */\n protected get headers(): AxiosRequestConfig['headers'] {\n if (!this._headers) this._headers = { Authorization: this.publishableApiKey }\n return this._headers\n }\n\n /**\n * True if the environment is sandbox (testing), false otherwise\n */\n protected get isSandboxEnvironment(): boolean {\n return this.domain.includes('sandbox')\n }\n\n /**\n * The Rebilly organization ID\n */\n protected get organizationId() {\n if (!this._organizationId)\n this._organizationId = removePrefix(\n assertEx(this.params.organizationId, () => `${moduleName}: Missing organizationId in params`),\n 'org_',\n )\n return this._organizationId\n }\n\n /**\n * The Rebilly Publishable API key\n */\n protected get publishableApiKey(): string {\n if (!this._publishableApiKey)\n this._publishableApiKey = assertEx(this.params.publishableApiKey, () => `${moduleName}: Missing publishableApiKey in params`)\n return this._publishableApiKey\n }\n\n /**\n * The Rebilly Organization token creation endpoint\n */\n protected get tokenEndpoint() {\n if (!this._tokenEndpoint) this._tokenEndpoint = `${this.apiRoot}/tokens`\n return this._tokenEndpoint\n }\n\n override async reportHandler(payloads?: Payload[]): Promise<Payload[]> {\n await this.started('throw')\n const results: WithSources<RebillyPaymentAuthorizationToken>[] = []\n // Verify necessary inputs and if nothing meets our criteria, bail early\n if (!payloads || payloads.length === 0) return results\n const paymentCard = payloads?.find(isPaymentCard)\n if (!paymentCard) return results\n const billingAddress = payloads?.find(isBillingAddress)\n if (!billingAddress) return results\n const axios = new AxiosJson({ headers: this.headers })\n try {\n const data = toTokenRequest(paymentCard, billingAddress)\n const response = await axios.post<CreateTokenResponse>(this.tokenEndpoint, data)\n assertEx(response.status === HttpStatusCode.Created, () => `Failed to tokenize payment card: ${response.status}`)\n const { id } = response.data\n const sources = await PayloadBuilder.dataHashes([paymentCard, billingAddress])\n results.push({ id, schema: RebillyPaymentAuthorizationTokenSchema, sources })\n } catch (error) {\n this.logger?.error?.(`${moduleName}: Error creating payment token: ${error}`)\n }\n return results\n }\n}\n","import { BillingAddress, PaymentCard } from '@xyo-network/payment-payload-plugins'\n\nimport { CreatePaymentTokenRequest } from '../Api/index.js'\n\n/**\n * Converts a payment card and billing address to a token request\n * @param paymentCard The payment card\n * @param billingAddress The billing address\n * @returns The token request\n */\nexport const toTokenRequest = (paymentCard: PaymentCard, billingAddress: BillingAddress): CreatePaymentTokenRequest => {\n const { cvv, expMonth, expYear, cardNumber } = paymentCard\n // NOTE: We are destructuring all but the schema and passing it along to the billingAddress. This\n // is to allow for missing fields to be omitted rather than set to undefined and for any new fields\n // that might be added later to be automatically picked up on. It is fine to pass this along since\n // the user is supplying this data about themselves.\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { schema: _, ...fields } = billingAddress\n return {\n billingAddress: { ...fields },\n method: 'payment-card',\n paymentInstrument: { cvv, expMonth, expYear, pan: cardNumber },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,gDAAgD;;;ACKtD,IAAM,sDAAsD,GAAG,6CAA6C;;;ACLnH,oBAAyB;AACzB,mBAA8D;AAC9D,6BAA+B;AAE/B,qCAAgD;AAChD,4CAAyF;AACzF,+BAAiC;;;ACI1B,IAAM,iBAAiB,CAAC,aAA0B,mBAA8D;AACrH,QAAM,EAAE,KAAK,UAAU,SAAS,WAAW,IAAI;AAM/C,QAAM,EAAE,QAAQ,GAAG,GAAG,OAAO,IAAI;AACjC,SAAO;AAAA,IACL,gBAAgB,EAAE,GAAG,OAAO;AAAA,IAC5B,QAAQ;AAAA,IACR,mBAAmB,EAAE,KAAK,UAAU,SAAS,KAAK,WAAW;AAAA,EAC/D;AACF;;;ADTA,IAAM,eAAe,CAAC,KA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OAAO,mBAAmB,MAAM,GAAG,UAAU,uCAAuC;AAC9H,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,IAAc,gBAAgB;AAC5B,QAAI,CAAC,KAAK,eAAgB,MAAK,iBAAiB,GAAG,KAAK,OAAO;AAC/D,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAe,cAAc,UAA0C;AA9FzE;AA+FI,UAAM,KAAK,QAAQ,OAAO;AAC1B,UAAM,UAA2D,CAAC;AAElE,QAAI,CAAC,YAAY,SAAS,WAAW,EAAG,QAAO;AAC/C,UAAM,cAAc,qCAAU,KAAK;AACnC,QAAI,CAAC,YAAa,QAAO;AACzB,UAAM,iBAAiB,qCAAU,KAAK;AACtC,QAAI,CAAC,eAAgB,QAAO;AAC5B,UAAM,QAAQ,IAAI,uBAAU,EAAE,SAAS,KAAK,QAAQ,CAAC;AACrD,QAAI;AACF,YAAM,OAAO,eAAe,aAAa,cAAc;AACvD,YAAM,WAAW,MAAM,MAAM,KAA0B,KAAK,eAAe,IAAI;AAC/E,kCAAS,SAAS,WAAW,4BAAe,SAAS,MAAM,oCAAoC,SAAS,MAAM,EAAE;AAChH,YAAM,EAAE,GAAG,IAAI,SAAS;AACxB,YAAM,UAAU,MAAM,sCAAe,WAAW,CAAC,aAAa,cAAc,CAAC;AAC7E,cAAQ,KAAK,EAAE,IAAI,QAAQ,8EAAwC,QAAQ,CAAC;AAAA,IAC9E,SAAS,OAAO;AACd,uBAAK,WAAL,mBAAa,UAAb,4BAAqB,GAAG,UAAU,mCAAmC,KAAK;AAAA,IAC5E;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/Schema.ts","../../src/Config.ts","../../src/Sentinel.ts","../../src/util/toTokenRequest.ts"],"sourcesContent":["export * from './Config.ts'\nexport * from './Params.ts'\nexport * from './Schema.ts'\nexport * from './Sentinel.ts'\n","export const RebillyPaymentCardAuthorizationSentinelSchema = 'network.xyo.sentinel.payments.payment.instrument.card.authorization.rebilly'\nexport type RebillyPaymentCardAuthorizationSentinelSchema = typeof RebillyPaymentCardAuthorizationSentinelSchema\n","import { RebillyApiDomainSettings } from '@xyo-network/rebilly-payment-payload-plugin'\nimport { SentinelConfig } from '@xyo-network/sentinel-model'\n\nimport { RebillyPaymentCardAuthorizationSentinelSchema } from './Schema.ts'\n\nexport const RebillyPaymentCardAuthorizationSentinelConfigSchema = `${RebillyPaymentCardAuthorizationSentinelSchema}.config`\nexport type RebillyPaymentCardAuthorizationSentinelConfigSchema = typeof RebillyPaymentCardAuthorizationSentinelConfigSchema\n\n/*\n * The Rebilly Payment Card Authorization Sentinel Config\n */\nexport type RebillyPaymentCardAuthorizationSentinelConfig = SentinelConfig<{\n /**\n * The config schema\n */\n schema: RebillyPaymentCardAuthorizationSentinelConfigSchema\n}> &\nPartial<RebillyApiDomainSettings>\n","import { assertEx } from '@xylabs/assert'\nimport { AxiosJson, AxiosRequestConfig, HttpStatusCode } from '@xylabs/axios'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload, WithSources } from '@xyo-network/payload-model'\nimport { isBillingAddress, isPaymentCard } from '@xyo-network/payment-payload-plugins'\nimport { RebillyPaymentAuthorizationToken, RebillyPaymentAuthorizationTokenSchema } from '@xyo-network/rebilly-payment-payload-plugin'\nimport { AbstractSentinel } from '@xyo-network/sentinel-abstract'\nimport { SentinelInstance, SentinelModuleEventData } from '@xyo-network/sentinel-model'\n\nimport { CreateTokenResponse } from './Api/index.ts'\nimport { RebillyPaymentCardAuthorizationSentinelConfigSchema } from './Config.ts'\nimport { RebillyPaymentCardAuthorizationSentinelParams } from './Params.ts'\nimport { toTokenRequest } from './util/index.ts'\n\nconst removePrefix = (str: string, prefix: string) => {\n const regex = new RegExp(`^${prefix}`)\n return str.replace(regex, '')\n}\n\nconst moduleName = 'RebillyPaymentCardAuthorizationSentinel'\nexport class RebillyPaymentCardAuthorizationSentinel<\n TParams extends RebillyPaymentCardAuthorizationSentinelParams = RebillyPaymentCardAuthorizationSentinelParams,\n TEventData extends SentinelModuleEventData<SentinelInstance<TParams>> = SentinelModuleEventData<SentinelInstance<TParams>>,\n> extends AbstractSentinel<TParams, TEventData> {\n static override configSchemas = [RebillyPaymentCardAuthorizationSentinelConfigSchema]\n static override defaultConfigSchema = RebillyPaymentCardAuthorizationSentinelConfigSchema\n\n protected _apiRoot: string | undefined = undefined\n protected _domain: string | undefined = undefined\n protected _headers: AxiosRequestConfig['headers'] | undefined = undefined\n protected _organizationId: string | undefined = undefined\n protected _publishableApiKey: string | undefined = undefined\n protected _tokenEndpoint: string | undefined = undefined\n\n /**\n * The Rebilly Organization API root endpoint\n */\n protected get apiRoot() {\n if (!this._apiRoot) this._apiRoot = `${this.domain}/organizations/${this.organizationId}`\n return this._apiRoot\n }\n\n /**\n * The Rebilly domain\n */\n protected get domain() {\n if (!this._domain) this._domain = assertEx(this.params.domain ?? this.config.domain, () => `${moduleName}: Missing domain in params/config`)\n return this._domain\n }\n\n /**\n * The headers to be included in the request for each request\n */\n protected get headers(): AxiosRequestConfig['headers'] {\n if (!this._headers) this._headers = { Authorization: this.publishableApiKey }\n return this._headers\n }\n\n /**\n * True if the environment is sandbox (testing), false otherwise\n */\n protected get isSandboxEnvironment(): boolean {\n return this.domain.includes('sandbox')\n }\n\n /**\n * The Rebilly organization ID\n */\n protected get organizationId() {\n if (!this._organizationId)\n this._organizationId = removePrefix(\n assertEx(this.params.organizationId, () => `${moduleName}: Missing organizationId in params`),\n 'org_',\n )\n return this._organizationId\n }\n\n /**\n * The Rebilly Publishable API key\n */\n protected get publishableApiKey(): string {\n if (!this._publishableApiKey)\n this._publishableApiKey = assertEx(this.params.publishableApiKey, () => `${moduleName}: Missing publishableApiKey in params`)\n return this._publishableApiKey\n }\n\n /**\n * The Rebilly Organization token creation endpoint\n */\n protected get tokenEndpoint() {\n if (!this._tokenEndpoint) this._tokenEndpoint = `${this.apiRoot}/tokens`\n return this._tokenEndpoint\n }\n\n override async reportHandler(payloads?: Payload[]): Promise<Payload[]> {\n await this.started('throw')\n const results: WithSources<RebillyPaymentAuthorizationToken>[] = []\n // Verify necessary inputs and if nothing meets our criteria, bail early\n if (!payloads || payloads.length === 0) return results\n const paymentCard = payloads?.find(isPaymentCard)\n if (!paymentCard) return results\n const billingAddress = payloads?.find(isBillingAddress)\n if (!billingAddress) return results\n const axios = new AxiosJson({ headers: this.headers })\n try {\n const data = toTokenRequest(paymentCard, billingAddress)\n const response = await axios.post<CreateTokenResponse>(this.tokenEndpoint, data)\n assertEx(response.status === HttpStatusCode.Created, () => `Failed to tokenize payment card: ${response.status}`)\n const { id } = response.data\n const sources = await PayloadBuilder.dataHashes([paymentCard, billingAddress])\n results.push({ id, schema: RebillyPaymentAuthorizationTokenSchema, sources })\n } catch (error) {\n this.logger?.error?.(`${moduleName}: Error creating payment token: ${error}`)\n }\n return results\n }\n}\n","import { BillingAddress, PaymentCard } from '@xyo-network/payment-payload-plugins'\n\nimport { CreatePaymentTokenRequest } from '../Api/index.ts'\n\n/**\n * Converts a payment card and billing address to a token request\n * @param paymentCard The payment card\n * @param billingAddress The billing address\n * @returns The token request\n */\nexport const toTokenRequest = (paymentCard: PaymentCard, billingAddress: BillingAddress): CreatePaymentTokenRequest => {\n const { cvv, expMonth, expYear, cardNumber } = paymentCard\n // NOTE: We are destructuring all but the schema and passing it along to the billingAddress. This\n // is to allow for missing fields to be omitted rather than set to undefined and for any new fields\n // that might be added later to be automatically picked up on. It is fine to pass this along since\n // the user is supplying this data about themselves.\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { schema: _, ...fields } = billingAddress\n return {\n billingAddress: { ...fields },\n method: 'payment-card',\n paymentInstrument: { cvv, expMonth, expYear, pan: cardNumber },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;ACAO,IAAMA,gDAAgD;;;ACKtD,IAAMC,sDAAsD,GAAGC,6CAAAA;;;ACLtE,oBAAyB;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KAAAA;IACvE;AACA,WAAOvB;EACT;AACF;AA7FUvB;AACR,cAJWD,0CAIKiD,iBAAgB;EAACC;;AACjC,cALWlD,0CAKKmD,uBAAsBD;AALjC,IAAMlD,0CAAN;","names":["RebillyPaymentCardAuthorizationSentinelSchema","RebillyPaymentCardAuthorizationSentinelConfigSchema","RebillyPaymentCardAuthorizationSentinelSchema","toTokenRequest","paymentCard","billingAddress","cvv","expMonth","expYear","cardNumber","schema","_","fields","method","paymentInstrument","pan","removePrefix","str","prefix","regex","RegExp","replace","moduleName","RebillyPaymentCardAuthorizationSentinel","AbstractSentinel","_apiRoot","undefined","_domain","_headers","_organizationId","_publishableApiKey","_tokenEndpoint","apiRoot","domain","organizationId","assertEx","params","config","headers","Authorization","publishableApiKey","isSandboxEnvironment","includes","tokenEndpoint","reportHandler","payloads","started","results","length","paymentCard","find","isPaymentCard","billingAddress","isBillingAddress","axios","AxiosJson","data","toTokenRequest","response","post","status","HttpStatusCode","Created","id","sources","PayloadBuilder","dataHashes","push","schema","RebillyPaymentAuthorizationTokenSchema","error","logger","configSchemas","RebillyPaymentCardAuthorizationSentinelConfigSchema","defaultConfigSchema"]}
|
package/dist/node/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './Config.
|
|
2
|
-
export * from './Params.
|
|
3
|
-
export * from './Schema.
|
|
4
|
-
export * from './Sentinel.
|
|
1
|
+
export * from './Config.ts';
|
|
2
|
+
export * from './Params.ts';
|
|
3
|
+
export * from './Schema.ts';
|
|
4
|
+
export * from './Sentinel.ts';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/node/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './Config.
|
|
2
|
-
export * from './Params.
|
|
3
|
-
export * from './Schema.
|
|
4
|
-
export * from './Sentinel.
|
|
1
|
+
export * from './Config.ts';
|
|
2
|
+
export * from './Params.ts';
|
|
3
|
+
export * from './Schema.ts';
|
|
4
|
+
export * from './Sentinel.ts';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './Config.
|
|
2
|
-
export * from './Params.
|
|
3
|
-
export * from './Schema.
|
|
4
|
-
export * from './Sentinel.
|
|
1
|
+
export * from './Config.ts';
|
|
2
|
+
export * from './Params.ts';
|
|
3
|
+
export * from './Schema.ts';
|
|
4
|
+
export * from './Sentinel.ts';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
|
|
1
6
|
// src/Schema.ts
|
|
2
7
|
var RebillyPaymentCardAuthorizationSentinelSchema = "network.xyo.sentinel.payments.payment.instrument.card.authorization.rebilly";
|
|
3
8
|
|
|
@@ -13,25 +18,30 @@ import { RebillyPaymentAuthorizationTokenSchema } from "@xyo-network/rebilly-pay
|
|
|
13
18
|
import { AbstractSentinel } from "@xyo-network/sentinel-abstract";
|
|
14
19
|
|
|
15
20
|
// src/util/toTokenRequest.ts
|
|
16
|
-
var toTokenRequest = (paymentCard, billingAddress) => {
|
|
21
|
+
var toTokenRequest = /* @__PURE__ */ __name((paymentCard, billingAddress) => {
|
|
17
22
|
const { cvv, expMonth, expYear, cardNumber } = paymentCard;
|
|
18
23
|
const { schema: _, ...fields } = billingAddress;
|
|
19
24
|
return {
|
|
20
|
-
billingAddress: {
|
|
25
|
+
billingAddress: {
|
|
26
|
+
...fields
|
|
27
|
+
},
|
|
21
28
|
method: "payment-card",
|
|
22
|
-
paymentInstrument: {
|
|
29
|
+
paymentInstrument: {
|
|
30
|
+
cvv,
|
|
31
|
+
expMonth,
|
|
32
|
+
expYear,
|
|
33
|
+
pan: cardNumber
|
|
34
|
+
}
|
|
23
35
|
};
|
|
24
|
-
};
|
|
36
|
+
}, "toTokenRequest");
|
|
25
37
|
|
|
26
38
|
// src/Sentinel.ts
|
|
27
|
-
var removePrefix = (str, prefix) => {
|
|
39
|
+
var removePrefix = /* @__PURE__ */ __name((str, prefix) => {
|
|
28
40
|
const regex = new RegExp(`^${prefix}`);
|
|
29
41
|
return str.replace(regex, "");
|
|
30
|
-
};
|
|
42
|
+
}, "removePrefix");
|
|
31
43
|
var moduleName = "RebillyPaymentCardAuthorizationSentinel";
|
|
32
|
-
var
|
|
33
|
-
static configSchemas = [RebillyPaymentCardAuthorizationSentinelConfigSchema];
|
|
34
|
-
static defaultConfigSchema = RebillyPaymentCardAuthorizationSentinelConfigSchema;
|
|
44
|
+
var _RebillyPaymentCardAuthorizationSentinel = class _RebillyPaymentCardAuthorizationSentinel extends AbstractSentinel {
|
|
35
45
|
_apiRoot = void 0;
|
|
36
46
|
_domain = void 0;
|
|
37
47
|
_headers = void 0;
|
|
@@ -39,54 +49,51 @@ var RebillyPaymentCardAuthorizationSentinel = class extends AbstractSentinel {
|
|
|
39
49
|
_publishableApiKey = void 0;
|
|
40
50
|
_tokenEndpoint = void 0;
|
|
41
51
|
/**
|
|
42
|
-
|
|
43
|
-
|
|
52
|
+
* The Rebilly Organization API root endpoint
|
|
53
|
+
*/
|
|
44
54
|
get apiRoot() {
|
|
45
55
|
if (!this._apiRoot) this._apiRoot = `${this.domain}/organizations/${this.organizationId}`;
|
|
46
56
|
return this._apiRoot;
|
|
47
57
|
}
|
|
48
58
|
/**
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
* The Rebilly domain
|
|
60
|
+
*/
|
|
51
61
|
get domain() {
|
|
52
62
|
if (!this._domain) this._domain = assertEx(this.params.domain ?? this.config.domain, () => `${moduleName}: Missing domain in params/config`);
|
|
53
63
|
return this._domain;
|
|
54
64
|
}
|
|
55
65
|
/**
|
|
56
|
-
|
|
57
|
-
|
|
66
|
+
* The headers to be included in the request for each request
|
|
67
|
+
*/
|
|
58
68
|
get headers() {
|
|
59
|
-
if (!this._headers) this._headers = {
|
|
69
|
+
if (!this._headers) this._headers = {
|
|
70
|
+
Authorization: this.publishableApiKey
|
|
71
|
+
};
|
|
60
72
|
return this._headers;
|
|
61
73
|
}
|
|
62
74
|
/**
|
|
63
|
-
|
|
64
|
-
|
|
75
|
+
* True if the environment is sandbox (testing), false otherwise
|
|
76
|
+
*/
|
|
65
77
|
get isSandboxEnvironment() {
|
|
66
78
|
return this.domain.includes("sandbox");
|
|
67
79
|
}
|
|
68
80
|
/**
|
|
69
|
-
|
|
70
|
-
|
|
81
|
+
* The Rebilly organization ID
|
|
82
|
+
*/
|
|
71
83
|
get organizationId() {
|
|
72
|
-
if (!this._organizationId)
|
|
73
|
-
this._organizationId = removePrefix(
|
|
74
|
-
assertEx(this.params.organizationId, () => `${moduleName}: Missing organizationId in params`),
|
|
75
|
-
"org_"
|
|
76
|
-
);
|
|
84
|
+
if (!this._organizationId) this._organizationId = removePrefix(assertEx(this.params.organizationId, () => `${moduleName}: Missing organizationId in params`), "org_");
|
|
77
85
|
return this._organizationId;
|
|
78
86
|
}
|
|
79
87
|
/**
|
|
80
|
-
|
|
81
|
-
|
|
88
|
+
* The Rebilly Publishable API key
|
|
89
|
+
*/
|
|
82
90
|
get publishableApiKey() {
|
|
83
|
-
if (!this._publishableApiKey)
|
|
84
|
-
this._publishableApiKey = assertEx(this.params.publishableApiKey, () => `${moduleName}: Missing publishableApiKey in params`);
|
|
91
|
+
if (!this._publishableApiKey) this._publishableApiKey = assertEx(this.params.publishableApiKey, () => `${moduleName}: Missing publishableApiKey in params`);
|
|
85
92
|
return this._publishableApiKey;
|
|
86
93
|
}
|
|
87
94
|
/**
|
|
88
|
-
|
|
89
|
-
|
|
95
|
+
* The Rebilly Organization token creation endpoint
|
|
96
|
+
*/
|
|
90
97
|
get tokenEndpoint() {
|
|
91
98
|
if (!this._tokenEndpoint) this._tokenEndpoint = `${this.apiRoot}/tokens`;
|
|
92
99
|
return this._tokenEndpoint;
|
|
@@ -100,23 +107,38 @@ var RebillyPaymentCardAuthorizationSentinel = class extends AbstractSentinel {
|
|
|
100
107
|
if (!paymentCard) return results;
|
|
101
108
|
const billingAddress = payloads == null ? void 0 : payloads.find(isBillingAddress);
|
|
102
109
|
if (!billingAddress) return results;
|
|
103
|
-
const axios = new AxiosJson({
|
|
110
|
+
const axios = new AxiosJson({
|
|
111
|
+
headers: this.headers
|
|
112
|
+
});
|
|
104
113
|
try {
|
|
105
114
|
const data = toTokenRequest(paymentCard, billingAddress);
|
|
106
115
|
const response = await axios.post(this.tokenEndpoint, data);
|
|
107
116
|
assertEx(response.status === HttpStatusCode.Created, () => `Failed to tokenize payment card: ${response.status}`);
|
|
108
117
|
const { id } = response.data;
|
|
109
|
-
const sources = await PayloadBuilder.dataHashes([
|
|
110
|
-
|
|
118
|
+
const sources = await PayloadBuilder.dataHashes([
|
|
119
|
+
paymentCard,
|
|
120
|
+
billingAddress
|
|
121
|
+
]);
|
|
122
|
+
results.push({
|
|
123
|
+
id,
|
|
124
|
+
schema: RebillyPaymentAuthorizationTokenSchema,
|
|
125
|
+
sources
|
|
126
|
+
});
|
|
111
127
|
} catch (error) {
|
|
112
128
|
(_b = (_a = this.logger) == null ? void 0 : _a.error) == null ? void 0 : _b.call(_a, `${moduleName}: Error creating payment token: ${error}`);
|
|
113
129
|
}
|
|
114
130
|
return results;
|
|
115
131
|
}
|
|
116
132
|
};
|
|
133
|
+
__name(_RebillyPaymentCardAuthorizationSentinel, "RebillyPaymentCardAuthorizationSentinel");
|
|
134
|
+
__publicField(_RebillyPaymentCardAuthorizationSentinel, "configSchemas", [
|
|
135
|
+
RebillyPaymentCardAuthorizationSentinelConfigSchema
|
|
136
|
+
]);
|
|
137
|
+
__publicField(_RebillyPaymentCardAuthorizationSentinel, "defaultConfigSchema", RebillyPaymentCardAuthorizationSentinelConfigSchema);
|
|
138
|
+
var RebillyPaymentCardAuthorizationSentinel = _RebillyPaymentCardAuthorizationSentinel;
|
|
117
139
|
export {
|
|
118
140
|
RebillyPaymentCardAuthorizationSentinel,
|
|
119
141
|
RebillyPaymentCardAuthorizationSentinelConfigSchema,
|
|
120
142
|
RebillyPaymentCardAuthorizationSentinelSchema
|
|
121
143
|
};
|
|
122
|
-
//# sourceMappingURL=index.
|
|
144
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/Schema.ts","../../src/Config.ts","../../src/Sentinel.ts","../../src/util/toTokenRequest.ts"],"sourcesContent":["export const RebillyPaymentCardAuthorizationSentinelSchema = 'network.xyo.sentinel.payments.payment.instrument.card.authorization.rebilly'\nexport type RebillyPaymentCardAuthorizationSentinelSchema = typeof RebillyPaymentCardAuthorizationSentinelSchema\n","import { RebillyApiDomainSettings } from '@xyo-network/rebilly-payment-payload-plugin'\nimport { SentinelConfig } from '@xyo-network/sentinel-model'\n\nimport { RebillyPaymentCardAuthorizationSentinelSchema } from './Schema.ts'\n\nexport const RebillyPaymentCardAuthorizationSentinelConfigSchema = `${RebillyPaymentCardAuthorizationSentinelSchema}.config`\nexport type RebillyPaymentCardAuthorizationSentinelConfigSchema = typeof RebillyPaymentCardAuthorizationSentinelConfigSchema\n\n/*\n * The Rebilly Payment Card Authorization Sentinel Config\n */\nexport type RebillyPaymentCardAuthorizationSentinelConfig = SentinelConfig<{\n /**\n * The config schema\n */\n schema: RebillyPaymentCardAuthorizationSentinelConfigSchema\n}> &\nPartial<RebillyApiDomainSettings>\n","import { assertEx } from '@xylabs/assert'\nimport { AxiosJson, AxiosRequestConfig, HttpStatusCode } from '@xylabs/axios'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload, WithSources } from '@xyo-network/payload-model'\nimport { isBillingAddress, isPaymentCard } from '@xyo-network/payment-payload-plugins'\nimport { RebillyPaymentAuthorizationToken, RebillyPaymentAuthorizationTokenSchema } from '@xyo-network/rebilly-payment-payload-plugin'\nimport { AbstractSentinel } from '@xyo-network/sentinel-abstract'\nimport { SentinelInstance, SentinelModuleEventData } from '@xyo-network/sentinel-model'\n\nimport { CreateTokenResponse } from './Api/index.ts'\nimport { RebillyPaymentCardAuthorizationSentinelConfigSchema } from './Config.ts'\nimport { RebillyPaymentCardAuthorizationSentinelParams } from './Params.ts'\nimport { toTokenRequest } from './util/index.ts'\n\nconst removePrefix = (str: string, prefix: string) => {\n const regex = new RegExp(`^${prefix}`)\n return str.replace(regex, '')\n}\n\nconst moduleName = 'RebillyPaymentCardAuthorizationSentinel'\nexport class RebillyPaymentCardAuthorizationSentinel<\n TParams extends RebillyPaymentCardAuthorizationSentinelParams = RebillyPaymentCardAuthorizationSentinelParams,\n TEventData extends SentinelModuleEventData<SentinelInstance<TParams>> = SentinelModuleEventData<SentinelInstance<TParams>>,\n> extends AbstractSentinel<TParams, TEventData> {\n static override configSchemas = [RebillyPaymentCardAuthorizationSentinelConfigSchema]\n static override defaultConfigSchema = RebillyPaymentCardAuthorizationSentinelConfigSchema\n\n protected _apiRoot: string | undefined = undefined\n protected _domain: string | undefined = undefined\n protected _headers: AxiosRequestConfig['headers'] | undefined = undefined\n protected _organizationId: string | undefined = undefined\n protected _publishableApiKey: string | undefined = undefined\n protected _tokenEndpoint: string | undefined = undefined\n\n /**\n * The Rebilly Organization API root endpoint\n */\n protected get apiRoot() {\n if (!this._apiRoot) this._apiRoot = `${this.domain}/organizations/${this.organizationId}`\n return this._apiRoot\n }\n\n /**\n * The Rebilly domain\n */\n protected get domain() {\n if (!this._domain) this._domain = assertEx(this.params.domain ?? this.config.domain, () => `${moduleName}: Missing domain in params/config`)\n return this._domain\n }\n\n /**\n * The headers to be included in the request for each request\n */\n protected get headers(): AxiosRequestConfig['headers'] {\n if (!this._headers) this._headers = { Authorization: this.publishableApiKey }\n return this._headers\n }\n\n /**\n * True if the environment is sandbox (testing), false otherwise\n */\n protected get isSandboxEnvironment(): boolean {\n return this.domain.includes('sandbox')\n }\n\n /**\n * The Rebilly organization ID\n */\n protected get organizationId() {\n if (!this._organizationId)\n this._organizationId = removePrefix(\n assertEx(this.params.organizationId, () => `${moduleName}: Missing organizationId in params`),\n 'org_',\n )\n return this._organizationId\n }\n\n /**\n * The Rebilly Publishable API key\n */\n protected get publishableApiKey(): string {\n if (!this._publishableApiKey)\n this._publishableApiKey = assertEx(this.params.publishableApiKey, () => `${moduleName}: Missing publishableApiKey in params`)\n return this._publishableApiKey\n }\n\n /**\n * The Rebilly Organization token creation endpoint\n */\n protected get tokenEndpoint() {\n if (!this._tokenEndpoint) this._tokenEndpoint = `${this.apiRoot}/tokens`\n return this._tokenEndpoint\n }\n\n override async reportHandler(payloads?: Payload[]): Promise<Payload[]> {\n await this.started('throw')\n const results: WithSources<RebillyPaymentAuthorizationToken>[] = []\n // Verify necessary inputs and if nothing meets our criteria, bail early\n if (!payloads || payloads.length === 0) return results\n const paymentCard = payloads?.find(isPaymentCard)\n if (!paymentCard) return results\n const billingAddress = payloads?.find(isBillingAddress)\n if (!billingAddress) return results\n const axios = new AxiosJson({ headers: this.headers })\n try {\n const data = toTokenRequest(paymentCard, billingAddress)\n const response = await axios.post<CreateTokenResponse>(this.tokenEndpoint, data)\n assertEx(response.status === HttpStatusCode.Created, () => `Failed to tokenize payment card: ${response.status}`)\n const { id } = response.data\n const sources = await PayloadBuilder.dataHashes([paymentCard, billingAddress])\n results.push({ id, schema: RebillyPaymentAuthorizationTokenSchema, sources })\n } catch (error) {\n this.logger?.error?.(`${moduleName}: Error creating payment token: ${error}`)\n }\n return results\n }\n}\n","import { BillingAddress, PaymentCard } from '@xyo-network/payment-payload-plugins'\n\nimport { CreatePaymentTokenRequest } from '../Api/index.ts'\n\n/**\n * Converts a payment card and billing address to a token request\n * @param paymentCard The payment card\n * @param billingAddress The billing address\n * @returns The token request\n */\nexport const toTokenRequest = (paymentCard: PaymentCard, billingAddress: BillingAddress): CreatePaymentTokenRequest => {\n const { cvv, expMonth, expYear, cardNumber } = paymentCard\n // NOTE: We are destructuring all but the schema and passing it along to the billingAddress. This\n // is to allow for missing fields to be omitted rather than set to undefined and for any new fields\n // that might be added later to be automatically picked up on. It is fine to pass this along since\n // the user is supplying this data about themselves.\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { schema: _, ...fields } = billingAddress\n return {\n billingAddress: { ...fields },\n method: 'payment-card',\n paymentInstrument: { cvv, expMonth, expYear, pan: cardNumber },\n }\n}\n"],"mappings":";;;;;;AAAO,IAAMA,gDAAgD;;;ACKtD,IAAMC,sDAAsD,GAAGC,6CAAAA;;;ACLtE,SAASC,gBAAgB;AACzB,SAASC,WAA+BC,sBAAsB;AAC9D,SAASC,sBAAsB;AAE/B,SAASC,kBAAkBC,qBAAqB;AAChD,SAA2CC,8CAA8C;AACzF,SAASC,wBAAwB;;;ACI1B,IAAMC,iBAAiB,wBAACC,aAA0BC,mBAAAA;AACvD,QAAM,EAAEC,KAAKC,UAAUC,SAASC,WAAU,IAAKL;AAM/C,QAAM,EAAEM,QAAQC,GAAG,GAAGC,OAAAA,IAAWP;AACjC,SAAO;IACLA,gBAAgB;MAAE,GAAGO;IAAO;IAC5BC,QAAQ;IACRC,mBAAmB;MAAER;MAAKC;MAAUC;MAASO,KAAKN;IAAW;EAC/D;AACF,GAb8B;;;ADI9B,IAAMO,eAAe,wBAACC,KAAaC,WAAAA;AACjC,QAAMC,QAAQ,IAAIC,OAAO,IAAIF,MAAAA,EAAQ;AACrC,SAAOD,IAAII,QAAQF,OAAO,EAAA;AAC5B,GAHqB;AAKrB,IAAMG,aAAa;AACZ,IAAMC,2CAAN,MAAMA,iDAGHC,iBAAAA;EAIEC,WAA+BC;EAC/BC,UAA8BD;EAC9BE,WAAsDF;EACtDG,kBAAsCH;EACtCI,qBAAyCJ;EACzCK,iBAAqCL;;;;EAK/C,IAAcM,UAAU;AACtB,QA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AQ,IAAIC,UAAU;MAAEjB,SAAS,KAAKA;IAAQ,CAAA;AACpD,QAAI;AACF,YAAMkB,OAAOC,eAAeR,aAAaG,cAAAA;AACzC,YAAMM,WAAW,MAAMJ,MAAMK,KAA0B,KAAKhB,eAAea,IAAAA;AAC3ErB,eAASuB,SAASE,WAAWC,eAAeC,SAAS,MAAM,oCAAoCJ,SAASE,MAAM,EAAE;AAChH,YAAM,EAAEG,GAAE,IAAKL,SAASF;AACxB,YAAMQ,UAAU,MAAMC,eAAeC,WAAW;QAACjB;QAAaG;OAAe;AAC7EL,cAAQoB,KAAK;QAAEJ;QAAIK,QAAQC;QAAwCL;MAAQ,CAAA;IAC7E,SAASM,OAAO;AACd,uBAAKC,WAAL,mBAAaD,UAAb,4BAAqB,GAAGhD,UAAAA,mCAA6CgD,KAAAA;IACvE;AACA,WAAOvB;EACT;AACF;AA7FUvB;AACR,cAJWD,0CAIKiD,iBAAgB;EAACC;;AACjC,cALWlD,0CAKKmD,uBAAsBD;AALjC,IAAMlD,0CAAN;","names":["RebillyPaymentCardAuthorizationSentinelSchema","RebillyPaymentCardAuthorizationSentinelConfigSchema","RebillyPaymentCardAuthorizationSentinelSchema","assertEx","AxiosJson","HttpStatusCode","PayloadBuilder","isBillingAddress","isPaymentCard","RebillyPaymentAuthorizationTokenSchema","AbstractSentinel","toTokenRequest","paymentCard","billingAddress","cvv","expMonth","expYear","cardNumber","schema","_","fields","method","paymentInstrument","pan","removePrefix","str","prefix","regex","RegExp","replace","moduleName","RebillyPaymentCardAuthorizationSentinel","AbstractSentinel","_apiRoot","undefined","_domain","_headers","_organizationId","_publishableApiKey","_tokenEndpoint","apiRoot","domain","organizationId","assertEx","params","config","headers","Authorization","publishableApiKey","isSandboxEnvironment","includes","tokenEndpoint","reportHandler","payloads","started","results","length","paymentCard","find","isPaymentCard","billingAddress","isBillingAddress","axios","AxiosJson","data","toTokenRequest","response","post","status","HttpStatusCode","Created","id","sources","PayloadBuilder","dataHashes","push","schema","RebillyPaymentAuthorizationTokenSchema","error","logger","configSchemas","RebillyPaymentCardAuthorizationSentinelConfigSchema","defaultConfigSchema"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './toTokenRequest.
|
|
1
|
+
export * from './toTokenRequest.ts';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './toTokenRequest.
|
|
1
|
+
export * from './toTokenRequest.ts';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './toTokenRequest.
|
|
1
|
+
export * from './toTokenRequest.ts';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { BillingAddress, PaymentCard } from '@xyo-network/payment-payload-plugins';
|
|
2
|
-
import { CreatePaymentTokenRequest } from '../Api/index.
|
|
2
|
+
import { CreatePaymentTokenRequest } from '../Api/index.ts';
|
|
3
3
|
export declare const toTokenRequest: (paymentCard: PaymentCard, billingAddress: BillingAddress) => CreatePaymentTokenRequest;
|
|
4
4
|
//# sourceMappingURL=toTokenRequest.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { BillingAddress, PaymentCard } from '@xyo-network/payment-payload-plugins';
|
|
2
|
-
import { CreatePaymentTokenRequest } from '../Api/index.
|
|
2
|
+
import { CreatePaymentTokenRequest } from '../Api/index.ts';
|
|
3
3
|
export declare const toTokenRequest: (paymentCard: PaymentCard, billingAddress: BillingAddress) => CreatePaymentTokenRequest;
|
|
4
4
|
//# sourceMappingURL=toTokenRequest.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { BillingAddress, PaymentCard } from '@xyo-network/payment-payload-plugins';
|
|
2
|
-
import { CreatePaymentTokenRequest } from '../Api/index.
|
|
2
|
+
import { CreatePaymentTokenRequest } from '../Api/index.ts';
|
|
3
3
|
export declare const toTokenRequest: (paymentCard: PaymentCard, billingAddress: BillingAddress) => CreatePaymentTokenRequest;
|
|
4
4
|
//# sourceMappingURL=toTokenRequest.d.ts.map
|