@alphawebai/hs-prism 0.1.0-rc.34 → 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.
|
|
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.
|
|
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[]>;
|
|
@@ -317,6 +317,34 @@ function paypalVaultStateFromOrder(payload, options, sourceConnectorPaymentId) {
|
|
|
317
317
|
}
|
|
318
318
|
return { status: 'absent' };
|
|
319
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
|
+
}
|
|
320
348
|
function supportsPurposes(reference, purposes) {
|
|
321
349
|
const requested = new Set(purposes);
|
|
322
350
|
return !((requested.has('post_purchase') && !reference.capabilities.includes('post_purchase')) ||
|
|
@@ -942,6 +970,16 @@ class PrismPayPalConnector {
|
|
|
942
970
|
this.assertOperation(input);
|
|
943
971
|
return this.repeatPayment(input);
|
|
944
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
|
+
}
|
|
945
983
|
async retrievePayment(input) {
|
|
946
984
|
assertIdentifier(input.operationId, 'operationId');
|
|
947
985
|
assertIdentifier(input.connectorPaymentId, 'connectorPaymentId');
|
|
@@ -325,8 +325,18 @@ export interface PrismConnectorV1 {
|
|
|
325
325
|
retrieveWebhookEndpoint(input: PrismRetrieveWebhookEndpointInput): Promise<PrismWebhookEndpoint>;
|
|
326
326
|
}
|
|
327
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
|
+
}
|
|
328
337
|
export interface PrismPayPalConnectorV1 extends PrismConnectorV1 {
|
|
329
338
|
authorizeApprovedPayment(input: PrismAuthorizeApprovedPaymentInput): Promise<PrismPaymentResult>;
|
|
339
|
+
retrieveOrderLifecycle?(input: PrismRetrieveOrderLifecycleInput): Promise<PrismPayPalOrderLifecycle>;
|
|
330
340
|
}
|
|
331
341
|
export interface PrismStripeConnectorOptions {
|
|
332
342
|
environment: PrismEnvironment;
|
package/package.json
CHANGED