moltspay 0.8.3 → 0.8.4
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/cli/index.js +9 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +9 -5
- package/dist/cli/index.mjs.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -5
- package/dist/index.mjs.map +1 -1
- package/dist/server/index.d.mts +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +9 -5
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +9 -5
- package/dist/server/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -30591,12 +30591,16 @@ var MoltsPayServer = class {
|
|
|
30591
30591
|
}, responseHeaders);
|
|
30592
30592
|
}
|
|
30593
30593
|
/**
|
|
30594
|
-
* Return 402 with x402 payment requirements
|
|
30594
|
+
* Return 402 with x402 payment requirements (v2 format)
|
|
30595
30595
|
*/
|
|
30596
30596
|
sendPaymentRequired(config, res) {
|
|
30597
|
-
const requirements =
|
|
30598
|
-
requirements
|
|
30599
|
-
const
|
|
30597
|
+
const requirements = this.buildPaymentRequirements(config);
|
|
30598
|
+
requirements.description = `${config.name} - $${config.price} ${config.currency}`;
|
|
30599
|
+
const paymentRequired = {
|
|
30600
|
+
x402Version: X402_VERSION,
|
|
30601
|
+
accepts: [requirements]
|
|
30602
|
+
};
|
|
30603
|
+
const encoded = Buffer.from(JSON.stringify(paymentRequired)).toString("base64");
|
|
30600
30604
|
res.writeHead(402, {
|
|
30601
30605
|
"Content-Type": "application/json",
|
|
30602
30606
|
[PAYMENT_REQUIRED_HEADER]: encoded
|
|
@@ -30604,7 +30608,7 @@ var MoltsPayServer = class {
|
|
|
30604
30608
|
res.end(JSON.stringify({
|
|
30605
30609
|
error: "Payment required",
|
|
30606
30610
|
message: `Service requires $${config.price} ${config.currency}`,
|
|
30607
|
-
x402:
|
|
30611
|
+
x402: paymentRequired
|
|
30608
30612
|
}, null, 2));
|
|
30609
30613
|
}
|
|
30610
30614
|
/**
|