@alphawebai/hs-prism 0.1.0-rc.33 → 0.1.0-rc.35

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.
@@ -1,7 +1,7 @@
1
1
  export declare const ALPHAWEB_STRIPE_WEBHOOK_EVENTS: readonly ["charge.dispute.closed", "charge.dispute.created", "charge.dispute.funds_reinstated", "charge.dispute.funds_withdrawn", "charge.dispute.updated", "mandate.updated", "payment_intent.amount_capturable_updated", "payment_intent.canceled", "payment_intent.payment_failed", "payment_intent.processing", "payment_intent.requires_action", "payment_intent.succeeded", "payment_method.attached", "payment_method.automatically_updated", "payment_method.detached", "payment_method.updated", "refund.created", "refund.failed", "refund.updated", "setup_intent.canceled", "setup_intent.requires_action", "setup_intent.setup_failed", "setup_intent.succeeded"];
2
2
  export declare const ALPHAWEB_PAYPAL_WEBHOOK_EVENTS: readonly ["CHECKOUT.ORDER.APPROVED", "CHECKOUT.ORDER.COMPLETED", "CHECKOUT.ORDER.PROCESSED", "CHECKOUT.PAYMENT-APPROVAL.REVERSED", "CUSTOMER.DISPUTE.CREATED", "CUSTOMER.DISPUTE.RESOLVED", "CUSTOMER.DISPUTE.UPDATED", "PAYMENT.AUTHORIZATION.CREATED", "PAYMENT.AUTHORIZATION.VOIDED", "PAYMENT.CAPTURE.COMPLETED", "PAYMENT.CAPTURE.DECLINED", "PAYMENT.CAPTURE.PENDING", "PAYMENT.CAPTURE.REFUNDED", "PAYMENT.CAPTURE.REVERSED", "PAYMENT.REFUND.FAILED", "PAYMENT.REFUND.PENDING", "RISK.DISPUTE.CREATED", "VAULT.PAYMENT-TOKEN.CREATED", "VAULT.PAYMENT-TOKEN.DELETED", "VAULT.PAYMENT-TOKEN.DELETION-INITIATED"];
3
3
  export declare const ALPHAWEB_PRISM_COMPATIBILITY_MANIFEST: Readonly<{
4
- readonly release: "0.1.0-rc.33";
4
+ readonly release: "0.1.0-rc.35";
5
5
  readonly upstreamCommit: "b07af7d9dac271de729548e74217ddcf895c602b";
6
6
  readonly medusaRange: ">=2.17.2 <2.18.0";
7
7
  readonly stripeApiVersion: "2026-06-24.dahlia";
@@ -49,7 +49,7 @@ exports.ALPHAWEB_PAYPAL_WEBHOOK_EVENTS = Object.freeze([
49
49
  'VAULT.PAYMENT-TOKEN.DELETION-INITIATED',
50
50
  ]);
51
51
  exports.ALPHAWEB_PRISM_COMPATIBILITY_MANIFEST = Object.freeze({
52
- release: '0.1.0-rc.33',
52
+ release: '0.1.0-rc.35',
53
53
  upstreamCommit: 'b07af7d9dac271de729548e74217ddcf895c602b',
54
54
  medusaRange: '>=2.17.2 <2.18.0',
55
55
  stripeApiVersion: '2026-06-24.dahlia',
@@ -1,5 +1,5 @@
1
1
  import { types } from '../payments/generated/proto';
2
- import type { PrismAuthorizeApprovedPaymentInput, PrismCancelInput, PrismCaptureInput, PrismCreateWebhookEndpointInput, PrismDeleteWebhookEndpointInput, PrismDisputeResult, PrismEstablishReusableReferenceInput, PrismFindPaymentInput, PrismFindRefundInput, PrismMerchantOperation, PrismPayPalConnectorOptions, PrismPayPalConnectorV1, PrismPayPalRuntimeVerification, PrismPayPalRuntimeVerificationInput, PrismPaymentResult, PrismRefundInput, PrismRefundResult, PrismRetrieveDisputeInput, PrismRetrievePaymentInput, PrismRetrieveRefundInput, PrismRetrieveWebhookEndpointInput, PrismRetryPaymentInput, PrismReusableReferenceDerivation, PrismUpdateWebhookEndpointInput, PrismWebhookEndpoint, PrismWebhookEndpointCreated, PrismWebhookParseInput, PrismWebhookParseResult } from './types';
2
+ import type { PrismAuthorizeApprovedPaymentInput, PrismCancelInput, PrismCaptureInput, PrismCreateWebhookEndpointInput, PrismDeleteWebhookEndpointInput, PrismDisputeResult, PrismEstablishReusableReferenceInput, PrismFindPaymentInput, PrismFindRefundInput, PrismMerchantOperation, PrismPayPalConnectorOptions, PrismPayPalConnectorV1, PrismPayPalOrderLifecycle, PrismPayPalRuntimeVerification, PrismPayPalRuntimeVerificationInput, PrismPaymentResult, PrismRefundInput, PrismRefundResult, PrismRetrieveDisputeInput, PrismRetrieveOrderLifecycleInput, PrismRetrievePaymentInput, PrismRetrieveRefundInput, PrismRetrieveWebhookEndpointInput, PrismRetryPaymentInput, PrismReusableReferenceDerivation, PrismUpdateWebhookEndpointInput, PrismWebhookEndpoint, PrismWebhookEndpointCreated, PrismWebhookParseInput, PrismWebhookParseResult } from './types';
3
3
  interface MerchantAuthenticationPort {
4
4
  createServerAuthenticationToken(input: types.IMerchantAuthenticationServiceCreateServerAuthenticationTokenRequest): Promise<types.MerchantAuthenticationServiceCreateServerAuthenticationTokenResponse>;
5
5
  }
@@ -38,6 +38,7 @@ export declare class PrismPayPalConnector implements PrismPayPalConnectorV1 {
38
38
  authorizeApprovedPayment(input: PrismAuthorizeApprovedPaymentInput): Promise<PrismPaymentResult>;
39
39
  repeatPayment(input: PrismMerchantOperation): Promise<PrismPaymentResult>;
40
40
  retryPayment(input: PrismRetryPaymentInput): Promise<PrismPaymentResult>;
41
+ retrieveOrderLifecycle(input: PrismRetrieveOrderLifecycleInput): Promise<PrismPayPalOrderLifecycle>;
41
42
  retrievePayment(input: PrismRetrievePaymentInput): Promise<PrismPaymentResult>;
42
43
  establishReusableReference(input: PrismEstablishReusableReferenceInput): Promise<PrismReusableReferenceDerivation>;
43
44
  findPaymentsByMerchantOperation(_input: PrismFindPaymentInput): Promise<PrismPaymentResult[]>;
@@ -99,6 +99,41 @@ function operationMetadata(input) {
99
99
  function futureUseRequested(input) {
100
100
  return Boolean(input.futureUse) || input.metadata.alphaweb_setup_future_usage === 'off_session';
101
101
  }
102
+ const PAYPAL_BROWSER_CONTINUATION_MAX_URL_LENGTH = 2048;
103
+ function browserContinuationUrl(value, fieldName) {
104
+ const normalized = typeof value === 'string' ? value.trim() : '';
105
+ if (normalized.length < 1 || normalized.length > PAYPAL_BROWSER_CONTINUATION_MAX_URL_LENGTH) {
106
+ throw validationError(`PayPal ${fieldName} is invalid.`, 'PRISM_PAYPAL_BROWSER_CONTINUATION');
107
+ }
108
+ let parsed;
109
+ try {
110
+ parsed = new URL(normalized);
111
+ }
112
+ catch {
113
+ throw validationError(`PayPal ${fieldName} is invalid.`, 'PRISM_PAYPAL_BROWSER_CONTINUATION');
114
+ }
115
+ if (parsed.protocol !== 'https:' ||
116
+ !parsed.hostname ||
117
+ parsed.username.length > 0 ||
118
+ parsed.password.length > 0 ||
119
+ parsed.hash.length > 0) {
120
+ throw validationError(`PayPal ${fieldName} is invalid.`, 'PRISM_PAYPAL_BROWSER_CONTINUATION');
121
+ }
122
+ return parsed;
123
+ }
124
+ function browserContinuation(input) {
125
+ if (!futureUseRequested(input))
126
+ return undefined;
127
+ if (!input.browserContinuation) {
128
+ throw validationError('PayPal future-use checkout requires trusted return and cancel URLs.', 'PRISM_PAYPAL_BROWSER_CONTINUATION');
129
+ }
130
+ const returnUrl = browserContinuationUrl(input.browserContinuation.returnUrl, 'return URL');
131
+ const cancelUrl = browserContinuationUrl(input.browserContinuation.cancelUrl, 'cancel URL');
132
+ if (returnUrl.origin !== cancelUrl.origin) {
133
+ throw validationError('PayPal return and cancel URLs must use the same storefront origin.', 'PRISM_PAYPAL_BROWSER_CONTINUATION');
134
+ }
135
+ return { returnUrl: returnUrl.toString(), cancelUrl: cancelUrl.toString() };
136
+ }
102
137
  function futureUseMitCategoryFromIntent(futureUse) {
103
138
  if (futureUse?.recurringAgreement?.totalPayments !== null &&
104
139
  futureUse?.recurringAgreement?.totalPayments !== undefined) {
@@ -282,6 +317,34 @@ function paypalVaultStateFromOrder(payload, options, sourceConnectorPaymentId) {
282
317
  }
283
318
  return { status: 'absent' };
284
319
  }
320
+ const PAYPAL_ORDER_LIFECYCLE_STATUSES = new Set([
321
+ 'CREATED',
322
+ 'SAVED',
323
+ 'PAYER_ACTION_REQUIRED',
324
+ 'APPROVED',
325
+ 'VOIDED',
326
+ 'COMPLETED',
327
+ ]);
328
+ function orderLifecycleFrom(payload) {
329
+ const order = recordOf(payload);
330
+ const rawStatus = stringOf(order.status)?.toUpperCase();
331
+ const orderStatus = rawStatus && PAYPAL_ORDER_LIFECYCLE_STATUSES.has(rawStatus)
332
+ ? rawStatus
333
+ : 'UNKNOWN';
334
+ let hasAuthorization = false;
335
+ let hasCapture = false;
336
+ const purchaseUnits = Array.isArray(order.purchase_units) ? order.purchase_units : [];
337
+ for (const unit of purchaseUnits) {
338
+ const payments = recordOf(recordOf(unit).payments);
339
+ const authorizations = Array.isArray(payments.authorizations) ? payments.authorizations : [];
340
+ const captures = Array.isArray(payments.captures) ? payments.captures : [];
341
+ if (authorizations.some((entry) => stringOf(recordOf(entry).id)))
342
+ hasAuthorization = true;
343
+ if (captures.some((entry) => stringOf(recordOf(entry).id)))
344
+ hasCapture = true;
345
+ }
346
+ return { orderStatus, hasAuthorization, hasCapture };
347
+ }
285
348
  function supportsPurposes(reference, purposes) {
286
349
  const requested = new Set(purposes);
287
350
  return !((requested.has('post_purchase') && !reference.capabilities.includes('post_purchase')) ||
@@ -760,9 +823,10 @@ class PrismPayPalConnector {
760
823
  throw validationError('Interactive payment input is invalid.', 'PRISM_INTERACTIVE_INPUT');
761
824
  }
762
825
  try {
763
- const state = await this.connectorState();
764
826
  const setupFutureUsage = futureUseRequested(input);
765
827
  const recurringAgreement = recurringAgreementMessage(input);
828
+ const continuation = browserContinuation(input);
829
+ const state = await this.connectorState();
766
830
  const captureMethod = input.metadata.alphaweb_capture_method === 'manual'
767
831
  ? proto_1.types.CaptureMethod.MANUAL
768
832
  : proto_1.types.CaptureMethod.AUTOMATIC;
@@ -781,6 +845,7 @@ class PrismPayPalConnector {
781
845
  ? futureUseMitCategory(input)
782
846
  : proto_1.types.MitCategory.MIT_CATEGORY_UNSPECIFIED,
783
847
  ...(recurringAgreement ? { recurringAgreement } : {}),
848
+ ...(continuation ?? {}),
784
849
  });
785
850
  const orderId = stringOf(order.connectorOrderId);
786
851
  if (!orderId) {
@@ -905,6 +970,16 @@ class PrismPayPalConnector {
905
970
  this.assertOperation(input);
906
971
  return this.repeatPayment(input);
907
972
  }
973
+ async retrieveOrderLifecycle(input) {
974
+ assertIdentifier(input.connectorPaymentId, 'connectorPaymentId');
975
+ try {
976
+ const payload = await this.paypalRequest('GET', `/v2/checkout/orders/${encodeURIComponent(input.connectorPaymentId)}`);
977
+ return orderLifecycleFrom(payload);
978
+ }
979
+ catch (error) {
980
+ throw (0, error_1.normalizePrismError)(error);
981
+ }
982
+ }
908
983
  async retrievePayment(input) {
909
984
  assertIdentifier(input.operationId, 'operationId');
910
985
  assertIdentifier(input.connectorPaymentId, 'connectorPaymentId');
@@ -26,6 +26,10 @@ export interface PrismFutureUseIntent {
26
26
  purposes: [PrismFutureUsePurpose, ...PrismFutureUsePurpose[]];
27
27
  recurringAgreement?: PrismRecurringAgreement;
28
28
  }
29
+ export interface PrismBrowserContinuation {
30
+ returnUrl: string;
31
+ cancelUrl: string;
32
+ }
29
33
  export interface PrismReusablePaymentReference {
30
34
  version: 1;
31
35
  connector: PrismConnectorId;
@@ -72,6 +76,7 @@ export interface PrismMerchantOperation {
72
76
  customerReference?: string;
73
77
  reusableReference?: PrismReusablePaymentReference;
74
78
  futureUse?: PrismFutureUseIntent;
79
+ browserContinuation?: PrismBrowserContinuation;
75
80
  methodSelection: {
76
81
  kind: 'interactive_dynamic';
77
82
  paymentMethodConfigurationId?: string;
@@ -320,8 +325,18 @@ export interface PrismConnectorV1 {
320
325
  retrieveWebhookEndpoint(input: PrismRetrieveWebhookEndpointInput): Promise<PrismWebhookEndpoint>;
321
326
  }
322
327
  export type PrismStripeConnectorV1 = PrismConnectorV1;
328
+ export type PrismPayPalOrderLifecycleStatus = 'CREATED' | 'SAVED' | 'PAYER_ACTION_REQUIRED' | 'APPROVED' | 'VOIDED' | 'COMPLETED' | 'UNKNOWN';
329
+ export interface PrismPayPalOrderLifecycle {
330
+ orderStatus: PrismPayPalOrderLifecycleStatus;
331
+ hasAuthorization: boolean;
332
+ hasCapture: boolean;
333
+ }
334
+ export interface PrismRetrieveOrderLifecycleInput {
335
+ connectorPaymentId: string;
336
+ }
323
337
  export interface PrismPayPalConnectorV1 extends PrismConnectorV1 {
324
338
  authorizeApprovedPayment(input: PrismAuthorizeApprovedPaymentInput): Promise<PrismPaymentResult>;
339
+ retrieveOrderLifecycle?(input: PrismRetrieveOrderLifecycleInput): Promise<PrismPayPalOrderLifecycle>;
325
340
  }
326
341
  export interface PrismStripeConnectorOptions {
327
342
  environment: PrismEnvironment;
@@ -15152,6 +15152,15 @@ export namespace types {
15152
15152
  * details in its provider-owned buyer approval surface.
15153
15153
  */
15154
15154
  recurringAgreement?: (types.IRecurringAgreement|null);
15155
+
15156
+ /**
15157
+ * Provider-owned buyer continuation URLs for approval flows. Connectors that
15158
+ * require future-use approval must fail closed when either URL is absent.
15159
+ */
15160
+ returnUrl?: (string|null);
15161
+
15162
+ /** PaymentServiceCreateOrderRequest cancelUrl */
15163
+ cancelUrl?: (string|null);
15155
15164
  }
15156
15165
 
15157
15166
  /** Request message for creating an order */
@@ -15212,6 +15221,15 @@ export namespace types {
15212
15221
  */
15213
15222
  public recurringAgreement?: (types.IRecurringAgreement|null);
15214
15223
 
15224
+ /**
15225
+ * Provider-owned buyer continuation URLs for approval flows. Connectors that
15226
+ * require future-use approval must fail closed when either URL is absent.
15227
+ */
15228
+ public returnUrl?: (string|null);
15229
+
15230
+ /** PaymentServiceCreateOrderRequest cancelUrl. */
15231
+ public cancelUrl?: (string|null);
15232
+
15215
15233
  /**
15216
15234
  * Creates a new PaymentServiceCreateOrderRequest instance using the specified properties.
15217
15235
  * @param [properties] Properties to set
@@ -47737,6 +47737,9 @@ $root.types = (function() {
47737
47737
  * recurring. Connectors that don't require this distinction may ignore it.
47738
47738
  * @property {types.IRecurringAgreement|null} [recurringAgreement] Required for recurring agreements when a connector must present cadence
47739
47739
  * details in its provider-owned buyer approval surface.
47740
+ * @property {string|null} [returnUrl] Provider-owned buyer continuation URLs for approval flows. Connectors that
47741
+ * require future-use approval must fail closed when either URL is absent.
47742
+ * @property {string|null} [cancelUrl] PaymentServiceCreateOrderRequest cancelUrl
47740
47743
  */
47741
47744
 
47742
47745
  /**
@@ -47855,6 +47858,23 @@ $root.types = (function() {
47855
47858
  */
47856
47859
  PaymentServiceCreateOrderRequest.prototype.recurringAgreement = null;
47857
47860
 
47861
+ /**
47862
+ * Provider-owned buyer continuation URLs for approval flows. Connectors that
47863
+ * require future-use approval must fail closed when either URL is absent.
47864
+ * @member {string|null|undefined} returnUrl
47865
+ * @memberof types.PaymentServiceCreateOrderRequest
47866
+ * @instance
47867
+ */
47868
+ PaymentServiceCreateOrderRequest.prototype.returnUrl = null;
47869
+
47870
+ /**
47871
+ * PaymentServiceCreateOrderRequest cancelUrl.
47872
+ * @member {string|null|undefined} cancelUrl
47873
+ * @memberof types.PaymentServiceCreateOrderRequest
47874
+ * @instance
47875
+ */
47876
+ PaymentServiceCreateOrderRequest.prototype.cancelUrl = null;
47877
+
47858
47878
  // OneOf field names bound to virtual getters and setters
47859
47879
  var $oneOfFields;
47860
47880
 
@@ -47924,6 +47944,18 @@ $root.types = (function() {
47924
47944
  set: $util.oneOfSetter($oneOfFields)
47925
47945
  });
47926
47946
 
47947
+ // Virtual OneOf for proto3 optional field
47948
+ Object.defineProperty(PaymentServiceCreateOrderRequest.prototype, "_returnUrl", {
47949
+ get: $util.oneOfGetter($oneOfFields = ["returnUrl"]),
47950
+ set: $util.oneOfSetter($oneOfFields)
47951
+ });
47952
+
47953
+ // Virtual OneOf for proto3 optional field
47954
+ Object.defineProperty(PaymentServiceCreateOrderRequest.prototype, "_cancelUrl", {
47955
+ get: $util.oneOfGetter($oneOfFields = ["cancelUrl"]),
47956
+ set: $util.oneOfSetter($oneOfFields)
47957
+ });
47958
+
47927
47959
  /**
47928
47960
  * Creates a new PaymentServiceCreateOrderRequest instance using the specified properties.
47929
47961
  * @function create
@@ -47976,6 +48008,10 @@ $root.types = (function() {
47976
48008
  writer.uint32(/* id 11, wireType 0 =*/88).int32(message.mitCategory);
47977
48009
  if (message.recurringAgreement != null && Object.hasOwnProperty.call(message, "recurringAgreement"))
47978
48010
  $root.types.RecurringAgreement.encode(message.recurringAgreement, writer.uint32(/* id 12, wireType 2 =*/98).fork(), q + 1).ldelim();
48011
+ if (message.returnUrl != null && Object.hasOwnProperty.call(message, "returnUrl"))
48012
+ writer.uint32(/* id 13, wireType 2 =*/106).string(message.returnUrl);
48013
+ if (message.cancelUrl != null && Object.hasOwnProperty.call(message, "cancelUrl"))
48014
+ writer.uint32(/* id 14, wireType 2 =*/114).string(message.cancelUrl);
47979
48015
  return writer;
47980
48016
  };
47981
48017
 
@@ -48051,6 +48087,14 @@ $root.types = (function() {
48051
48087
  message.recurringAgreement = $root.types.RecurringAgreement.decode(reader, reader.uint32(), undefined, long + 1);
48052
48088
  break;
48053
48089
  }
48090
+ case 13: {
48091
+ message.returnUrl = reader.string();
48092
+ break;
48093
+ }
48094
+ case 14: {
48095
+ message.cancelUrl = reader.string();
48096
+ break;
48097
+ }
48054
48098
  default:
48055
48099
  reader.skipType(tag & 7, long);
48056
48100
  break;
@@ -48288,6 +48332,16 @@ $root.types = (function() {
48288
48332
  return "recurringAgreement." + error;
48289
48333
  }
48290
48334
  }
48335
+ if (message.returnUrl != null && Object.hasOwnProperty.call(message, "returnUrl")) {
48336
+ properties._returnUrl = 1;
48337
+ if (!$util.isString(message.returnUrl))
48338
+ return "returnUrl: string expected";
48339
+ }
48340
+ if (message.cancelUrl != null && Object.hasOwnProperty.call(message, "cancelUrl")) {
48341
+ properties._cancelUrl = 1;
48342
+ if (!$util.isString(message.cancelUrl))
48343
+ return "cancelUrl: string expected";
48344
+ }
48291
48345
  return null;
48292
48346
  };
48293
48347
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alphawebai/hs-prism",
3
- "version": "0.1.0-rc.33",
3
+ "version": "0.1.0-rc.35",
4
4
  "description": "Hyperswitch Payments SDK — Node.js client for connector integrations via UniFFI FFI",
5
5
  "main": "dist/src/index.js",
6
6
  "exports": {