@myzonerocks/pact 0.1.1 → 0.1.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/package.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "name": "@myzonerocks/pact",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "TypeScript SDK for the PACT payment abstraction protocol",
5
5
  "license": "Apache-2.0",
6
- "repository": { "type": "git", "url": "git+https://github.com/myzonerocks/pact.git", "directory": "sdk/ts" },
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/myzonerocks/pact.git",
9
+ "directory": "sdk/ts"
10
+ },
7
11
  "type": "module",
8
12
  "main": "./dist/src/index.js",
9
13
  "types": "./dist/src/index.d.ts",
@@ -33,7 +37,10 @@
33
37
  "import": "./dist/src/policy.js"
34
38
  }
35
39
  },
36
- "files": ["dist", "src"],
40
+ "files": [
41
+ "dist",
42
+ "src"
43
+ ],
37
44
  "scripts": {
38
45
  "build": "tsc -p tsconfig.json",
39
46
  "test": "vitest run",
@@ -75,6 +75,10 @@ export interface CreateIntentParams {
75
75
  destination: string;
76
76
  applicationFee?: number;
77
77
  capture?: Capture;
78
+ // methods pins the exact payment method types offered (e.g. card, cashapp, link);
79
+ // wallets like Apple Pay and Google Pay ride on "card". Empty falls back to the
80
+ // account's dynamic payment methods.
81
+ methods?: string[];
78
82
  metadata: Record<string, string>;
79
83
  }
80
84
 
@@ -110,6 +114,9 @@ export interface StripeConfig {
110
114
  // tolerance is the webhook timestamp tolerance in seconds; defaults to 300.
111
115
  tolerance?: number;
112
116
  ids: () => string;
117
+ // methods pins the payment method types offered on the card rail (e.g. card,
118
+ // cashapp, link). Empty offers the account's dynamic payment methods.
119
+ methods?: string[];
113
120
  }
114
121
 
115
122
  // StripeLeg collects card payments through Stripe. It exposes the wallets that
@@ -123,6 +130,7 @@ export class StripeLeg implements InteractivePayInLeg {
123
130
  private readonly clock: () => number;
124
131
  private readonly tolerance: number;
125
132
  private readonly ids: () => string;
133
+ private readonly methods: string[] | undefined;
126
134
 
127
135
  constructor(cfg: StripeConfig) {
128
136
  if (!cfg.webhookKey) {
@@ -135,6 +143,7 @@ export class StripeLeg implements InteractivePayInLeg {
135
143
  this.clock = cfg.clock ?? (() => 0);
136
144
  this.tolerance = cfg.tolerance ?? defaultToleranceSeconds;
137
145
  this.ids = cfg.ids;
146
+ this.methods = cfg.methods;
138
147
  }
139
148
 
140
149
  // payInCapabilities advertises the card rail and the wallets that fund through
@@ -184,6 +193,7 @@ export class StripeLeg implements InteractivePayInLeg {
184
193
  destination: deliverTo,
185
194
  applicationFee: minorToInteger(quote.fees),
186
195
  capture: Capture.OnConfirmation,
196
+ ...(this.methods ? { methods: this.methods } : {}),
187
197
  metadata: { [metadataIntentKey]: intentId },
188
198
  },
189
199
  idempotencyKey(intentId, "prepare"),
@@ -403,7 +413,13 @@ class HttpStripeApi implements StripeApi {
403
413
  if ((params.capture ?? Capture.Manual) === Capture.Manual) {
404
414
  form.set("capture_method", "manual");
405
415
  }
406
- form.set("automatic_payment_methods[enabled]", "true");
416
+ // Pinning the method types offers exactly those and nothing else; without a
417
+ // pin, dynamic payment methods surface whatever the dashboard has enabled.
418
+ if (params.methods && params.methods.length > 0) {
419
+ params.methods.forEach((m, i) => form.set(`payment_method_types[${i}]`, m));
420
+ } else {
421
+ form.set("automatic_payment_methods[enabled]", "true");
422
+ }
407
423
  if (params.destination) {
408
424
  form.set("transfer_data[destination]", params.destination);
409
425
  }