@xyo-network/rebilly-payment-card-authorization-plugin 5.3.2 → 5.3.3

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.
Files changed (36) hide show
  1. package/dist/neutral/Api/PaymentCardToken/Request.d.ts +88 -0
  2. package/dist/neutral/Api/PaymentCardToken/Request.d.ts.map +1 -0
  3. package/dist/neutral/Api/PaymentCardToken/Response.d.ts +70 -0
  4. package/dist/neutral/Api/PaymentCardToken/Response.d.ts.map +1 -0
  5. package/dist/neutral/Api/PaymentCardToken/index.d.ts +3 -0
  6. package/dist/neutral/Api/PaymentCardToken/index.d.ts.map +1 -0
  7. package/dist/neutral/Api/index.d.ts +2 -0
  8. package/dist/neutral/Api/index.d.ts.map +1 -0
  9. package/dist/neutral/Config.d.ts +14 -0
  10. package/dist/neutral/Config.d.ts.map +1 -0
  11. package/dist/neutral/Params.d.ts +11 -0
  12. package/dist/neutral/Params.d.ts.map +1 -0
  13. package/dist/neutral/Schema.d.ts +5 -0
  14. package/dist/neutral/Schema.d.ts.map +1 -0
  15. package/dist/neutral/Sentinel.d.ts +49 -0
  16. package/dist/neutral/Sentinel.d.ts.map +1 -0
  17. package/dist/neutral/index.d.ts +5 -0
  18. package/dist/neutral/index.d.ts.map +1 -0
  19. package/dist/neutral/index.mjs +139 -0
  20. package/dist/neutral/index.mjs.map +1 -0
  21. package/dist/neutral/util/index.d.ts +2 -0
  22. package/dist/neutral/util/index.d.ts.map +1 -0
  23. package/dist/neutral/util/toTokenRequest.d.ts +10 -0
  24. package/dist/neutral/util/toTokenRequest.d.ts.map +1 -0
  25. package/package.json +12 -7
  26. package/src/Api/PaymentCardToken/Request.ts +0 -238
  27. package/src/Api/PaymentCardToken/Response.ts +0 -73
  28. package/src/Api/PaymentCardToken/index.ts +0 -2
  29. package/src/Api/index.ts +0 -1
  30. package/src/Config.ts +0 -18
  31. package/src/Params.ts +0 -15
  32. package/src/Schema.ts +0 -4
  33. package/src/Sentinel.ts +0 -121
  34. package/src/index.ts +0 -4
  35. package/src/util/index.ts +0 -1
  36. package/src/util/toTokenRequest.ts +0 -28
@@ -0,0 +1,88 @@
1
+ export interface ContactPhoneNumber {
2
+ /**
3
+ * Phone number label or name.
4
+ * <= 45 characters
5
+ */
6
+ label: string;
7
+ /**
8
+ * Specifies if the phone number is the contact's primary phone number.
9
+ */
10
+ primary?: boolean;
11
+ /**
12
+ * Phone number value.
13
+ * <= 50 characters
14
+ */
15
+ value: string;
16
+ }
17
+ export interface ContactEmail {
18
+ /**
19
+ * Email label or name.
20
+ * <= 45 characters
21
+ */
22
+ label: string;
23
+ /**
24
+ * Specifies if the email address is the contact's primary email address.
25
+ */
26
+ primary?: boolean;
27
+ /**
28
+ * Email address value.
29
+ * <= 255 characters
30
+ */
31
+ value: string;
32
+ }
33
+ /**
34
+ * Billing address details associated with the payment token.
35
+ */
36
+ export interface RequestBillingAddress {
37
+ /** Street address line 1. */
38
+ address?: string;
39
+ /** Street address line 2. */
40
+ address2?: string | null;
41
+ /** City of the billing address. */
42
+ city?: string;
43
+ /** Country code of the billing address, ISO 3166-1 alpha-2 code. */
44
+ country?: string;
45
+ /** Date of birth of the cardholder. */
46
+ dob?: string;
47
+ /** Email addresses associated with the billing address. */
48
+ emails?: ContactEmail[];
49
+ /** First name of the cardholder. */
50
+ firstName: string;
51
+ /** Job title of the cardholder. */
52
+ jobTitle?: string | null;
53
+ /** Last name of the cardholder. */
54
+ lastName: string;
55
+ /** Organization or company name associated with the billing address. */
56
+ organization?: string | null;
57
+ /** Phone numbers associated with the billing address. */
58
+ phoneNumbers?: ContactPhoneNumber[];
59
+ /** Postal or ZIP code of the billing address. */
60
+ postalCode?: string;
61
+ /** State or region of the billing address. */
62
+ region?: string;
63
+ }
64
+ export interface RequestPaymentCardInstrument {
65
+ /**
66
+ * Card Verification Value (CVV/CVC) of the payment card.
67
+ */
68
+ cvv: string;
69
+ /**
70
+ * Expiration month of the payment card.
71
+ */
72
+ expMonth: number;
73
+ /**
74
+ * Expiration year of the payment card.
75
+ */
76
+ expYear: number;
77
+ /**
78
+ * Primary Account Number (PAN) of the payment card. This value is required to perform a payment.
79
+ */
80
+ pan: string;
81
+ }
82
+ export type PaymentMethod = 'payment-card';
83
+ export interface CreatePaymentTokenRequest {
84
+ billingAddress: RequestBillingAddress;
85
+ method: PaymentMethod;
86
+ paymentInstrument: RequestPaymentCardInstrument;
87
+ }
88
+ //# sourceMappingURL=Request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Request.d.ts","sourceRoot":"","sources":["../../../../src/Api/PaymentCardToken/Request.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,6BAA6B;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,uCAAuC;IACvC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,2DAA2D;IAC3D,MAAM,CAAC,EAAE,YAAY,EAAE,CAAA;IACvB,oCAAoC;IACpC,SAAS,EAAE,MAAM,CAAA;IACjB,mCAAmC;IACnC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAA;IAChB,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,yDAAyD;IACzD,YAAY,CAAC,EAAE,kBAAkB,EAAE,CAAA;IACnC,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,MAAM,aAAa,GA8FrB,cAAc,CAAA;AAsDlB,MAAM,WAAW,yBAAyB;IACxC,cAAc,EAAE,qBAAqB,CAAA;IACrC,MAAM,EAAE,aAAa,CAAA;IACrB,iBAAiB,EAAE,4BAA4B,CAAA;CAChD"}
@@ -0,0 +1,70 @@
1
+ import type { PaymentMethod, RequestBillingAddress } from './Request.ts';
2
+ export interface ResponseBillingAddress extends RequestBillingAddress {
3
+ hash?: string | null;
4
+ }
5
+ /**
6
+ * Main interface for API response encapsulating all relevant details.
7
+ */
8
+ export interface CreateTokenResponse {
9
+ /** Hyperlinks to related API resources. */
10
+ _links: Link[];
11
+ /** Billing address associated with the payment token. */
12
+ billingAddress: ResponseBillingAddress;
13
+ /** Card brand such as Visa or Mastercard. */
14
+ brand: string;
15
+ /** An identifier for the browser data. */
16
+ browserData: unknown | null;
17
+ /** Date and time when the token was created. */
18
+ createdTime: string;
19
+ /** Expiration time of the token. */
20
+ expirationTime: string | null;
21
+ /** Date and time when the token expired. */
22
+ expiredTime: string | null;
23
+ /** An identifier for the fingerprint of the device used. */
24
+ fingerprint: string | null;
25
+ /** An identifier of the token. */
26
+ id: string;
27
+ /** Indicates if the token has been used. */
28
+ isUsed: boolean;
29
+ /** The last four digits of the payment instrument. */
30
+ last4: string;
31
+ /** Payment method such as 'payment-card'. */
32
+ method: PaymentMethod;
33
+ /** Payment instrument details. */
34
+ paymentInstrument: ResponsePaymentCardInstrument;
35
+ /** Metadata related to risk evaluation. */
36
+ riskMetadata: unknown | null;
37
+ /** Date and time when the token was last updated. */
38
+ updatedTime: string;
39
+ /** Usage time of the token. */
40
+ usageTime: string | null;
41
+ /** Indicates if the token has already been used. */
42
+ used: boolean;
43
+ /** Date and time when the token was first used. */
44
+ usedTime: string | null;
45
+ }
46
+ /**
47
+ * Payment instrument details such as credit card information.
48
+ */
49
+ export interface ResponsePaymentCardInstrument {
50
+ /** Bank identification number or issuer identification number of the card. */
51
+ bin: string;
52
+ /** Card brand such as Visa or Mastercard. */
53
+ brand: string;
54
+ /** Expiration month of the card. */
55
+ expMonth: number;
56
+ /** Expiration year of the card. */
57
+ expYear: number;
58
+ /** Last four digits of the card number. */
59
+ last4: string;
60
+ }
61
+ /**
62
+ * Links structure for API navigation.
63
+ */
64
+ export interface Link {
65
+ /** URL of the related resource. */
66
+ href: string;
67
+ /** Relation type of the link. */
68
+ rel: string;
69
+ }
70
+ //# sourceMappingURL=Response.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Response.d.ts","sourceRoot":"","sources":["../../../../src/Api/PaymentCardToken/Response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AAExE,MAAM,WAAW,sBAAuB,SAAQ,qBAAqB;IACnE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,2CAA2C;IAC3C,MAAM,EAAE,IAAI,EAAE,CAAA;IACd,yDAAyD;IACzD,cAAc,EAAE,sBAAsB,CAAA;IACtC,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAA;IACb,0CAA0C;IAC1C,WAAW,EAAE,OAAO,GAAG,IAAI,CAAA;IAC3B,gDAAgD;IAChD,WAAW,EAAE,MAAM,CAAA;IACnB,oCAAoC;IACpC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,4CAA4C;IAC5C,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,4DAA4D;IAC5D,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,kCAAkC;IAClC,EAAE,EAAE,MAAM,CAAA;IACV,4CAA4C;IAC5C,MAAM,EAAE,OAAO,CAAA;IACf,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAA;IACb,6CAA6C;IAC7C,MAAM,EAAE,aAAa,CAAA;IACrB,kCAAkC;IAClC,iBAAiB,EAAE,6BAA6B,CAAA;IAChD,2CAA2C;IAC3C,YAAY,EAAE,OAAO,GAAG,IAAI,CAAA;IAC5B,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAA;IACnB,+BAA+B;IAC/B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,oDAAoD;IACpD,IAAI,EAAE,OAAO,CAAA;IACb,mDAAmD;IACnD,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,8EAA8E;IAC9E,GAAG,EAAE,MAAM,CAAA;IACX,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAA;IACb,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAA;IAChB,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAA;IACZ,iCAAiC;IACjC,GAAG,EAAE,MAAM,CAAA;CACZ"}
@@ -0,0 +1,3 @@
1
+ export * from './Request.ts';
2
+ export * from './Response.ts';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Api/PaymentCardToken/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './PaymentCardToken/index.ts';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Api/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAA"}
@@ -0,0 +1,14 @@
1
+ import type { RebillyApiDomainSettings } from '@xyo-network/rebilly-payment-payload-plugin';
2
+ import type { SentinelConfig } from '@xyo-network/sentinel-model';
3
+ export declare const RebillyPaymentCardAuthorizationSentinelConfigSchema: string & {
4
+ readonly __schema: true;
5
+ };
6
+ export type RebillyPaymentCardAuthorizationSentinelConfigSchema = typeof RebillyPaymentCardAuthorizationSentinelConfigSchema;
7
+ export interface RebillyPaymentCardAuthorizationSentinelConfig extends SentinelConfig<{
8
+ /**
9
+ * The config schema
10
+ */
11
+ schema: RebillyPaymentCardAuthorizationSentinelConfigSchema;
12
+ }>, Partial<RebillyApiDomainSettings> {
13
+ }
14
+ //# sourceMappingURL=Config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../src/Config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAA;AAC3F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAIjE,eAAO,MAAM,mDAAmD;;CAA4E,CAAA;AAC5I,MAAM,MAAM,mDAAmD,GAAG,OAAO,mDAAmD,CAAA;AAK5H,MAAM,WAAW,6CAA8C,SAAQ,cAAc,CAAC;IACpF;;OAEG;IACH,MAAM,EAAE,mDAAmD,CAAA;CAC5D,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC;CAAG"}
@@ -0,0 +1,11 @@
1
+ import type { AnyConfigSchema } from '@xyo-network/module-model';
2
+ import type { RebillyOrganizationSettings, RebillyPublishableApiSettings } from '@xyo-network/rebilly-payment-payload-plugin';
3
+ import type { SentinelParams } from '@xyo-network/sentinel-model';
4
+ import type { RebillyPaymentCardAuthorizationSentinelConfig } from './Config.ts';
5
+ export type RebillyPaymentCardAuthorizationParams = Partial<RebillyPublishableApiSettings & RebillyOrganizationSettings>;
6
+ export interface RebillyPaymentCardAuthorizationSentinelParams<TConfig extends AnyConfigSchema<RebillyPaymentCardAuthorizationSentinelConfig> = AnyConfigSchema<RebillyPaymentCardAuthorizationSentinelConfig>> extends SentinelParams<TConfig> {
7
+ domain?: string;
8
+ organizationId?: string;
9
+ publishableApiKey?: string;
10
+ }
11
+ //# sourceMappingURL=Params.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Params.d.ts","sourceRoot":"","sources":["../../src/Params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,KAAK,EAAE,2BAA2B,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAA;AAC7H,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAEjE,OAAO,KAAK,EAAE,6CAA6C,EAAE,MAAM,aAAa,CAAA;AAEhF,MAAM,MAAM,qCAAqC,GAAG,OAAO,CAAC,6BAA6B,GAAG,2BAA2B,CAAC,CAAA;AAExH,MAAM,WAAW,6CAA6C,CAC5D,OAAO,SAAS,eAAe,CAAC,6CAA6C,CAAC,GAAG,eAAe,CAAC,6CAA6C,CAAC,CAC/I,SAAQ,cAAc,CAAC,OAAO,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B"}
@@ -0,0 +1,5 @@
1
+ export declare const RebillyPaymentCardAuthorizationSentinelSchema: "network.xyo.sentinel.payments.payment.instrument.card.authorization.rebilly" & {
2
+ readonly __schema: true;
3
+ };
4
+ export type RebillyPaymentCardAuthorizationSentinelSchema = typeof RebillyPaymentCardAuthorizationSentinelSchema;
5
+ //# sourceMappingURL=Schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../../src/Schema.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,6CAA6C;;CAAgG,CAAA;AAC1J,MAAM,MAAM,6CAA6C,GAAG,OAAO,6CAA6C,CAAA"}
@@ -0,0 +1,49 @@
1
+ import type { Payload } from '@xyo-network/payload-model';
2
+ import { AbstractSentinel } from '@xyo-network/sentinel-abstract';
3
+ import type { SentinelInstance, SentinelModuleEventData } from '@xyo-network/sentinel-model';
4
+ import type { AxiosRequestConfig } from 'axios';
5
+ import type { RebillyPaymentCardAuthorizationSentinelParams } from './Params.ts';
6
+ export declare class RebillyPaymentCardAuthorizationSentinel<TParams extends RebillyPaymentCardAuthorizationSentinelParams = RebillyPaymentCardAuthorizationSentinelParams, TEventData extends SentinelModuleEventData<SentinelInstance<TParams>> = SentinelModuleEventData<SentinelInstance<TParams>>> extends AbstractSentinel<TParams, TEventData> {
7
+ static readonly configSchemas: (string & {
8
+ readonly __schema: true;
9
+ })[];
10
+ static readonly defaultConfigSchema: string & {
11
+ readonly __schema: true;
12
+ };
13
+ protected _apiRoot: string | undefined;
14
+ protected _domain: string | undefined;
15
+ protected _headers: AxiosRequestConfig['headers'] | undefined;
16
+ protected _organizationId: string | undefined;
17
+ protected _publishableApiKey: string | undefined;
18
+ protected _tokenEndpoint: string | undefined;
19
+ /**
20
+ * The Rebilly Organization API root endpoint
21
+ */
22
+ protected get apiRoot(): string;
23
+ /**
24
+ * The Rebilly domain
25
+ */
26
+ protected get domain(): string;
27
+ /**
28
+ * The headers to be included in the request for each request
29
+ */
30
+ protected get headers(): AxiosRequestConfig['headers'];
31
+ /**
32
+ * True if the environment is sandbox (testing), false otherwise
33
+ */
34
+ protected get isSandboxEnvironment(): boolean;
35
+ /**
36
+ * The Rebilly organization ID
37
+ */
38
+ protected get organizationId(): string;
39
+ /**
40
+ * The Rebilly Publishable API key
41
+ */
42
+ protected get publishableApiKey(): string;
43
+ /**
44
+ * The Rebilly Organization token creation endpoint
45
+ */
46
+ protected get tokenEndpoint(): string;
47
+ reportHandler(payloads?: Payload[]): Promise<Payload[]>;
48
+ }
49
+ //# sourceMappingURL=Sentinel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Sentinel.d.ts","sourceRoot":"","sources":["../../src/Sentinel.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAe,MAAM,4BAA4B,CAAA;AAKtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AAC5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAA;AAK/C,OAAO,KAAK,EAAE,6CAA6C,EAAE,MAAM,aAAa,CAAA;AAShF,qBAAa,uCAAuC,CAClD,OAAO,SAAS,6CAA6C,GAAG,6CAA6C,EAC7G,UAAU,SAAS,uBAAuB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,GAAG,uBAAuB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAC1H,SAAQ,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7C,gBAAyB,aAAa;;SAAwD;IAC9F,gBAAyB,mBAAmB;;MAAsD;IAElG,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAY;IAClD,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAY;IACjD,SAAS,CAAC,QAAQ,EAAE,kBAAkB,CAAC,SAAS,CAAC,GAAG,SAAS,CAAY;IACzE,SAAS,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAY;IACzD,SAAS,CAAC,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAY;IAC5D,SAAS,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAY;IAExD;;OAEG;IACH,SAAS,KAAK,OAAO,WAGpB;IAED;;OAEG;IACH,SAAS,KAAK,MAAM,WAGnB;IAED;;OAEG;IACH,SAAS,KAAK,OAAO,IAAI,kBAAkB,CAAC,SAAS,CAAC,CAGrD;IAED;;OAEG;IACH,SAAS,KAAK,oBAAoB,IAAI,OAAO,CAE5C;IAED;;OAEG;IACH,SAAS,KAAK,cAAc,WAO3B;IAED;;OAEG;IACH,SAAS,KAAK,iBAAiB,IAAI,MAAM,CAIxC;IAED;;OAEG;IACH,SAAS,KAAK,aAAa,WAG1B;IAEc,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CAwBvE"}
@@ -0,0 +1,5 @@
1
+ export * from './Config.ts';
2
+ export * from './Params.ts';
3
+ export * from './Schema.ts';
4
+ export * from './Sentinel.ts';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA"}
@@ -0,0 +1,139 @@
1
+ // src/Config.ts
2
+ import { asSchema as asSchema2 } from "@xyo-network/payload-model";
3
+
4
+ // src/Schema.ts
5
+ import { asSchema } from "@xyo-network/payload-model";
6
+ var RebillyPaymentCardAuthorizationSentinelSchema = asSchema("network.xyo.sentinel.payments.payment.instrument.card.authorization.rebilly", true);
7
+
8
+ // src/Config.ts
9
+ var RebillyPaymentCardAuthorizationSentinelConfigSchema = asSchema2(`${RebillyPaymentCardAuthorizationSentinelSchema}.config`, true);
10
+
11
+ // src/Sentinel.ts
12
+ import { assertEx, axiosJsonConfig } from "@xylabs/sdk-js";
13
+ import { isBillingAddress, isPaymentCard } from "@xyo-network/payment-payload-plugins";
14
+ import { RebillyPaymentAuthorizationTokenSchema } from "@xyo-network/rebilly-payment-payload-plugin";
15
+ import { PayloadBuilder } from "@xyo-network/sdk-js";
16
+ import { AbstractSentinel } from "@xyo-network/sentinel-abstract";
17
+ import { Axios, HttpStatusCode } from "axios";
18
+
19
+ // src/util/toTokenRequest.ts
20
+ var toTokenRequest = (paymentCard, billingAddress) => {
21
+ const {
22
+ cvv,
23
+ expMonth,
24
+ expYear,
25
+ cardNumber
26
+ } = paymentCard;
27
+ const { schema: _, ...fields } = billingAddress;
28
+ return {
29
+ billingAddress: { ...fields },
30
+ method: "payment-card",
31
+ paymentInstrument: {
32
+ cvv,
33
+ expMonth,
34
+ expYear,
35
+ pan: cardNumber
36
+ }
37
+ };
38
+ };
39
+
40
+ // src/Sentinel.ts
41
+ var removePrefix = (str, prefix) => {
42
+ const regex = new RegExp(`^${prefix}`);
43
+ return str.replace(regex, "");
44
+ };
45
+ var moduleName = "RebillyPaymentCardAuthorizationSentinel";
46
+ var RebillyPaymentCardAuthorizationSentinel = class extends AbstractSentinel {
47
+ static configSchemas = [RebillyPaymentCardAuthorizationSentinelConfigSchema];
48
+ static defaultConfigSchema = RebillyPaymentCardAuthorizationSentinelConfigSchema;
49
+ _apiRoot = void 0;
50
+ _domain = void 0;
51
+ _headers = void 0;
52
+ _organizationId = void 0;
53
+ _publishableApiKey = void 0;
54
+ _tokenEndpoint = void 0;
55
+ /**
56
+ * The Rebilly Organization API root endpoint
57
+ */
58
+ get apiRoot() {
59
+ if (!this._apiRoot) this._apiRoot = `${this.domain}/organizations/${this.organizationId}`;
60
+ return this._apiRoot;
61
+ }
62
+ /**
63
+ * The Rebilly domain
64
+ */
65
+ get domain() {
66
+ if (!this._domain) this._domain = assertEx(this.params.domain ?? this.config.domain, () => `${moduleName}: Missing domain in params/config`);
67
+ return this._domain;
68
+ }
69
+ /**
70
+ * The headers to be included in the request for each request
71
+ */
72
+ get headers() {
73
+ if (!this._headers) this._headers = { Authorization: this.publishableApiKey };
74
+ return this._headers;
75
+ }
76
+ /**
77
+ * True if the environment is sandbox (testing), false otherwise
78
+ */
79
+ get isSandboxEnvironment() {
80
+ return this.domain.includes("sandbox");
81
+ }
82
+ /**
83
+ * The Rebilly organization ID
84
+ */
85
+ get organizationId() {
86
+ if (!this._organizationId)
87
+ this._organizationId = removePrefix(
88
+ assertEx(this.params.organizationId, () => `${moduleName}: Missing organizationId in params`),
89
+ "org_"
90
+ );
91
+ return this._organizationId;
92
+ }
93
+ /**
94
+ * The Rebilly Publishable API key
95
+ */
96
+ get publishableApiKey() {
97
+ if (!this._publishableApiKey)
98
+ this._publishableApiKey = assertEx(this.params.publishableApiKey, () => `${moduleName}: Missing publishableApiKey in params`);
99
+ return this._publishableApiKey;
100
+ }
101
+ /**
102
+ * The Rebilly Organization token creation endpoint
103
+ */
104
+ get tokenEndpoint() {
105
+ if (!this._tokenEndpoint) this._tokenEndpoint = `${this.apiRoot}/tokens`;
106
+ return this._tokenEndpoint;
107
+ }
108
+ async reportHandler(payloads) {
109
+ await this.started("throw");
110
+ const results = [];
111
+ if (!payloads || payloads.length === 0) return results;
112
+ const paymentCard = payloads?.find(isPaymentCard);
113
+ if (!paymentCard) return results;
114
+ const billingAddress = payloads?.find(isBillingAddress);
115
+ if (!billingAddress) return results;
116
+ const axios = new Axios(axiosJsonConfig({ headers: this.headers }));
117
+ try {
118
+ const data = toTokenRequest(paymentCard, billingAddress);
119
+ const response = await axios.post(this.tokenEndpoint, data);
120
+ assertEx(response.status === HttpStatusCode.Created, () => `Failed to tokenize payment card: ${response.status}`);
121
+ const { id } = response.data;
122
+ const $sources = await PayloadBuilder.dataHashes([paymentCard, billingAddress]);
123
+ results.push({
124
+ id,
125
+ schema: RebillyPaymentAuthorizationTokenSchema,
126
+ $sources
127
+ });
128
+ } catch (error) {
129
+ this.logger?.error?.(`${moduleName}: Error creating payment token: ${error}`);
130
+ }
131
+ return results;
132
+ }
133
+ };
134
+ export {
135
+ RebillyPaymentCardAuthorizationSentinel,
136
+ RebillyPaymentCardAuthorizationSentinelConfigSchema,
137
+ RebillyPaymentCardAuthorizationSentinelSchema
138
+ };
139
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/Config.ts","../../src/Schema.ts","../../src/Sentinel.ts","../../src/util/toTokenRequest.ts"],"sourcesContent":["import { asSchema } from '@xyo-network/payload-model'\nimport type { RebillyApiDomainSettings } from '@xyo-network/rebilly-payment-payload-plugin'\nimport type { SentinelConfig } from '@xyo-network/sentinel-model'\n\nimport { RebillyPaymentCardAuthorizationSentinelSchema } from './Schema.ts'\n\nexport const RebillyPaymentCardAuthorizationSentinelConfigSchema = asSchema(`${RebillyPaymentCardAuthorizationSentinelSchema}.config`, true)\nexport type RebillyPaymentCardAuthorizationSentinelConfigSchema = typeof RebillyPaymentCardAuthorizationSentinelConfigSchema\n\n/*\n * The Rebilly Payment Card Authorization Sentinel Config\n */\nexport interface RebillyPaymentCardAuthorizationSentinelConfig extends SentinelConfig<{\n /**\n * The config schema\n */\n schema: RebillyPaymentCardAuthorizationSentinelConfigSchema\n}>, Partial<RebillyApiDomainSettings> {}\n","import { asSchema } from '@xyo-network/payload-model'\n\nexport const RebillyPaymentCardAuthorizationSentinelSchema = asSchema('network.xyo.sentinel.payments.payment.instrument.card.authorization.rebilly', true)\nexport type RebillyPaymentCardAuthorizationSentinelSchema = typeof RebillyPaymentCardAuthorizationSentinelSchema\n","import { assertEx, axiosJsonConfig } from '@xylabs/sdk-js'\nimport type { Payload, WithSources } from '@xyo-network/payload-model'\nimport { isBillingAddress, isPaymentCard } from '@xyo-network/payment-payload-plugins'\nimport type { RebillyPaymentAuthorizationToken } from '@xyo-network/rebilly-payment-payload-plugin'\nimport { RebillyPaymentAuthorizationTokenSchema } from '@xyo-network/rebilly-payment-payload-plugin'\nimport { PayloadBuilder } from '@xyo-network/sdk-js'\nimport { AbstractSentinel } from '@xyo-network/sentinel-abstract'\nimport type { SentinelInstance, SentinelModuleEventData } from '@xyo-network/sentinel-model'\nimport type { AxiosRequestConfig } from 'axios'\nimport { Axios, HttpStatusCode } from 'axios'\n\nimport type { CreateTokenResponse } from './Api/index.ts'\nimport { RebillyPaymentCardAuthorizationSentinelConfigSchema } from './Config.ts'\nimport type { 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 readonly configSchemas = [RebillyPaymentCardAuthorizationSentinelConfigSchema]\n static override readonly 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 Axios(axiosJsonConfig({ 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({\n id, schema: RebillyPaymentAuthorizationTokenSchema, $sources,\n })\n } catch (error) {\n this.logger?.error?.(`${moduleName}: Error creating payment token: ${error}`)\n }\n return results\n }\n}\n","import type { BillingAddress, PaymentCard } from '@xyo-network/payment-payload-plugins'\n\nimport type { 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 {\n cvv, expMonth, expYear, cardNumber,\n } = paymentCard\n // 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\n const { schema: _, ...fields } = billingAddress\n return {\n billingAddress: { ...fields },\n method: 'payment-card',\n paymentInstrument: {\n cvv, expMonth, expYear, pan: cardNumber,\n },\n }\n}\n"],"mappings":"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","names":["asSchema","asSchema"]}
@@ -0,0 +1,2 @@
1
+ export * from './toTokenRequest.ts';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA"}
@@ -0,0 +1,10 @@
1
+ import type { BillingAddress, PaymentCard } from '@xyo-network/payment-payload-plugins';
2
+ import type { CreatePaymentTokenRequest } from '../Api/index.ts';
3
+ /**
4
+ * Converts a payment card and billing address to a token request
5
+ * @param paymentCard The payment card
6
+ * @param billingAddress The billing address
7
+ * @returns The token request
8
+ */
9
+ export declare const toTokenRequest: (paymentCard: PaymentCard, billingAddress: BillingAddress) => CreatePaymentTokenRequest;
10
+ //# sourceMappingURL=toTokenRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toTokenRequest.d.ts","sourceRoot":"","sources":["../../../src/util/toTokenRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAA;AAEvF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAA;AAEhE;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,aAAa,WAAW,EAAE,gBAAgB,cAAc,KAAG,yBAiBzF,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/rebilly-payment-card-authorization-plugin",
3
- "version": "5.3.2",
3
+ "version": "5.3.3",
4
4
  "description": "Typescript/Javascript Plugins for XYO Platform",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -30,21 +30,21 @@
30
30
  "types": "dist/neutral/index.d.ts",
31
31
  "files": [
32
32
  "dist",
33
- "src",
34
- "!**/*.bench.*",
35
- "!**/*.spec.*",
36
- "!**/*.test.*"
33
+ "README.md"
37
34
  ],
35
+ "dependencies": {
36
+ "@xyo-network/payment-payload-plugins": "workspace:^",
37
+ "@xyo-network/rebilly-payment-payload-plugin": "workspace:^"
38
+ },
38
39
  "devDependencies": {
39
40
  "@xylabs/sdk-js": "^5.0.90",
41
+ "@xylabs/ts-scripts-common": "~7.5.10",
40
42
  "@xylabs/ts-scripts-yarn3": "~7.5.10",
41
43
  "@xylabs/tsconfig": "~7.5.10",
42
44
  "@xylabs/vitest-extended": "~5.0.90",
43
45
  "@xyo-network/boundwitness-model": "~5.3.5",
44
46
  "@xyo-network/module-model": "~5.3.5",
45
47
  "@xyo-network/payload-model": "~5.3.5",
46
- "@xyo-network/payment-payload-plugins": "5.3.2",
47
- "@xyo-network/rebilly-payment-payload-plugin": "5.3.2",
48
48
  "@xyo-network/sdk-js": "~5.3.5",
49
49
  "@xyo-network/sentinel-abstract": "~5.3.5",
50
50
  "@xyo-network/sentinel-model": "~5.3.5",
@@ -55,6 +55,11 @@
55
55
  },
56
56
  "peerDependencies": {
57
57
  "@xylabs/sdk-js": "^5",
58
+ "@xyo-network/module-model": "^5",
59
+ "@xyo-network/payload-model": "^5",
60
+ "@xyo-network/sdk-js": "^5",
61
+ "@xyo-network/sentinel-abstract": "^5",
62
+ "@xyo-network/sentinel-model": "^5",
58
63
  "axios": "^1",
59
64
  "zod": "^4"
60
65
  },
@@ -1,238 +0,0 @@
1
- export interface ContactPhoneNumber {
2
- /**
3
- * Phone number label or name.
4
- * <= 45 characters
5
- */
6
- label: string
7
- /**
8
- * Specifies if the phone number is the contact's primary phone number.
9
- */
10
- primary?: boolean
11
- /**
12
- * Phone number value.
13
- * <= 50 characters
14
- */
15
- value: string
16
- }
17
-
18
- export interface ContactEmail {
19
- /**
20
- * Email label or name.
21
- * <= 45 characters
22
- */
23
- label: string
24
- /**
25
- * Specifies if the email address is the contact's primary email address.
26
- */
27
- primary?: boolean
28
- /**
29
- * Email address value.
30
- * <= 255 characters
31
- */
32
- value: string
33
- }
34
-
35
- /**
36
- * Billing address details associated with the payment token.
37
- */
38
- export interface RequestBillingAddress {
39
- /** Street address line 1. */
40
- address?: string
41
- /** Street address line 2. */
42
- address2?: string | null
43
- /** City of the billing address. */
44
- city?: string
45
- /** Country code of the billing address, ISO 3166-1 alpha-2 code. */
46
- country?: string
47
- /** Date of birth of the cardholder. */
48
- dob?: string
49
- /** Email addresses associated with the billing address. */
50
- emails?: ContactEmail[]
51
- /** First name of the cardholder. */
52
- firstName: string
53
- /** Job title of the cardholder. */
54
- jobTitle?: string | null
55
- /** Last name of the cardholder. */
56
- lastName: string
57
- /** Organization or company name associated with the billing address. */
58
- organization?: string | null
59
- /** Phone numbers associated with the billing address. */
60
- phoneNumbers?: ContactPhoneNumber[]
61
- /** Postal or ZIP code of the billing address. */
62
- postalCode?: string
63
- /** State or region of the billing address. */
64
- region?: string
65
- }
66
-
67
- export interface RequestPaymentCardInstrument {
68
- /**
69
- * Card Verification Value (CVV/CVC) of the payment card.
70
- */
71
- cvv: string
72
- /**
73
- * Expiration month of the payment card.
74
- */
75
- expMonth: number
76
- /**
77
- * Expiration year of the payment card.
78
- */
79
- expYear: number
80
- /**
81
- * Primary Account Number (PAN) of the payment card. This value is required to perform a payment.
82
- */
83
- pan: string
84
- }
85
-
86
- export type PaymentMethod
87
- // | 'ach'
88
- // | 'AdvCash'
89
- // | 'Alfa-click'
90
- // | 'Alipay'
91
- // | 'AstroPay Card'
92
- // | 'AstroPay-GO'
93
- // | 'Baloto'
94
- // | 'Bancontact-mobile'
95
- // | 'Bancontact'
96
- // | 'bank-transfer-2'
97
- // | 'bank-transfer-3'
98
- // | 'bank-transfer-4'
99
- // | 'bank-transfer-5'
100
- // | 'bank-transfer-6'
101
- // | 'bank-transfer-7'
102
- // | 'bank-transfer-8'
103
- // | 'bank-transfer-9'
104
- // | 'bank-transfer'
105
- // | 'BankReferenced'
106
- // | 'Beeline'
107
- // | 'Belfius-direct-net'
108
- // | 'bitcoin'
109
- // | 'Bizum'
110
- // | 'Boleto'
111
- // | 'cash-deposit'
112
- // | 'cash'
113
- // | 'CASHlib'
114
- // | 'CashToCode'
115
- // | 'check'
116
- // | 'China UnionPay'
117
- // | 'Cleo'
118
- // | 'CODVoucher'
119
- // | 'Conekta-oxxo'
120
- // | 'cryptocurrency'
121
- // | 'Cupon-de-pagos'
122
- // | 'digital-wallet'
123
- // | 'domestic-cards'
124
- // | 'echeck'
125
- // | 'ecoPayz'
126
- // | 'ecoVoucher'
127
- // | 'Efecty'
128
- // | 'ePay.bg'
129
- // | 'EPS'
130
- // | 'eZeeWallet'
131
- // | 'FasterPay'
132
- // | 'Flexepin'
133
- // | 'Giropay'
134
- // | 'Google Pay'
135
- // | 'Gpaysafe'
136
- // | 'iDEAL'
137
- // | 'iDebit'
138
- // | 'ING-homepay'
139
- // | 'INOVAPAY-pin'
140
- // | 'INOVAPAY-wallet'
141
- // | 'InstaDebit'
142
- // | 'instant-bank-transfer'
143
- // | 'InstantPayments'
144
- // | 'Interac-eTransfer'
145
- // | 'Interac-online'
146
- // | 'Interac'
147
- // | 'invoice'
148
- // | 'iWallet'
149
- // | 'Jeton'
150
- // | 'jpay'
151
- // | 'Khelocard'
152
- // | 'Klarna'
153
- // | 'KNOT'
154
- // | 'loonie'
155
- // | 'Matrix'
156
- // | 'MaxiCash'
157
- // | 'Megafon'
158
- // | 'MiFinity-eWallet'
159
- // | 'miscellaneous'
160
- // | 'MTS'
161
- // | 'MuchBetter'
162
- // | 'Multibanco'
163
- // | 'Neosurf'
164
- // | 'Netbanking'
165
- // | 'Neteller'
166
- // | 'Nordea-Solo'
167
- // | 'OchaPay'
168
- // | 'online-bank-transfer'
169
- // | 'Onlineueberweisen'
170
- // | 'oriental-wallet'
171
- // | 'OXXO'
172
- // | 'P24'
173
- // | 'Pagadito'
174
- // | 'PagoEffectivo'
175
- // | 'Pagsmile-deposit-express'
176
- // | 'Pagsmile-lottery'
177
- // | 'Pay4Fun'
178
- // | 'PayCash'
179
- // | 'Payeer'
180
- = 'payment-card'
181
- // | 'PaymentAsia-crypto'
182
- // | 'Paymero'
183
- // | 'Paynote'
184
- // | 'paypal'
185
- // | 'Paysafecard'
186
- // | 'Paysafecash'
187
- // | 'PayTabs'
188
- // | 'Perfect-money'
189
- // | 'phone'
190
- // | 'PhonePe'
191
- // | 'Piastrix'
192
- // | 'PinPay'
193
- // | 'plaid-account'
194
- // | 'POLi'
195
- // | 'PostFinance-card'
196
- // | 'PostFinance-e-finance'
197
- // | 'QIWI'
198
- // | 'QPay'
199
- // | 'QQPay'
200
- // | 'rapyd-checkout'
201
- // | 'Resurs'
202
- // | 'SafetyPay'
203
- // | 'SEPA'
204
- // | 'Skrill Rapid Transfer'
205
- // | 'Skrill'
206
- // | 'SMSVoucher'
207
- // | 'Sofort'
208
- // | 'SparkPay'
209
- // | 'swift-dbt'
210
- // | 'Tele2'
211
- // | 'Terminaly-RF'
212
- // | 'ToditoCash-card'
213
- // | 'Trustly'
214
- // | 'UPayCard'
215
- // | 'UPI'
216
- // | 'USD-coin'
217
- // | 'VCreditos'
218
- // | 'VenusPoint'
219
- // | 'voucher-2'
220
- // | 'voucher-3'
221
- // | 'voucher-4'
222
- // | 'voucher'
223
- // | 'Webmoney'
224
- // | 'Webpay Card'
225
- // | 'Webpay-2'
226
- // | 'Webpay'
227
- // | 'WeChat Pay'
228
- // | 'XPay-P2P'
229
- // | 'XPay-QR'
230
- // | 'Yandex-money'
231
- // | 'Zimpler'
232
- // | 'Zotapay'
233
-
234
- export interface CreatePaymentTokenRequest {
235
- billingAddress: RequestBillingAddress
236
- method: PaymentMethod
237
- paymentInstrument: RequestPaymentCardInstrument
238
- }
@@ -1,73 +0,0 @@
1
- import type { PaymentMethod, RequestBillingAddress } from './Request.ts'
2
-
3
- export interface ResponseBillingAddress extends RequestBillingAddress {
4
- hash?: string | null
5
- }
6
-
7
- /**
8
- * Main interface for API response encapsulating all relevant details.
9
- */
10
- export interface CreateTokenResponse {
11
- /** Hyperlinks to related API resources. */
12
- _links: Link[]
13
- /** Billing address associated with the payment token. */
14
- billingAddress: ResponseBillingAddress
15
- /** Card brand such as Visa or Mastercard. */
16
- brand: string
17
- /** An identifier for the browser data. */
18
- browserData: unknown | null
19
- /** Date and time when the token was created. */
20
- createdTime: string
21
- /** Expiration time of the token. */
22
- expirationTime: string | null
23
- /** Date and time when the token expired. */
24
- expiredTime: string | null
25
- /** An identifier for the fingerprint of the device used. */
26
- fingerprint: string | null
27
- /** An identifier of the token. */
28
- id: string
29
- /** Indicates if the token has been used. */
30
- isUsed: boolean
31
- /** The last four digits of the payment instrument. */
32
- last4: string
33
- /** Payment method such as 'payment-card'. */
34
- method: PaymentMethod
35
- /** Payment instrument details. */
36
- paymentInstrument: ResponsePaymentCardInstrument
37
- /** Metadata related to risk evaluation. */
38
- riskMetadata: unknown | null
39
- /** Date and time when the token was last updated. */
40
- updatedTime: string
41
- /** Usage time of the token. */
42
- usageTime: string | null
43
- /** Indicates if the token has already been used. */
44
- used: boolean
45
- /** Date and time when the token was first used. */
46
- usedTime: string | null
47
- }
48
-
49
- /**
50
- * Payment instrument details such as credit card information.
51
- */
52
- export interface ResponsePaymentCardInstrument {
53
- /** Bank identification number or issuer identification number of the card. */
54
- bin: string
55
- /** Card brand such as Visa or Mastercard. */
56
- brand: string
57
- /** Expiration month of the card. */
58
- expMonth: number
59
- /** Expiration year of the card. */
60
- expYear: number
61
- /** Last four digits of the card number. */
62
- last4: string
63
- }
64
-
65
- /**
66
- * Links structure for API navigation.
67
- */
68
- export interface Link {
69
- /** URL of the related resource. */
70
- href: string
71
- /** Relation type of the link. */
72
- rel: string
73
- }
@@ -1,2 +0,0 @@
1
- export * from './Request.ts'
2
- export * from './Response.ts'
package/src/Api/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './PaymentCardToken/index.ts'
package/src/Config.ts DELETED
@@ -1,18 +0,0 @@
1
- import { asSchema } from '@xyo-network/payload-model'
2
- import type { RebillyApiDomainSettings } from '@xyo-network/rebilly-payment-payload-plugin'
3
- import type { SentinelConfig } from '@xyo-network/sentinel-model'
4
-
5
- import { RebillyPaymentCardAuthorizationSentinelSchema } from './Schema.ts'
6
-
7
- export const RebillyPaymentCardAuthorizationSentinelConfigSchema = asSchema(`${RebillyPaymentCardAuthorizationSentinelSchema}.config`, true)
8
- export type RebillyPaymentCardAuthorizationSentinelConfigSchema = typeof RebillyPaymentCardAuthorizationSentinelConfigSchema
9
-
10
- /*
11
- * The Rebilly Payment Card Authorization Sentinel Config
12
- */
13
- export interface RebillyPaymentCardAuthorizationSentinelConfig extends SentinelConfig<{
14
- /**
15
- * The config schema
16
- */
17
- schema: RebillyPaymentCardAuthorizationSentinelConfigSchema
18
- }>, Partial<RebillyApiDomainSettings> {}
package/src/Params.ts DELETED
@@ -1,15 +0,0 @@
1
- import type { AnyConfigSchema } from '@xyo-network/module-model'
2
- import type { RebillyOrganizationSettings, RebillyPublishableApiSettings } from '@xyo-network/rebilly-payment-payload-plugin'
3
- import type { SentinelParams } from '@xyo-network/sentinel-model'
4
-
5
- import type { RebillyPaymentCardAuthorizationSentinelConfig } from './Config.ts'
6
-
7
- export type RebillyPaymentCardAuthorizationParams = Partial<RebillyPublishableApiSettings & RebillyOrganizationSettings>
8
-
9
- export interface RebillyPaymentCardAuthorizationSentinelParams<
10
- TConfig extends AnyConfigSchema<RebillyPaymentCardAuthorizationSentinelConfig> = AnyConfigSchema<RebillyPaymentCardAuthorizationSentinelConfig>,
11
- > extends SentinelParams<TConfig> {
12
- domain?: string
13
- organizationId?: string
14
- publishableApiKey?: string
15
- }
package/src/Schema.ts DELETED
@@ -1,4 +0,0 @@
1
- import { asSchema } from '@xyo-network/payload-model'
2
-
3
- export const RebillyPaymentCardAuthorizationSentinelSchema = asSchema('network.xyo.sentinel.payments.payment.instrument.card.authorization.rebilly', true)
4
- export type RebillyPaymentCardAuthorizationSentinelSchema = typeof RebillyPaymentCardAuthorizationSentinelSchema
package/src/Sentinel.ts DELETED
@@ -1,121 +0,0 @@
1
- import { assertEx, axiosJsonConfig } from '@xylabs/sdk-js'
2
- import type { Payload, WithSources } from '@xyo-network/payload-model'
3
- import { isBillingAddress, isPaymentCard } from '@xyo-network/payment-payload-plugins'
4
- import type { RebillyPaymentAuthorizationToken } from '@xyo-network/rebilly-payment-payload-plugin'
5
- import { RebillyPaymentAuthorizationTokenSchema } from '@xyo-network/rebilly-payment-payload-plugin'
6
- import { PayloadBuilder } from '@xyo-network/sdk-js'
7
- import { AbstractSentinel } from '@xyo-network/sentinel-abstract'
8
- import type { SentinelInstance, SentinelModuleEventData } from '@xyo-network/sentinel-model'
9
- import type { AxiosRequestConfig } from 'axios'
10
- import { Axios, HttpStatusCode } from 'axios'
11
-
12
- import type { CreateTokenResponse } from './Api/index.ts'
13
- import { RebillyPaymentCardAuthorizationSentinelConfigSchema } from './Config.ts'
14
- import type { RebillyPaymentCardAuthorizationSentinelParams } from './Params.ts'
15
- import { toTokenRequest } from './util/index.ts'
16
-
17
- const removePrefix = (str: string, prefix: string) => {
18
- const regex = new RegExp(`^${prefix}`)
19
- return str.replace(regex, '')
20
- }
21
-
22
- const moduleName = 'RebillyPaymentCardAuthorizationSentinel'
23
- export class RebillyPaymentCardAuthorizationSentinel<
24
- TParams extends RebillyPaymentCardAuthorizationSentinelParams = RebillyPaymentCardAuthorizationSentinelParams,
25
- TEventData extends SentinelModuleEventData<SentinelInstance<TParams>> = SentinelModuleEventData<SentinelInstance<TParams>>,
26
- > extends AbstractSentinel<TParams, TEventData> {
27
- static override readonly configSchemas = [RebillyPaymentCardAuthorizationSentinelConfigSchema]
28
- static override readonly defaultConfigSchema = RebillyPaymentCardAuthorizationSentinelConfigSchema
29
-
30
- protected _apiRoot: string | undefined = undefined
31
- protected _domain: string | undefined = undefined
32
- protected _headers: AxiosRequestConfig['headers'] | undefined = undefined
33
- protected _organizationId: string | undefined = undefined
34
- protected _publishableApiKey: string | undefined = undefined
35
- protected _tokenEndpoint: string | undefined = undefined
36
-
37
- /**
38
- * The Rebilly Organization API root endpoint
39
- */
40
- protected get apiRoot() {
41
- if (!this._apiRoot) this._apiRoot = `${this.domain}/organizations/${this.organizationId}`
42
- return this._apiRoot
43
- }
44
-
45
- /**
46
- * The Rebilly domain
47
- */
48
- protected get domain() {
49
- if (!this._domain) this._domain = assertEx(this.params.domain ?? this.config.domain, () => `${moduleName}: Missing domain in params/config`)
50
- return this._domain
51
- }
52
-
53
- /**
54
- * The headers to be included in the request for each request
55
- */
56
- protected get headers(): AxiosRequestConfig['headers'] {
57
- if (!this._headers) this._headers = { Authorization: this.publishableApiKey }
58
- return this._headers
59
- }
60
-
61
- /**
62
- * True if the environment is sandbox (testing), false otherwise
63
- */
64
- protected get isSandboxEnvironment(): boolean {
65
- return this.domain.includes('sandbox')
66
- }
67
-
68
- /**
69
- * The Rebilly organization ID
70
- */
71
- protected get organizationId() {
72
- if (!this._organizationId)
73
- this._organizationId = removePrefix(
74
- assertEx(this.params.organizationId, () => `${moduleName}: Missing organizationId in params`),
75
- 'org_',
76
- )
77
- return this._organizationId
78
- }
79
-
80
- /**
81
- * The Rebilly Publishable API key
82
- */
83
- protected get publishableApiKey(): string {
84
- if (!this._publishableApiKey)
85
- this._publishableApiKey = assertEx(this.params.publishableApiKey, () => `${moduleName}: Missing publishableApiKey in params`)
86
- return this._publishableApiKey
87
- }
88
-
89
- /**
90
- * The Rebilly Organization token creation endpoint
91
- */
92
- protected get tokenEndpoint() {
93
- if (!this._tokenEndpoint) this._tokenEndpoint = `${this.apiRoot}/tokens`
94
- return this._tokenEndpoint
95
- }
96
-
97
- override async reportHandler(payloads?: Payload[]): Promise<Payload[]> {
98
- await this.started('throw')
99
- const results: WithSources<RebillyPaymentAuthorizationToken>[] = []
100
- // Verify necessary inputs and if nothing meets our criteria, bail early
101
- if (!payloads || payloads.length === 0) return results
102
- const paymentCard = payloads?.find(isPaymentCard)
103
- if (!paymentCard) return results
104
- const billingAddress = payloads?.find(isBillingAddress)
105
- if (!billingAddress) return results
106
- const axios = new Axios(axiosJsonConfig({ headers: this.headers }))
107
- try {
108
- const data = toTokenRequest(paymentCard, billingAddress)
109
- const response = await axios.post<CreateTokenResponse>(this.tokenEndpoint, data)
110
- assertEx(response.status === HttpStatusCode.Created, () => `Failed to tokenize payment card: ${response.status}`)
111
- const { id } = response.data
112
- const $sources = await PayloadBuilder.dataHashes([paymentCard, billingAddress])
113
- results.push({
114
- id, schema: RebillyPaymentAuthorizationTokenSchema, $sources,
115
- })
116
- } catch (error) {
117
- this.logger?.error?.(`${moduleName}: Error creating payment token: ${error}`)
118
- }
119
- return results
120
- }
121
- }
package/src/index.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './Config.ts'
2
- export * from './Params.ts'
3
- export * from './Schema.ts'
4
- export * from './Sentinel.ts'
package/src/util/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './toTokenRequest.ts'
@@ -1,28 +0,0 @@
1
- import type { BillingAddress, PaymentCard } from '@xyo-network/payment-payload-plugins'
2
-
3
- import type { CreatePaymentTokenRequest } from '../Api/index.ts'
4
-
5
- /**
6
- * Converts a payment card and billing address to a token request
7
- * @param paymentCard The payment card
8
- * @param billingAddress The billing address
9
- * @returns The token request
10
- */
11
- export const toTokenRequest = (paymentCard: PaymentCard, billingAddress: BillingAddress): CreatePaymentTokenRequest => {
12
- const {
13
- cvv, expMonth, expYear, cardNumber,
14
- } = paymentCard
15
- // We are destructuring all but the schema and passing it along to the billingAddress. This
16
- // is to allow for missing fields to be omitted rather than set to undefined and for any new fields
17
- // that might be added later to be automatically picked up on. It is fine to pass this along since
18
- // the user is supplying this data about themselves.
19
-
20
- const { schema: _, ...fields } = billingAddress
21
- return {
22
- billingAddress: { ...fields },
23
- method: 'payment-card',
24
- paymentInstrument: {
25
- cvv, expMonth, expYear, pan: cardNumber,
26
- },
27
- }
28
- }