@genesis-tech/genesispay-seller 0.13.1 → 0.13.2
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/CHANGELOG.md +10 -0
- package/dist/checkout-return.d.ts +41 -0
- package/dist/checkout-return.d.ts.map +1 -0
- package/dist/checkout-return.js +67 -0
- package/dist/checkout-return.js.map +1 -0
- package/dist/client.d.ts +283 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +629 -0
- package/dist/client.js.map +1 -0
- package/dist/customers.d.ts +41 -0
- package/dist/customers.d.ts.map +1 -0
- package/dist/customers.js +76 -0
- package/dist/customers.js.map +1 -0
- package/dist/entitlements.d.ts +19 -0
- package/dist/entitlements.d.ts.map +1 -0
- package/dist/entitlements.js +30 -0
- package/dist/entitlements.js.map +1 -0
- package/dist/errors.d.ts +63 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +162 -0
- package/dist/errors.js.map +1 -0
- package/dist/genesispay-settlement.d.ts +30 -0
- package/dist/genesispay-settlement.d.ts.map +1 -0
- package/dist/genesispay-settlement.js +103 -0
- package/dist/genesispay-settlement.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/invoices.d.ts +80 -0
- package/dist/invoices.d.ts.map +1 -0
- package/dist/invoices.js +133 -0
- package/dist/invoices.js.map +1 -0
- package/dist/mandate-gate.d.ts +49 -0
- package/dist/mandate-gate.d.ts.map +1 -0
- package/dist/mandate-gate.js +109 -0
- package/dist/mandate-gate.js.map +1 -0
- package/dist/mandates.d.ts +172 -0
- package/dist/mandates.d.ts.map +1 -0
- package/dist/mandates.js +213 -0
- package/dist/mandates.js.map +1 -0
- package/dist/networks.d.ts +10 -0
- package/dist/networks.d.ts.map +1 -0
- package/dist/networks.js +22 -0
- package/dist/networks.js.map +1 -0
- package/dist/payment-gate.d.ts +67 -0
- package/dist/payment-gate.d.ts.map +1 -0
- package/dist/payment-gate.js +106 -0
- package/dist/payment-gate.js.map +1 -0
- package/dist/plans.d.ts +68 -0
- package/dist/plans.d.ts.map +1 -0
- package/dist/plans.js +127 -0
- package/dist/plans.js.map +1 -0
- package/dist/products.d.ts +146 -0
- package/dist/products.d.ts.map +1 -0
- package/dist/products.js +295 -0
- package/dist/products.js.map +1 -0
- package/dist/resource.d.ts +47 -0
- package/dist/resource.d.ts.map +1 -0
- package/dist/resource.js +71 -0
- package/dist/resource.js.map +1 -0
- package/dist/usdc-amount.d.ts +7 -0
- package/dist/usdc-amount.d.ts.map +1 -0
- package/dist/usdc-amount.js +21 -0
- package/dist/usdc-amount.js.map +1 -0
- package/dist/webhooks.d.ts +277 -0
- package/dist/webhooks.d.ts.map +1 -0
- package/dist/webhooks.js +224 -0
- package/dist/webhooks.js.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type GenesisPayRequest } from "./resource.js";
|
|
2
|
+
export type Customer = {
|
|
3
|
+
id: string;
|
|
4
|
+
publicId: string;
|
|
5
|
+
name: string;
|
|
6
|
+
email: string;
|
|
7
|
+
companyName: string | null;
|
|
8
|
+
addressLine1: string | null;
|
|
9
|
+
addressLine2: string | null;
|
|
10
|
+
city: string | null;
|
|
11
|
+
postalCode: string | null;
|
|
12
|
+
countryCode: string | null;
|
|
13
|
+
taxId: string | null;
|
|
14
|
+
metadata: Record<string, string> | null;
|
|
15
|
+
createdAt: string;
|
|
16
|
+
updatedAt: string;
|
|
17
|
+
archivedAt: string | null;
|
|
18
|
+
};
|
|
19
|
+
export type CustomerCreateInput = {
|
|
20
|
+
name: string;
|
|
21
|
+
email: string;
|
|
22
|
+
companyName?: string;
|
|
23
|
+
addressLine1?: string;
|
|
24
|
+
addressLine2?: string;
|
|
25
|
+
city?: string;
|
|
26
|
+
postalCode?: string;
|
|
27
|
+
countryCode?: string;
|
|
28
|
+
taxId?: string;
|
|
29
|
+
metadata?: Record<string, string>;
|
|
30
|
+
};
|
|
31
|
+
export type CustomerUpdateInput = Partial<CustomerCreateInput>;
|
|
32
|
+
export interface CustomersResource {
|
|
33
|
+
create(input: CustomerCreateInput): Promise<Customer>;
|
|
34
|
+
list(): Promise<Customer[]>;
|
|
35
|
+
retrieve(publicId: string): Promise<Customer>;
|
|
36
|
+
update(publicId: string, input: CustomerUpdateInput): Promise<Customer>;
|
|
37
|
+
archive(publicId: string): Promise<Customer>;
|
|
38
|
+
}
|
|
39
|
+
export declare function createCustomersResource(request: GenesisPayRequest): CustomersResource;
|
|
40
|
+
export declare function toCustomer(raw: Record<string, unknown>): Customer;
|
|
41
|
+
//# sourceMappingURL=customers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customers.d.ts","sourceRoot":"","sources":["../src/customers.ts"],"names":[],"mappings":"AAGA,OAAO,EAKL,KAAK,iBAAiB,EACvB,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAE/D,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACtD,IAAI,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9C,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxE,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC9C;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,iBAAiB,GAAG,iBAAiB,CAoDrF;AAmCD,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,QAAQ,CAkBjE"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// `genesispay.customers.*` — reusable billing contacts over `/api/v1/customers`.
|
|
2
|
+
import { GenesisPayConfigError } from "./errors.js";
|
|
3
|
+
import { asRecord, optionalMetadata, optionalString, requiredString, } from "./resource.js";
|
|
4
|
+
export function createCustomersResource(request) {
|
|
5
|
+
return {
|
|
6
|
+
create: async (input) => customerRequest(request, "POST", "/api/v1/customers", input, "create a customer"),
|
|
7
|
+
list: async () => {
|
|
8
|
+
const body = await request({
|
|
9
|
+
path: "/api/v1/customers",
|
|
10
|
+
operation: "GET /api/v1/customers",
|
|
11
|
+
action: "list customers",
|
|
12
|
+
});
|
|
13
|
+
const rows = asRecord(body)?.customers;
|
|
14
|
+
if (!Array.isArray(rows)) {
|
|
15
|
+
throw new GenesisPayConfigError(`GenesisPay GET /api/v1/customers returned no customers array: ${JSON.stringify(body)}`);
|
|
16
|
+
}
|
|
17
|
+
return rows
|
|
18
|
+
.map(asRecord)
|
|
19
|
+
.filter((row) => Boolean(row?.publicId))
|
|
20
|
+
.map(toCustomer);
|
|
21
|
+
},
|
|
22
|
+
retrieve: async (publicId) => {
|
|
23
|
+
const id = requirePublicId(publicId, "customers.retrieve");
|
|
24
|
+
return customerRequest(request, "GET", `/api/v1/customers/${encodeURIComponent(id)}`, undefined, `retrieve customer "${id}"`);
|
|
25
|
+
},
|
|
26
|
+
update: async (publicId, input) => {
|
|
27
|
+
const id = requirePublicId(publicId, "customers.update");
|
|
28
|
+
return customerRequest(request, "PATCH", `/api/v1/customers/${encodeURIComponent(id)}`, input, `update customer "${id}"`);
|
|
29
|
+
},
|
|
30
|
+
archive: async (publicId) => {
|
|
31
|
+
const id = requirePublicId(publicId, "customers.archive");
|
|
32
|
+
return customerRequest(request, "POST", `/api/v1/customers/${encodeURIComponent(id)}/archive`, undefined, `archive customer "${id}"`);
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
async function customerRequest(request, method, path, body, action) {
|
|
37
|
+
const response = await request({
|
|
38
|
+
method,
|
|
39
|
+
path,
|
|
40
|
+
operation: `${method} ${path}`,
|
|
41
|
+
action,
|
|
42
|
+
...(body === undefined ? {} : { body }),
|
|
43
|
+
});
|
|
44
|
+
const raw = asRecord(asRecord(response)?.customer);
|
|
45
|
+
if (!raw?.publicId) {
|
|
46
|
+
throw new GenesisPayConfigError(`GenesisPay ${method} ${path} returned no customer: ${JSON.stringify(response)}`);
|
|
47
|
+
}
|
|
48
|
+
return toCustomer(raw);
|
|
49
|
+
}
|
|
50
|
+
function requirePublicId(publicId, method) {
|
|
51
|
+
const id = publicId?.trim();
|
|
52
|
+
if (!id) {
|
|
53
|
+
throw new GenesisPayConfigError(`${method}(publicId) requires the publicId returned by customers.create().`);
|
|
54
|
+
}
|
|
55
|
+
return id;
|
|
56
|
+
}
|
|
57
|
+
export function toCustomer(raw) {
|
|
58
|
+
return {
|
|
59
|
+
id: requiredString(raw.id),
|
|
60
|
+
publicId: requiredString(raw.publicId),
|
|
61
|
+
name: requiredString(raw.name),
|
|
62
|
+
email: requiredString(raw.email),
|
|
63
|
+
companyName: optionalString(raw.companyName),
|
|
64
|
+
addressLine1: optionalString(raw.addressLine1),
|
|
65
|
+
addressLine2: optionalString(raw.addressLine2),
|
|
66
|
+
city: optionalString(raw.city),
|
|
67
|
+
postalCode: optionalString(raw.postalCode),
|
|
68
|
+
countryCode: optionalString(raw.countryCode),
|
|
69
|
+
taxId: optionalString(raw.taxId),
|
|
70
|
+
metadata: optionalMetadata(raw.metadata),
|
|
71
|
+
createdAt: requiredString(raw.createdAt),
|
|
72
|
+
updatedAt: requiredString(raw.updatedAt),
|
|
73
|
+
archivedAt: optionalString(raw.archivedAt),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=customers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customers.js","sourceRoot":"","sources":["../src/customers.ts"],"names":[],"mappings":"AAAA,iFAAiF;AAEjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,cAAc,GAEf,MAAM,eAAe,CAAC;AA2CvB,MAAM,UAAU,uBAAuB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CAAC;IACJ,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,GAA4B;IACrD,OAAO;QACL,EAAE,EAAE,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC;QACtC,IAAI,EAAE,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC;QAC9B,KAAK,EAAE,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC;QAChC,WAAW,EAAE,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC;QAC5C,YAAY,EAAE,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC;QAC9C,YAAY,EAAE,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC;QAC9C,IAAI,EAAE,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC;QAC9B,UAAU,EAAE,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC;QAC1C,WAAW,EAAE,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC;QAC5C,KAAK,EAAE,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC;QAChC,QAAQ,EAAE,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC;QACxC,SAAS,EAAE,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC;QACxC,SAAS,EAAE,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC;QACxC,UAAU,EAAE,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC;KAC3C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type GenesisPayRequest } from "./resource.js";
|
|
2
|
+
export type VerifiedEntitlement = {
|
|
3
|
+
valid: boolean;
|
|
4
|
+
entitlement: {
|
|
5
|
+
publicId: string;
|
|
6
|
+
productId: string;
|
|
7
|
+
sku: string | null;
|
|
8
|
+
paymentAttemptId: string;
|
|
9
|
+
simulated: boolean;
|
|
10
|
+
expiresAt: string;
|
|
11
|
+
redemptionCount: number;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export interface EntitlementsResource {
|
|
15
|
+
/** Seller-scoped hard check for a redirect entitlement. */
|
|
16
|
+
verify(entitlementId: string): Promise<VerifiedEntitlement>;
|
|
17
|
+
}
|
|
18
|
+
export declare function createEntitlementsResource(request: GenesisPayRequest): EntitlementsResource;
|
|
19
|
+
//# sourceMappingURL=entitlements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlements.d.ts","sourceRoot":"","sources":["../src/entitlements.ts"],"names":[],"mappings":"AACA,OAAO,EAA4C,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEjG,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,EAAE;QACX,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;QACnB,gBAAgB,EAAE,MAAM,CAAC;QACzB,SAAS,EAAE,OAAO,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;CACH,CAAC;AAEF,MAAM,WAAW,oBAAoB;IACnC,2DAA2D;IAC3D,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CAC7D;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,iBAAiB,GAAG,oBAAoB,CAuB3F"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { GenesisPayConfigError } from "./errors.js";
|
|
2
|
+
import { asRecord, optionalString, requiredString } from "./resource.js";
|
|
3
|
+
export function createEntitlementsResource(request) {
|
|
4
|
+
return {
|
|
5
|
+
async verify(entitlementId) {
|
|
6
|
+
const id = entitlementId?.trim();
|
|
7
|
+
if (!id?.startsWith("ent_"))
|
|
8
|
+
throw new GenesisPayConfigError("entitlements.verify requires an ent_… id.");
|
|
9
|
+
const body = await request({
|
|
10
|
+
path: `/api/v1/entitlements/verify?entitlement=${encodeURIComponent(id)}`,
|
|
11
|
+
operation: "GET /api/v1/entitlements/verify",
|
|
12
|
+
action: `verify entitlement "${id}"`,
|
|
13
|
+
notFoundMessage: "The entitlement does not exist or does not belong to this seller.",
|
|
14
|
+
});
|
|
15
|
+
const root = asRecord(body);
|
|
16
|
+
const raw = asRecord(root?.entitlement);
|
|
17
|
+
if (!raw)
|
|
18
|
+
throw new GenesisPayConfigError("GenesisPay entitlement verification returned no entitlement.");
|
|
19
|
+
return {
|
|
20
|
+
valid: root?.valid === true,
|
|
21
|
+
entitlement: {
|
|
22
|
+
publicId: requiredString(raw.publicId), productId: requiredString(raw.productId), sku: optionalString(raw.sku),
|
|
23
|
+
paymentAttemptId: requiredString(raw.paymentAttemptId), simulated: raw.simulated === true,
|
|
24
|
+
expiresAt: requiredString(raw.expiresAt), redemptionCount: typeof raw.redemptionCount === "number" ? raw.redemptionCount : 0,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=entitlements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlements.js","sourceRoot":"","sources":["../src/entitlements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAA0B,MAAM,eAAe,CAAC;AAoBjG,MAAM,UAAU,0BAA0B,CAAC,OAA0B;IACnE,OAAO;QACL,KAAK,CAAC,MAAM,CAAC,aAAa;YACxB,MAAM,EAAE,GAAG,aAAa,EAAE,IAAI,EAAE,CAAC;YACjC,IAAI,CAAC,EAAE,EAAE,UAAU,CAAC,MAAM,CAAC;gBAAE,MAAM,IAAI,qBAAqB,CAAC,2CAA2C,CAAC,CAAC;YAC1G,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC;gBACzB,IAAI,EAAE,2CAA2C,kBAAkB,CAAC,EAAE,CAAC,EAAE;gBACzE,SAAS,EAAE,iCAAiC;gBAC5C,MAAM,EAAE,uBAAuB,EAAE,GAAG;gBACpC,eAAe,EAAE,mEAAmE;aACrF,CAAC,CAAC;YACH,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;YAAC,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;YACrE,IAAI,CAAC,GAAG;gBAAE,MAAM,IAAI,qBAAqB,CAAC,8DAA8D,CAAC,CAAC;YAC1G,OAAO;gBACL,KAAK,EAAE,IAAI,EAAE,KAAK,KAAK,IAAI;gBAC3B,WAAW,EAAE;oBACX,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC;oBAC9G,gBAAgB,EAAE,cAAc,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,KAAK,IAAI;oBACzF,SAAS,EAAE,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,eAAe,EAAE,OAAO,GAAG,CAAC,eAAe,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;iBAC7H;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** Missing/invalid key, unresolvable prod URL, or unreachable backend. */
|
|
2
|
+
export declare class GenesisPayConfigError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* The requested resource does not exist (HTTP 404). Kept separate from
|
|
7
|
+
* `GenesisPayConfigError` on purpose: polling `checkout.retrieve()` for an unknown
|
|
8
|
+
* publicId is an ordinary application case and must stay distinguishable from
|
|
9
|
+
* "the key is broken / the backend is unreachable".
|
|
10
|
+
*/
|
|
11
|
+
export declare class GenesisPayNotFoundError extends Error {
|
|
12
|
+
constructor(message: string);
|
|
13
|
+
}
|
|
14
|
+
/** Asset-integrity, mode↔network, or expectedPayTo-pin mismatch — a money-safety stop. */
|
|
15
|
+
export declare class GenesisPayNetworkSafetyError extends Error {
|
|
16
|
+
constructor(message: string);
|
|
17
|
+
}
|
|
18
|
+
/** One rejected field, as the API reports it. `path` is dot-joined ("metadata.orderId"). */
|
|
19
|
+
export type GenesisPayValidationIssue = {
|
|
20
|
+
path: string;
|
|
21
|
+
message: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* The request was well-formed but the input was rejected — HTTP 422 for a body,
|
|
25
|
+
* or HTTP 400 with field `issues` for a query string.
|
|
26
|
+
*
|
|
27
|
+
* `issues` is the server's structured list — the whole point of the class: 21
|
|
28
|
+
* metadata keys and a malformed wallet must not look the same to a caller that
|
|
29
|
+
* wants to surface the offending field back to its own user.
|
|
30
|
+
*/
|
|
31
|
+
export declare class GenesisPayValidationError extends Error {
|
|
32
|
+
readonly issues: GenesisPayValidationIssue[];
|
|
33
|
+
constructor(message: string, issues?: GenesisPayValidationIssue[]);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The API key exceeded its rate limit (HTTP 429).
|
|
37
|
+
*
|
|
38
|
+
* `retryAfterSeconds` mirrors the server's `Retry-After` header. It is `null`
|
|
39
|
+
* when the header is missing or unparseable — never a guessed default, because
|
|
40
|
+
* a caller sleeping on a made-up number is worse than one that backs off with
|
|
41
|
+
* its own policy.
|
|
42
|
+
*/
|
|
43
|
+
export declare class GenesisPayRateLimitError extends Error {
|
|
44
|
+
readonly retryAfterSeconds: number | null;
|
|
45
|
+
constructor(message: string, retryAfterSeconds: number | null);
|
|
46
|
+
}
|
|
47
|
+
export type ThrowForErrorResponseOptions = {
|
|
48
|
+
/** Operation label used in messages, e.g. `POST /api/v1/links`. */
|
|
49
|
+
operation: string;
|
|
50
|
+
/** Replaces the generic 404 message with a case-specific hint. */
|
|
51
|
+
notFoundMessage?: string;
|
|
52
|
+
/** Appended to the message — a next step for the caller, not error detail. */
|
|
53
|
+
hint?: string;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Maps a non-OK response onto the right error class and throws it.
|
|
57
|
+
*
|
|
58
|
+
* Consumes the response body exactly once (as text, then optimistically as
|
|
59
|
+
* JSON) so a non-JSON error page still ends up in the message instead of
|
|
60
|
+
* blowing up the mapper.
|
|
61
|
+
*/
|
|
62
|
+
export declare function throwForErrorResponse(response: Response, options: ThrowForErrorResponseOptions): Promise<never>;
|
|
63
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AASA,0EAA0E;AAC1E,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;GAKG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,OAAO,EAAE,MAAM;CAI5B;AAED,0FAA0F;AAC1F,qBAAa,4BAA6B,SAAQ,KAAK;gBACzC,OAAO,EAAE,MAAM;CAI5B;AAED,4FAA4F;AAC5F,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;;;GAOG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,QAAQ,CAAC,MAAM,EAAE,yBAAyB,EAAE,CAAC;gBAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,GAAE,yBAAyB,EAAO;CAKtE;AAED;;;;;;;GAOG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;gBAE9B,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,IAAI;CAK9D;AAED,MAAM,MAAM,4BAA4B,GAAG;IACzC,mEAAmE;IACnE,SAAS,EAAE,MAAM,CAAC;IAClB,kEAAkE;IAClE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,8EAA8E;IAC9E,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAUF;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,KAAK,CAAC,CA4ChB"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// Typed errors for every GenesisPay HTTP call.
|
|
2
|
+
//
|
|
3
|
+
// One rule, one place: `throwForErrorResponse` is the single mapper from a
|
|
4
|
+
// non-OK `Response` to an error class, so every method (checkout today, plans
|
|
5
|
+
// and mandates tomorrow) fails the same way. A method that hand-rolls its own
|
|
6
|
+
// `throw new GenesisPayConfigError(...)` for a non-OK status is a bug — 422 and
|
|
7
|
+
// 429 carry information (which field is wrong, how long to wait) that a generic
|
|
8
|
+
// config error throws away.
|
|
9
|
+
/** Missing/invalid key, unresolvable prod URL, or unreachable backend. */
|
|
10
|
+
export class GenesisPayConfigError extends Error {
|
|
11
|
+
constructor(message) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = "GenesisPayConfigError";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The requested resource does not exist (HTTP 404). Kept separate from
|
|
18
|
+
* `GenesisPayConfigError` on purpose: polling `checkout.retrieve()` for an unknown
|
|
19
|
+
* publicId is an ordinary application case and must stay distinguishable from
|
|
20
|
+
* "the key is broken / the backend is unreachable".
|
|
21
|
+
*/
|
|
22
|
+
export class GenesisPayNotFoundError extends Error {
|
|
23
|
+
constructor(message) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.name = "GenesisPayNotFoundError";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** Asset-integrity, mode↔network, or expectedPayTo-pin mismatch — a money-safety stop. */
|
|
29
|
+
export class GenesisPayNetworkSafetyError extends Error {
|
|
30
|
+
constructor(message) {
|
|
31
|
+
super(message);
|
|
32
|
+
this.name = "GenesisPayNetworkSafetyError";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The request was well-formed but the input was rejected — HTTP 422 for a body,
|
|
37
|
+
* or HTTP 400 with field `issues` for a query string.
|
|
38
|
+
*
|
|
39
|
+
* `issues` is the server's structured list — the whole point of the class: 21
|
|
40
|
+
* metadata keys and a malformed wallet must not look the same to a caller that
|
|
41
|
+
* wants to surface the offending field back to its own user.
|
|
42
|
+
*/
|
|
43
|
+
export class GenesisPayValidationError extends Error {
|
|
44
|
+
issues;
|
|
45
|
+
constructor(message, issues = []) {
|
|
46
|
+
super(message);
|
|
47
|
+
this.name = "GenesisPayValidationError";
|
|
48
|
+
this.issues = issues;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The API key exceeded its rate limit (HTTP 429).
|
|
53
|
+
*
|
|
54
|
+
* `retryAfterSeconds` mirrors the server's `Retry-After` header. It is `null`
|
|
55
|
+
* when the header is missing or unparseable — never a guessed default, because
|
|
56
|
+
* a caller sleeping on a made-up number is worse than one that backs off with
|
|
57
|
+
* its own policy.
|
|
58
|
+
*/
|
|
59
|
+
export class GenesisPayRateLimitError extends Error {
|
|
60
|
+
retryAfterSeconds;
|
|
61
|
+
constructor(message, retryAfterSeconds) {
|
|
62
|
+
super(message);
|
|
63
|
+
this.name = "GenesisPayRateLimitError";
|
|
64
|
+
this.retryAfterSeconds = retryAfterSeconds;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Maps a non-OK response onto the right error class and throws it.
|
|
69
|
+
*
|
|
70
|
+
* Consumes the response body exactly once (as text, then optimistically as
|
|
71
|
+
* JSON) so a non-JSON error page still ends up in the message instead of
|
|
72
|
+
* blowing up the mapper.
|
|
73
|
+
*/
|
|
74
|
+
export async function throwForErrorResponse(response, options) {
|
|
75
|
+
const body = await readErrorBody(response);
|
|
76
|
+
const detail = body.message ?? body.text;
|
|
77
|
+
const suffix = detail ? `: ${detail}` : "";
|
|
78
|
+
const hint = options.hint ? ` ${options.hint}` : "";
|
|
79
|
+
if (response.status === 404) {
|
|
80
|
+
throw new GenesisPayNotFoundError(options.notFoundMessage ??
|
|
81
|
+
`GenesisPay ${options.operation} returned 404 (not found)${suffix}${hint}`);
|
|
82
|
+
}
|
|
83
|
+
// 422 is a rejected *body*; 400 with `issues[]` is a rejected *query string*
|
|
84
|
+
// (`GET /api/v1/mandates` answers that way). Both mean "your input was wrong,
|
|
85
|
+
// here are the fields", so both become GenesisPayValidationError — a caller that
|
|
86
|
+
// wants to show the offending parameter must not have to branch on status.
|
|
87
|
+
//
|
|
88
|
+
// The `issues.length` gate is what keeps this narrow: a 400 without structured
|
|
89
|
+
// detail ("Request body must be JSON.", "startingAfter is not a mandate of this
|
|
90
|
+
// account.") stays a GenesisPayConfigError exactly as before, so nothing that was
|
|
91
|
+
// a config error yesterday changes class today.
|
|
92
|
+
if (response.status === 422 || (response.status === 400 && body.issues.length > 0)) {
|
|
93
|
+
throw new GenesisPayValidationError(`GenesisPay ${options.operation} rejected the input (${response.status})${suffix}`, body.issues);
|
|
94
|
+
}
|
|
95
|
+
if (response.status === 429) {
|
|
96
|
+
const retryAfterSeconds = parseRetryAfterSeconds(response.headers?.get("retry-after") ?? null);
|
|
97
|
+
const wait = retryAfterSeconds === null ? "" : ` Retry after ${retryAfterSeconds}s.`;
|
|
98
|
+
throw new GenesisPayRateLimitError(`GenesisPay ${options.operation} was rate limited (429)${suffix}${wait}`, retryAfterSeconds);
|
|
99
|
+
}
|
|
100
|
+
throw new GenesisPayConfigError(`GenesisPay ${options.operation} failed: ${response.status}${suffix}${hint}`.trim());
|
|
101
|
+
}
|
|
102
|
+
async function readErrorBody(response) {
|
|
103
|
+
const text = (await response.text().catch(() => "")).trim();
|
|
104
|
+
if (!text)
|
|
105
|
+
return { text: "", message: null, issues: [] };
|
|
106
|
+
let parsed;
|
|
107
|
+
try {
|
|
108
|
+
parsed = JSON.parse(text);
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
return { text, message: null, issues: [] };
|
|
112
|
+
}
|
|
113
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
114
|
+
return { text, message: null, issues: [] };
|
|
115
|
+
}
|
|
116
|
+
const record = parsed;
|
|
117
|
+
const message = typeof record.error === "string" && record.error
|
|
118
|
+
? record.error
|
|
119
|
+
: typeof record.message === "string" && record.message
|
|
120
|
+
? record.message
|
|
121
|
+
: null;
|
|
122
|
+
return { text, message, issues: toValidationIssues(record.issues) };
|
|
123
|
+
}
|
|
124
|
+
/** Tolerant: anything that is not a `{path, message}` object is dropped, never thrown on. */
|
|
125
|
+
function toValidationIssues(value) {
|
|
126
|
+
if (!Array.isArray(value))
|
|
127
|
+
return [];
|
|
128
|
+
const issues = [];
|
|
129
|
+
for (const entry of value) {
|
|
130
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry))
|
|
131
|
+
continue;
|
|
132
|
+
const issue = entry;
|
|
133
|
+
if (typeof issue.message !== "string")
|
|
134
|
+
continue;
|
|
135
|
+
issues.push({
|
|
136
|
+
path: typeof issue.path === "string" ? issue.path : "",
|
|
137
|
+
message: issue.message,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
return issues;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* `Retry-After` is either delta-seconds or an HTTP date (RFC 9110). GenesisPay
|
|
144
|
+
* sends seconds; the date form is parsed anyway so a proxy that rewrites the
|
|
145
|
+
* header does not degrade the value to `null`.
|
|
146
|
+
*/
|
|
147
|
+
function parseRetryAfterSeconds(header) {
|
|
148
|
+
if (!header)
|
|
149
|
+
return null;
|
|
150
|
+
const raw = header.trim();
|
|
151
|
+
if (!raw)
|
|
152
|
+
return null;
|
|
153
|
+
if (/^\d+$/.test(raw)) {
|
|
154
|
+
const seconds = Number(raw);
|
|
155
|
+
return Number.isSafeInteger(seconds) ? seconds : null;
|
|
156
|
+
}
|
|
157
|
+
const dateMs = Date.parse(raw);
|
|
158
|
+
if (Number.isNaN(dateMs))
|
|
159
|
+
return null;
|
|
160
|
+
return Math.max(0, Math.ceil((dateMs - Date.now()) / 1_000));
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,EAAE;AACF,2EAA2E;AAC3E,8EAA8E;AAC9E,8EAA8E;AAC9E,gFAAgF;AAChF,gFAAgF;AAChF,4BAA4B;AAE5B,0EAA0E;AAC1E,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF;AAED,0FAA0F;AAC1F,MAAM,OAAO,4BAA6B,SAAQ,KAAK;IACrD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;IAC7C,CAAC;CACF;AAQD;;;;;;;GAOG;AACH,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IACzC,MAAM,CAA8B;IAE7C,YAAY,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IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;YACtD,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,SAAS,sBAAsB,CAAC,MAAqB;IACnD,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IAC1B,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IAEtB,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC5B,OAAO,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IACxD,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IACtC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { VerifySettlement } from "./payment-gate.js";
|
|
2
|
+
/**
|
|
3
|
+
* Default GenesisPay app base URL — the public "development" facilitator. Used
|
|
4
|
+
* when `facilitatorBaseUrl` is omitted so integrators don't have to configure a
|
|
5
|
+
* URL in dev. Set `facilitatorBaseUrl` explicitly for production.
|
|
6
|
+
*
|
|
7
|
+
* The custom domain rather than the Railway-generated hostname: the generated
|
|
8
|
+
* form encodes the service name and breaks when the service is renamed.
|
|
9
|
+
*/
|
|
10
|
+
export declare const DEFAULT_FACILITATOR_BASE_URL = "https://dev.genesispay.finance";
|
|
11
|
+
export type GenesisPaySettlementOptions = {
|
|
12
|
+
/**
|
|
13
|
+
* Base URL of the GenesisPay app, e.g. "https://genesispay.example". Defaults to
|
|
14
|
+
* the public development facilitator (DEFAULT_FACILITATOR_BASE_URL) when
|
|
15
|
+
* omitted; set it explicitly in production.
|
|
16
|
+
*/
|
|
17
|
+
facilitatorBaseUrl?: string;
|
|
18
|
+
/** GenesisPay seller API key ("gp_sk_..."). */
|
|
19
|
+
apiKey: string;
|
|
20
|
+
/** Override for testing; defaults to global fetch. */
|
|
21
|
+
fetchFn?: typeof fetch;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Built-in settlement hook that forwards the PAYMENT-SIGNATURE payload to the
|
|
25
|
+
* GenesisPay facilitator (`POST /api/v1/facilitator/settle`). GenesisPay broadcasts
|
|
26
|
+
* the EIP-3009 authorization on-chain (or verifies a payer-provided txHash)
|
|
27
|
+
* and verifies the USDC transfer before reporting success.
|
|
28
|
+
*/
|
|
29
|
+
export declare function genesisPaySettlement(options: GenesisPaySettlementOptions): VerifySettlement;
|
|
30
|
+
//# sourceMappingURL=genesispay-settlement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genesispay-settlement.d.ts","sourceRoot":"","sources":["../src/genesispay-settlement.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGV,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;GAOG;AACH,eAAO,MAAM,4BAA4B,mCAAmC,CAAC;AAE7E,MAAM,MAAM,2BAA2B,GAAG;IACxC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;CACxB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,2BAA2B,GACnC,gBAAgB,CA6DlB"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { parseSettlementResponsePayload } from "@genesis-tech/genesispay-protocol";
|
|
2
|
+
/**
|
|
3
|
+
* Default GenesisPay app base URL — the public "development" facilitator. Used
|
|
4
|
+
* when `facilitatorBaseUrl` is omitted so integrators don't have to configure a
|
|
5
|
+
* URL in dev. Set `facilitatorBaseUrl` explicitly for production.
|
|
6
|
+
*
|
|
7
|
+
* The custom domain rather than the Railway-generated hostname: the generated
|
|
8
|
+
* form encodes the service name and breaks when the service is renamed.
|
|
9
|
+
*/
|
|
10
|
+
export const DEFAULT_FACILITATOR_BASE_URL = "https://dev.genesispay.finance";
|
|
11
|
+
/**
|
|
12
|
+
* Built-in settlement hook that forwards the PAYMENT-SIGNATURE payload to the
|
|
13
|
+
* GenesisPay facilitator (`POST /api/v1/facilitator/settle`). GenesisPay broadcasts
|
|
14
|
+
* the EIP-3009 authorization on-chain (or verifies a payer-provided txHash)
|
|
15
|
+
* and verifies the USDC transfer before reporting success.
|
|
16
|
+
*/
|
|
17
|
+
export function genesisPaySettlement(options) {
|
|
18
|
+
const settleUrl = buildSettleUrl(options.facilitatorBaseUrl?.trim() || DEFAULT_FACILITATOR_BASE_URL);
|
|
19
|
+
const apiKey = options.apiKey?.trim();
|
|
20
|
+
if (!apiKey) {
|
|
21
|
+
throw new Error("genesisPaySettlement requires a GenesisPay seller API key (gp_sk_...).");
|
|
22
|
+
}
|
|
23
|
+
const fetchFn = options.fetchFn ?? fetch;
|
|
24
|
+
return async (context) => {
|
|
25
|
+
const { requirement } = context;
|
|
26
|
+
let response;
|
|
27
|
+
try {
|
|
28
|
+
response = await fetchFn(settleUrl, {
|
|
29
|
+
method: "POST",
|
|
30
|
+
headers: {
|
|
31
|
+
"Content-Type": "application/json",
|
|
32
|
+
Authorization: `Bearer ${apiKey}`,
|
|
33
|
+
},
|
|
34
|
+
body: JSON.stringify({
|
|
35
|
+
paymentSignature: context.paymentSignatureHeader,
|
|
36
|
+
requirement: {
|
|
37
|
+
resource: requirement.resource,
|
|
38
|
+
network: requirement.network,
|
|
39
|
+
chainId: requirement.chainId,
|
|
40
|
+
assetAddress: requirement.assetAddress,
|
|
41
|
+
amountUsdcMinor: requirement.maxAmountRequired,
|
|
42
|
+
payTo: requirement.payTo,
|
|
43
|
+
description: requirement.description || undefined,
|
|
44
|
+
},
|
|
45
|
+
}),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
return {
|
|
50
|
+
ok: false,
|
|
51
|
+
errorReason: `Failed to reach the GenesisPay facilitator: ${describeError(error)}`,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const body = await readJsonBody(response);
|
|
55
|
+
const settlement = tryParseSettlement(body);
|
|
56
|
+
if (response.ok && settlement?.success) {
|
|
57
|
+
return { ok: true, settlement };
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
ok: false,
|
|
61
|
+
errorReason: settlement?.errorReason ??
|
|
62
|
+
readErrorMessage(body) ??
|
|
63
|
+
`GenesisPay facilitator settlement failed with status ${response.status}.`,
|
|
64
|
+
...(settlement ? { settlement } : {}),
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function buildSettleUrl(facilitatorBaseUrl) {
|
|
69
|
+
const trimmed = facilitatorBaseUrl?.trim().replace(/\/+$/, "");
|
|
70
|
+
if (!trimmed || !/^https?:\/\//.test(trimmed)) {
|
|
71
|
+
throw new Error(`Invalid facilitatorBaseUrl "${String(facilitatorBaseUrl)}": expected an http(s) URL like "https://genesispay.example".`);
|
|
72
|
+
}
|
|
73
|
+
return `${trimmed}/api/v1/facilitator/settle`;
|
|
74
|
+
}
|
|
75
|
+
async function readJsonBody(response) {
|
|
76
|
+
try {
|
|
77
|
+
return await response.json();
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function tryParseSettlement(body) {
|
|
84
|
+
try {
|
|
85
|
+
return parseSettlementResponsePayload(body);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function readErrorMessage(body) {
|
|
92
|
+
if (typeof body === "object" &&
|
|
93
|
+
body !== null &&
|
|
94
|
+
"error" in body &&
|
|
95
|
+
typeof body.error === "string") {
|
|
96
|
+
return body.error;
|
|
97
|
+
}
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
function describeError(error) {
|
|
101
|
+
return error instanceof Error ? error.message : "unknown error";
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=genesispay-settlement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genesispay-settlement.js","sourceRoot":"","sources":["../src/genesispay-settlement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AASnF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,gCAAgC,CAAC;AAe7E;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAoC;IAEpC,MAAM,SAAS,GAAG,cAAc,CAC9B,OAAO,CAAC,kBAAkB,EAAE,IAAI,EAAE,IAAI,4BAA4B,CACnE,CAAC;IACF,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC;IAEtC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,wEAAwE,CACzE,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC;IAEzC,OAAO,KAAK,EAAE,OAA0B,EAAmC,EAAE;QAC3E,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;QAEhC,IAAI,QAAkB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+
export { GenesisPay, type GenesisPayKeyMode, type GenesisPayClientOptions, type SellerConfig, type CheckoutAmountInput, type CheckoutCreateInput, type CheckoutLink, type CheckoutSession, type CheckoutAttempt, type CheckoutAttemptStatus, type SimulatePaymentOptions, type GateConfig, type ResolvingGate, } from "./client.js";
|
|
2
|
+
export { type SubscriptionPlan, type SubscriptionPlanStatus, type PlanCreateInput, type PlansResource, } from "./plans.js";
|
|
3
|
+
export { type Product, type ProductCreateInput, type ProductPaymentLink, type ProductDelivery, type ProductGate, type ProductGatePurchase, type ProductsResource, } from "./products.js";
|
|
4
|
+
export { type EntitlementsResource, type VerifiedEntitlement } from "./entitlements.js";
|
|
5
|
+
export { type Customer, type CustomerCreateInput, type CustomerUpdateInput, type CustomersResource, } from "./customers.js";
|
|
6
|
+
export { type Invoice, type InvoiceStatus, type InvoiceLineInput, type InvoiceDraftInput, type InvoiceEmailDelivery, type InvoicesResource, } from "./invoices.js";
|
|
7
|
+
export { type Mandate, type MandateKind, type MandateStatus, type MandateCreateInput, type MandateCreateResult, type MandateCharge, type MandateChargeInput, type MandateChargeStatus, type MandateListOptions, type MandateListPage, type PermitTypedData, type MandatesResource, } from "./mandates.js";
|
|
8
|
+
export { GenesisPayConfigError, GenesisPayNetworkSafetyError, GenesisPayNotFoundError, GenesisPayValidationError, GenesisPayRateLimitError, type GenesisPayValidationIssue, } from "./errors.js";
|
|
9
|
+
export { constructEvent, isKnownGenesisPayEventType, GENESISPAY_EVENT_TYPES, GenesisPaySignatureVerificationError, type GenesisPayEvent, type GenesisPayAnyEvent, type GenesisPayUnknownEvent, type GenesisPayEventType, type GenesisPayPaymentEvent, type GenesisPayMandateEvent, type GenesisPayAgentPaymentEvent, type GenesisPayPaymentEventData, type GenesisPayMandateEventData, type ConstructEventOptions, } from "./webhooks.js";
|
|
10
|
+
export { createPaymentGate, type PaymentGate, type PaymentGateConfig, type SettlementContext, type SettlementVerification, type VerifySettlement, type WrapOptions, } from "./payment-gate.js";
|
|
11
|
+
export { genesisPaySettlement, DEFAULT_FACILITATOR_BASE_URL, type GenesisPaySettlementOptions, } from "./genesispay-settlement.js";
|
|
12
|
+
export { resolvePaymentGateNetwork, type PaymentGateNetwork, type PaymentGateNetworkConfig, } from "./networks.js";
|
|
13
|
+
export { parseUsdcAmountToMinorUnits } from "./usdc-amount.js";
|
|
14
|
+
export { CHECKOUT_RETURN_LINK_ID_PARAM, CHECKOUT_RETURN_STATUS_PARAM, parseCheckoutReturnHint, type CheckoutReturnHint, } from "./checkout-return.js";
|
|
15
|
+
export { createMandateGate, MANDATE_HEADER, type MandateChargeOutcome, type MandateGate, type MandateGateOptions, } from "./mandate-gate.js";
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EACV,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,UAAU,EACf,KAAK,aAAa,GACnB,MAAM,aAAa,CAAC;AAMrB,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,aAAa,GACnB,MAAM,YAAY,CAAC;AAIpB,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,GACtB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExF,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,mBAA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vB,KAAK,wBAAwB,GAC9B,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAM/D,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAC5B,uBAAuB,EACvB,KAAK,kBAAkB,GACxB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,kBAAkB,GACxB,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// @genesis-tech/genesispay-seller — framework-agnostic x402 payment gate.
|
|
2
|
+
export { GenesisPay, } from "./client.js";
|
|
3
|
+
// Every SDK method throws from this set: 404 → NotFound, 422 (and 400 when the
|
|
4
|
+
// body carries structured `issues`) → Validation, 429 → RateLimit (with
|
|
5
|
+
// `retryAfterSeconds`), anything else → Config.
|
|
6
|
+
export { GenesisPayConfigError, GenesisPayNetworkSafetyError, GenesisPayNotFoundError, GenesisPayValidationError, GenesisPayRateLimitError, } from "./errors.js";
|
|
7
|
+
export { constructEvent, isKnownGenesisPayEventType, GENESISPAY_EVENT_TYPES, GenesisPaySignatureVerificationError, } from "./webhooks.js";
|
|
8
|
+
export { createPaymentGate, } from "./payment-gate.js";
|
|
9
|
+
export { genesisPaySettlement, DEFAULT_FACILITATOR_BASE_URL, } from "./genesispay-settlement.js";
|
|
10
|
+
export { resolvePaymentGateNetwork, } from "./networks.js";
|
|
11
|
+
export { parseUsdcAmountToMinorUnits } from "./usdc-amount.js";
|
|
12
|
+
// Checkout return parameters: the query-parameter names GenesisPay appends to a
|
|
13
|
+
// merchant's `returnUrl`, plus the typed hint parser that reads them back. The
|
|
14
|
+
// hint is a UI convenience, not proof of payment — verify with
|
|
15
|
+
// `checkout.retrieve(hint.linkId)` before acting on it.
|
|
16
|
+
export { CHECKOUT_RETURN_LINK_ID_PARAM, CHECKOUT_RETURN_STATUS_PARAM, parseCheckoutReturnHint, } from "./checkout-return.js";
|
|
17
|
+
export { createMandateGate, MANDATE_HEADER, } from "./mandate-gate.js";
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAE1E,OAAO,EACL,UAAU,GAaX,MAAM,aAAa,CAAC;AA0DrB,+EAA+E;AAC/E,wEAAwE;AACxE,gDAAgD;AAChD,OAAO,EACL,qBAAqB,EACrB,4BAA4B,EAC5B,uBAAuB,EACvB,yBAAyB,EACzB,wBAAwB,GAEzB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,cAAc,EACd,0BAA0B,EAC1B,sBAAsB,EACtB,oCAAoC,GAWrC,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,iBAAiB,GAOlB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,oBAAoB,EACpB,4BAA4B,GAE7B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,yBAAyB,GAG1B,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAE/D,gFAAgF;AAChF,+EAA+E;AAC/E,+DAA+D;AAC/D,wDAAwD;AACxD,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAC5B,uBAAuB,GAExB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,iBAAiB,EACjB,cAAc,GAIf,MAAM,mBAAmB,CAAC"}
|