@openfacilitator/sdk 0.6.2 → 0.6.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.
- package/dist/index.d.mts +3 -7
- package/dist/index.d.ts +3 -7
- package/dist/index.js +9 -5
- package/dist/index.mjs +9 -5
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -516,13 +516,9 @@ declare function createPaymentContext(settleResponse: {
|
|
|
516
516
|
transaction: string;
|
|
517
517
|
payer: string;
|
|
518
518
|
network: string;
|
|
519
|
-
}, paymentPayload: {
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
amount: string;
|
|
523
|
-
asset: string;
|
|
524
|
-
};
|
|
525
|
-
};
|
|
519
|
+
}, paymentPayload: Record<string, unknown>, requirements?: {
|
|
520
|
+
maxAmountRequired?: string;
|
|
521
|
+
asset?: string;
|
|
526
522
|
}): PaymentContext;
|
|
527
523
|
interface PaymentMiddlewareConfig {
|
|
528
524
|
/** Facilitator instance or URL */
|
package/dist/index.d.ts
CHANGED
|
@@ -516,13 +516,9 @@ declare function createPaymentContext(settleResponse: {
|
|
|
516
516
|
transaction: string;
|
|
517
517
|
payer: string;
|
|
518
518
|
network: string;
|
|
519
|
-
}, paymentPayload: {
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
amount: string;
|
|
523
|
-
asset: string;
|
|
524
|
-
};
|
|
525
|
-
};
|
|
519
|
+
}, paymentPayload: Record<string, unknown>, requirements?: {
|
|
520
|
+
maxAmountRequired?: string;
|
|
521
|
+
asset?: string;
|
|
526
522
|
}): PaymentContext;
|
|
527
523
|
interface PaymentMiddlewareConfig {
|
|
528
524
|
/** Facilitator instance or URL */
|
package/dist/index.js
CHANGED
|
@@ -559,12 +559,16 @@ function honoRefundMiddleware(config) {
|
|
|
559
559
|
}
|
|
560
560
|
};
|
|
561
561
|
}
|
|
562
|
-
function createPaymentContext(settleResponse, paymentPayload) {
|
|
562
|
+
function createPaymentContext(settleResponse, paymentPayload, requirements) {
|
|
563
|
+
const payload = paymentPayload.payload;
|
|
564
|
+
const authorization = payload?.authorization;
|
|
565
|
+
const amount = authorization?.amount || payload?.amount || requirements?.maxAmountRequired || "0";
|
|
566
|
+
const asset = authorization?.asset || payload?.asset || requirements?.asset || "";
|
|
563
567
|
return {
|
|
564
568
|
transactionHash: settleResponse.transaction,
|
|
565
569
|
userWallet: settleResponse.payer,
|
|
566
|
-
amount
|
|
567
|
-
asset
|
|
570
|
+
amount,
|
|
571
|
+
asset,
|
|
568
572
|
network: settleResponse.network
|
|
569
573
|
};
|
|
570
574
|
}
|
|
@@ -635,7 +639,7 @@ function createPaymentMiddleware(config) {
|
|
|
635
639
|
});
|
|
636
640
|
return;
|
|
637
641
|
}
|
|
638
|
-
const paymentContext = createPaymentContext(settleResult, paymentPayload);
|
|
642
|
+
const paymentContext = createPaymentContext(settleResult, paymentPayload, requirements);
|
|
639
643
|
req.paymentContext = paymentContext;
|
|
640
644
|
if (res.locals) {
|
|
641
645
|
res.locals.paymentContext = paymentContext;
|
|
@@ -737,7 +741,7 @@ function honoPaymentMiddleware(config) {
|
|
|
737
741
|
reason: settleResult.errorReason
|
|
738
742
|
}, 402);
|
|
739
743
|
}
|
|
740
|
-
const paymentContext = createPaymentContext(settleResult, paymentPayload);
|
|
744
|
+
const paymentContext = createPaymentContext(settleResult, paymentPayload, requirements);
|
|
741
745
|
c.set("paymentContext", paymentContext);
|
|
742
746
|
if (config.refundProtection) {
|
|
743
747
|
const refundConfig = config.refundProtection;
|
package/dist/index.mjs
CHANGED
|
@@ -508,12 +508,16 @@ function honoRefundMiddleware(config) {
|
|
|
508
508
|
}
|
|
509
509
|
};
|
|
510
510
|
}
|
|
511
|
-
function createPaymentContext(settleResponse, paymentPayload) {
|
|
511
|
+
function createPaymentContext(settleResponse, paymentPayload, requirements) {
|
|
512
|
+
const payload = paymentPayload.payload;
|
|
513
|
+
const authorization = payload?.authorization;
|
|
514
|
+
const amount = authorization?.amount || payload?.amount || requirements?.maxAmountRequired || "0";
|
|
515
|
+
const asset = authorization?.asset || payload?.asset || requirements?.asset || "";
|
|
512
516
|
return {
|
|
513
517
|
transactionHash: settleResponse.transaction,
|
|
514
518
|
userWallet: settleResponse.payer,
|
|
515
|
-
amount
|
|
516
|
-
asset
|
|
519
|
+
amount,
|
|
520
|
+
asset,
|
|
517
521
|
network: settleResponse.network
|
|
518
522
|
};
|
|
519
523
|
}
|
|
@@ -584,7 +588,7 @@ function createPaymentMiddleware(config) {
|
|
|
584
588
|
});
|
|
585
589
|
return;
|
|
586
590
|
}
|
|
587
|
-
const paymentContext = createPaymentContext(settleResult, paymentPayload);
|
|
591
|
+
const paymentContext = createPaymentContext(settleResult, paymentPayload, requirements);
|
|
588
592
|
req.paymentContext = paymentContext;
|
|
589
593
|
if (res.locals) {
|
|
590
594
|
res.locals.paymentContext = paymentContext;
|
|
@@ -686,7 +690,7 @@ function honoPaymentMiddleware(config) {
|
|
|
686
690
|
reason: settleResult.errorReason
|
|
687
691
|
}, 402);
|
|
688
692
|
}
|
|
689
|
-
const paymentContext = createPaymentContext(settleResult, paymentPayload);
|
|
693
|
+
const paymentContext = createPaymentContext(settleResult, paymentPayload, requirements);
|
|
690
694
|
c.set("paymentContext", paymentContext);
|
|
691
695
|
if (config.refundProtection) {
|
|
692
696
|
const refundConfig = config.refundProtection;
|