@orboni/vendure-plugin 0.0.0-stage → 1.0.0
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/CHANGELOG.md +6 -0
- package/LICENSE +21 -0
- package/README.md +79 -2
- package/dist/constants.d.ts +10 -0
- package/dist/constants.js +9 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +17 -0
- package/dist/money.d.ts +15 -0
- package/dist/money.js +38 -0
- package/dist/orboni.controller.d.ts +10 -0
- package/dist/orboni.controller.js +43 -0
- package/dist/orboni.handler.d.ts +61 -0
- package/dist/orboni.handler.js +56 -0
- package/dist/orboni.plugin.d.ts +16 -0
- package/dist/orboni.plugin.js +82 -0
- package/dist/orboni.resolver.d.ts +7 -0
- package/dist/orboni.resolver.js +42 -0
- package/dist/orboni.service.d.ts +78 -0
- package/dist/orboni.service.js +409 -0
- package/dist/status.d.ts +22 -0
- package/dist/status.js +31 -0
- package/package.json +56 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.0 - 2026-11-23
|
|
4
|
+
|
|
5
|
+
- First release: Orboni as a Vendure 3 payment method. `createOrboniPaymentIntent` in the Shop API opens the order's payment page; the payment is recorded by Orboni's signed webhook at `/payments/orboni/<channel token>`, or by `addPaymentToOrder` with `{ sessionId }` when the buyer is back — always read back from Orboni first.
|
|
6
|
+
- Paid: a Settled payment. On its way or held for review: an Authorized payment, settled once paid. A reversal leaves a private note on the order. Refunds made in Vendure are recorded in Orboni.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Orboni
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,80 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Orboni for Vendure
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Crypto payments for [Vendure](https://vendure.io): the buyer pays on Orboni's payment page, picking USDT, USDC, Bitcoin, Ethereum or another coin, from any wallet or exchange. The money goes straight to the wallets you set in the Orboni dashboard — Orboni never holds it — and the order is paid once the payment is final, by the webhook or the buyer's return, whichever comes first.
|
|
4
|
+
|
|
5
|
+
A payment plugin for Vendure 3, tested end to end on Vendure 3.8. Full guide: https://orboni.com/docs/vendure
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @orboni/vendure-plugin
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
// vendure-config.ts
|
|
15
|
+
import { OrboniPlugin } from '@orboni/vendure-plugin';
|
|
16
|
+
|
|
17
|
+
export const config: VendureConfig = {
|
|
18
|
+
// …
|
|
19
|
+
plugins: [
|
|
20
|
+
// …
|
|
21
|
+
OrboniPlugin.init(),
|
|
22
|
+
],
|
|
23
|
+
};
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Set it up
|
|
27
|
+
|
|
28
|
+
1. In the Orboni dashboard, set the wallets you want to be paid to under Wallets, and copy a secret key under Developers → API keys — a test key (`sk_test_…`) first.
|
|
29
|
+
2. In the Vendure dashboard, open Settings → Payment methods, create one with the **Orboni** handler (say, "Crypto (USDT, USDC, BTC and more)", code `crypto`), enter the Secret key and the Return address of your storefront's page for a paid order. Assign it to your channel.
|
|
30
|
+
3. In the Orboni dashboard, under Developers → Webhooks, add an endpoint at `https://<your Vendure server>/payments/orboni/<channel token>` (the token is under Settings → Channels) with the `checkout.session.*` events, and enter its signing secret (`whsec_…`) as the payment method's Webhook signing secret.
|
|
31
|
+
4. Place an order, and on its payment page, signed in to the Orboni dashboard, press **Simulate payment**: the order is paid. Then swap in your live key (`sk_live_…`) and the live endpoint's secret. The key decides test or live at Orboni.
|
|
32
|
+
|
|
33
|
+
## The storefront
|
|
34
|
+
|
|
35
|
+
The storefront asks for the order's payment page, sends the buyer there, and records the payment when they come back. With a Return address such as `https://shop.example.com/order/{ORDER_CODE}?session={CHECKOUT_SESSION_ID}` the page knows both:
|
|
36
|
+
|
|
37
|
+
```graphql
|
|
38
|
+
# The payment step: the order has its customer, address and shipping.
|
|
39
|
+
mutation {
|
|
40
|
+
createOrboniPaymentIntent(input: { paymentMethodCode: "crypto" }) {
|
|
41
|
+
url # send the buyer here
|
|
42
|
+
sessionId
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
# Back from the payment page:
|
|
47
|
+
mutation {
|
|
48
|
+
addPaymentToOrder(input: { method: "crypto", metadata: { sessionId: "cs_…" } }) {
|
|
49
|
+
... on Order { code state } # PaymentSettled, or PaymentAuthorized
|
|
50
|
+
... on ErrorResult { errorCode message }
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`createOrboniPaymentIntent` moves the active order to ArrangingPayment and also takes `successUrl` and `cancelUrl`, over the payment method's. Paying again opens the same page while the order's total stays the same. When the buyer is back before the money is final, `addPaymentToOrder` answers with an error that says why: show it, and let the buyer pay or choose another way. When the webhook was first, the order is no longer active: read it with `orderByCode`.
|
|
56
|
+
|
|
57
|
+
## How orders move
|
|
58
|
+
|
|
59
|
+
| Payment | Orboni says | In Vendure |
|
|
60
|
+
| --- | --- | --- |
|
|
61
|
+
| Paid in full | `complete, paid` | A Settled payment naming the coin, the order PaymentSettled |
|
|
62
|
+
| On the chain, not final yet; or held for your review | `processing, held` | An Authorized payment, the order PaymentAuthorized; settled by the webhook once paid |
|
|
63
|
+
| Part paid | `partially_paid` | Nothing recorded; the payment page asks the buyer for the rest |
|
|
64
|
+
| Back before paying | `open, unpaid` | Nothing recorded, the buyer told so |
|
|
65
|
+
| Ran out unpaid | `expired` | Nothing recorded |
|
|
66
|
+
| Money that paid it left the chain | `payment_reversed` | A private note on the order not to ship it until the dashboard shows it paid again |
|
|
67
|
+
|
|
68
|
+
The plugin reads every payment back from Orboni with your key before Vendure records it, so a webhook sent twice, late or out of order changes nothing, and a storefront cannot record a payment that is not there. An order taken back to AddingItems and changed gets a new page for its new total, and the old one is closed.
|
|
69
|
+
|
|
70
|
+
## Good to know
|
|
71
|
+
|
|
72
|
+
- The currency: the order's own — US dollars, euros, pounds, yen and 30-odd more. In a currency Orboni does not take, the intent fails with a reason.
|
|
73
|
+
- The least an order may be is worth $1.00; below it the intent fails with Orboni's reason.
|
|
74
|
+
- Refunds: the money is in your wallet, so send it back from there, then refund the payment in Vendure: it is recorded in Orboni, and nothing moves by itself.
|
|
75
|
+
- Several channels, or several Vendure servers, can share one Orboni project: each channel adds its own endpoint and acts only on its own orders.
|
|
76
|
+
- What is sent: the order's outstanding amount and currency, its code, id and lines, the customer's email and the request's language. No address or phone number.
|
|
77
|
+
|
|
78
|
+
## Licence
|
|
79
|
+
|
|
80
|
+
MIT. Source: https://github.com/orboni/vendure-plugin-orboni
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const ORBONI_PLUGIN_OPTIONS: unique symbol;
|
|
2
|
+
export declare const loggerCtx = "OrboniPlugin";
|
|
3
|
+
/** The handler's code, as a payment method names it in the dashboard. */
|
|
4
|
+
export declare const HANDLER_CODE = "orboni";
|
|
5
|
+
/** Where Orboni's webhook comes: `/payments/orboni/<channel token>`. */
|
|
6
|
+
export declare const WEBHOOK_ROUTE = "payments/orboni";
|
|
7
|
+
export interface OrboniPluginOptions {
|
|
8
|
+
/** The API's address: only for testing against another Orboni. */
|
|
9
|
+
apiUrl?: string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WEBHOOK_ROUTE = exports.HANDLER_CODE = exports.loggerCtx = exports.ORBONI_PLUGIN_OPTIONS = void 0;
|
|
4
|
+
exports.ORBONI_PLUGIN_OPTIONS = Symbol('ORBONI_PLUGIN_OPTIONS');
|
|
5
|
+
exports.loggerCtx = 'OrboniPlugin';
|
|
6
|
+
/** The handler's code, as a payment method names it in the dashboard. */
|
|
7
|
+
exports.HANDLER_CODE = 'orboni';
|
|
8
|
+
/** Where Orboni's webhook comes: `/payments/orboni/<channel token>`. */
|
|
9
|
+
exports.WEBHOOK_ROUTE = 'payments/orboni';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { OrboniPlugin } from './orboni.plugin';
|
|
2
|
+
export { orboniPaymentHandler } from './orboni.handler';
|
|
3
|
+
export { OrboniService } from './orboni.service';
|
|
4
|
+
export type { OrboniArgs, PaymentIntent, PaymentIntentInput } from './orboni.service';
|
|
5
|
+
export type { OrboniPluginOptions } from './constants';
|
|
6
|
+
export { DECIMALS, fromOrboni, supports, toOrboni } from './money';
|
|
7
|
+
export { notPaidReason, paymentState } from './status';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.paymentState = exports.notPaidReason = exports.toOrboni = exports.supports = exports.fromOrboni = exports.DECIMALS = exports.OrboniService = exports.orboniPaymentHandler = exports.OrboniPlugin = void 0;
|
|
4
|
+
var orboni_plugin_1 = require("./orboni.plugin");
|
|
5
|
+
Object.defineProperty(exports, "OrboniPlugin", { enumerable: true, get: function () { return orboni_plugin_1.OrboniPlugin; } });
|
|
6
|
+
var orboni_handler_1 = require("./orboni.handler");
|
|
7
|
+
Object.defineProperty(exports, "orboniPaymentHandler", { enumerable: true, get: function () { return orboni_handler_1.orboniPaymentHandler; } });
|
|
8
|
+
var orboni_service_1 = require("./orboni.service");
|
|
9
|
+
Object.defineProperty(exports, "OrboniService", { enumerable: true, get: function () { return orboni_service_1.OrboniService; } });
|
|
10
|
+
var money_1 = require("./money");
|
|
11
|
+
Object.defineProperty(exports, "DECIMALS", { enumerable: true, get: function () { return money_1.DECIMALS; } });
|
|
12
|
+
Object.defineProperty(exports, "fromOrboni", { enumerable: true, get: function () { return money_1.fromOrboni; } });
|
|
13
|
+
Object.defineProperty(exports, "supports", { enumerable: true, get: function () { return money_1.supports; } });
|
|
14
|
+
Object.defineProperty(exports, "toOrboni", { enumerable: true, get: function () { return money_1.toOrboni; } });
|
|
15
|
+
var status_1 = require("./status");
|
|
16
|
+
Object.defineProperty(exports, "notPaidReason", { enumerable: true, get: function () { return status_1.notPaidReason; } });
|
|
17
|
+
Object.defineProperty(exports, "paymentState", { enumerable: true, get: function () { return status_1.paymentState; } });
|
package/dist/money.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The currencies Orboni prices in, with the decimals of each: an amount goes
|
|
3
|
+
* to Orboni in the currency's smallest unit (cents; whole yen, won, krónur,
|
|
4
|
+
* pesos and dong).
|
|
5
|
+
*
|
|
6
|
+
* Vendure keeps every amount as an integer of hundredths, whatever the
|
|
7
|
+
* currency: $24.90 is 2490 and ¥1500 is 150000. So a two-decimal currency
|
|
8
|
+
* goes as it is, and a zero-decimal one is divided by 100.
|
|
9
|
+
*/
|
|
10
|
+
export declare const DECIMALS: Readonly<Record<string, number>>;
|
|
11
|
+
export declare function supports(currency: string): boolean;
|
|
12
|
+
/** A Vendure amount (hundredths) in Orboni's smallest unit: 2490 → 2490 cents, 150000 → 1500 yen. */
|
|
13
|
+
export declare function toOrboni(amount: number, currency: string): number;
|
|
14
|
+
/** Orboni's smallest unit back in Vendure's hundredths: 1500 yen → 150000. */
|
|
15
|
+
export declare function fromOrboni(minor: number, currency: string): number;
|
package/dist/money.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DECIMALS = void 0;
|
|
4
|
+
exports.supports = supports;
|
|
5
|
+
exports.toOrboni = toOrboni;
|
|
6
|
+
exports.fromOrboni = fromOrboni;
|
|
7
|
+
/**
|
|
8
|
+
* The currencies Orboni prices in, with the decimals of each: an amount goes
|
|
9
|
+
* to Orboni in the currency's smallest unit (cents; whole yen, won, krónur,
|
|
10
|
+
* pesos and dong).
|
|
11
|
+
*
|
|
12
|
+
* Vendure keeps every amount as an integer of hundredths, whatever the
|
|
13
|
+
* currency: $24.90 is 2490 and ¥1500 is 150000. So a two-decimal currency
|
|
14
|
+
* goes as it is, and a zero-decimal one is divided by 100.
|
|
15
|
+
*/
|
|
16
|
+
exports.DECIMALS = {
|
|
17
|
+
usd: 2, eur: 2, gbp: 2, chf: 2, pln: 2, czk: 2, huf: 2, ron: 2, dkk: 2,
|
|
18
|
+
sek: 2, nok: 2, isk: 0, try: 2, jpy: 0, krw: 0, cny: 2, hkd: 2, sgd: 2,
|
|
19
|
+
inr: 2, idr: 2, myr: 2, php: 2, thb: 2, ils: 2, aud: 2, nzd: 2, cad: 2,
|
|
20
|
+
mxn: 2, brl: 2, zar: 2, uah: 2, ars: 2, clp: 0, aed: 2, sar: 2, twd: 2,
|
|
21
|
+
vnd: 0,
|
|
22
|
+
};
|
|
23
|
+
function supports(currency) {
|
|
24
|
+
return Object.hasOwn(exports.DECIMALS, currency.toLowerCase());
|
|
25
|
+
}
|
|
26
|
+
/** A Vendure amount (hundredths) in Orboni's smallest unit: 2490 → 2490 cents, 150000 → 1500 yen. */
|
|
27
|
+
function toOrboni(amount, currency) {
|
|
28
|
+
if (!Number.isInteger(amount) || amount < 0) {
|
|
29
|
+
throw new RangeError(`Not an amount: ${amount}`);
|
|
30
|
+
}
|
|
31
|
+
const decimals = exports.DECIMALS[currency.toLowerCase()] ?? 2;
|
|
32
|
+
return decimals === 2 ? amount : Math.round(amount / 10 ** (2 - decimals));
|
|
33
|
+
}
|
|
34
|
+
/** Orboni's smallest unit back in Vendure's hundredths: 1500 yen → 150000. */
|
|
35
|
+
function fromOrboni(minor, currency) {
|
|
36
|
+
const decimals = exports.DECIMALS[currency.toLowerCase()] ?? 2;
|
|
37
|
+
return minor * 10 ** (2 - decimals);
|
|
38
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Request, Response } from 'express';
|
|
2
|
+
import { OrboniService } from './orboni.service';
|
|
3
|
+
/** Orboni's webhook: POST /payments/orboni/<channel token>. */
|
|
4
|
+
export declare class OrboniController {
|
|
5
|
+
private readonly service;
|
|
6
|
+
constructor(service: OrboniService);
|
|
7
|
+
webhook(channelToken: string, signature: string | undefined, request: Request & {
|
|
8
|
+
rawBody?: Buffer;
|
|
9
|
+
}, response: Response): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.OrboniController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const orboni_service_1 = require("./orboni.service");
|
|
18
|
+
/** Orboni's webhook: POST /payments/orboni/<channel token>. */
|
|
19
|
+
let OrboniController = class OrboniController {
|
|
20
|
+
service;
|
|
21
|
+
constructor(service) {
|
|
22
|
+
this.service = service;
|
|
23
|
+
}
|
|
24
|
+
async webhook(channelToken, signature, request, response) {
|
|
25
|
+
const answer = await this.service.handleWebhook(channelToken, request.rawBody, signature);
|
|
26
|
+
response.status(answer.status).type('text/plain').send(answer.body);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
exports.OrboniController = OrboniController;
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, common_1.Post)('orboni/:channelToken'),
|
|
32
|
+
__param(0, (0, common_1.Param)('channelToken')),
|
|
33
|
+
__param(1, (0, common_1.Headers)('webhook-signature')),
|
|
34
|
+
__param(2, (0, common_1.Req)()),
|
|
35
|
+
__param(3, (0, common_1.Res)()),
|
|
36
|
+
__metadata("design:type", Function),
|
|
37
|
+
__metadata("design:paramtypes", [String, Object, Object, Object]),
|
|
38
|
+
__metadata("design:returntype", Promise)
|
|
39
|
+
], OrboniController.prototype, "webhook", null);
|
|
40
|
+
exports.OrboniController = OrboniController = __decorate([
|
|
41
|
+
(0, common_1.Controller)('payments'),
|
|
42
|
+
__metadata("design:paramtypes", [orboni_service_1.OrboniService])
|
|
43
|
+
], OrboniController);
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { LanguageCode, PaymentMethodHandler } from '@vendure/core';
|
|
2
|
+
/**
|
|
3
|
+
* Orboni as a Vendure payment method: the buyer pays on Orboni's payment
|
|
4
|
+
* page, in the coin and network they choose, straight to the merchant's own
|
|
5
|
+
* wallets. Its settings are entered per payment method in the dashboard.
|
|
6
|
+
*/
|
|
7
|
+
export declare const orboniPaymentHandler: PaymentMethodHandler<{
|
|
8
|
+
apiKey: {
|
|
9
|
+
type: "string";
|
|
10
|
+
label: {
|
|
11
|
+
languageCode: LanguageCode;
|
|
12
|
+
value: string;
|
|
13
|
+
}[];
|
|
14
|
+
description: {
|
|
15
|
+
languageCode: LanguageCode;
|
|
16
|
+
value: string;
|
|
17
|
+
}[];
|
|
18
|
+
ui: {
|
|
19
|
+
component: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
webhookSecret: {
|
|
23
|
+
type: "string";
|
|
24
|
+
required: false;
|
|
25
|
+
label: {
|
|
26
|
+
languageCode: LanguageCode;
|
|
27
|
+
value: string;
|
|
28
|
+
}[];
|
|
29
|
+
description: {
|
|
30
|
+
languageCode: LanguageCode;
|
|
31
|
+
value: string;
|
|
32
|
+
}[];
|
|
33
|
+
ui: {
|
|
34
|
+
component: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
successUrl: {
|
|
38
|
+
type: "string";
|
|
39
|
+
required: false;
|
|
40
|
+
label: {
|
|
41
|
+
languageCode: LanguageCode;
|
|
42
|
+
value: string;
|
|
43
|
+
}[];
|
|
44
|
+
description: {
|
|
45
|
+
languageCode: LanguageCode;
|
|
46
|
+
value: string;
|
|
47
|
+
}[];
|
|
48
|
+
};
|
|
49
|
+
cancelUrl: {
|
|
50
|
+
type: "string";
|
|
51
|
+
required: false;
|
|
52
|
+
label: {
|
|
53
|
+
languageCode: LanguageCode;
|
|
54
|
+
value: string;
|
|
55
|
+
}[];
|
|
56
|
+
description: {
|
|
57
|
+
languageCode: LanguageCode;
|
|
58
|
+
value: string;
|
|
59
|
+
}[];
|
|
60
|
+
};
|
|
61
|
+
}>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.orboniPaymentHandler = void 0;
|
|
4
|
+
const core_1 = require("@vendure/core");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
const orboni_service_1 = require("./orboni.service");
|
|
7
|
+
let service;
|
|
8
|
+
const en = (value) => [{ languageCode: core_1.LanguageCode.en, value }];
|
|
9
|
+
/**
|
|
10
|
+
* Orboni as a Vendure payment method: the buyer pays on Orboni's payment
|
|
11
|
+
* page, in the coin and network they choose, straight to the merchant's own
|
|
12
|
+
* wallets. Its settings are entered per payment method in the dashboard.
|
|
13
|
+
*/
|
|
14
|
+
exports.orboniPaymentHandler = new core_1.PaymentMethodHandler({
|
|
15
|
+
code: constants_1.HANDLER_CODE,
|
|
16
|
+
description: en('Orboni: crypto payments (USDT, USDC, BTC and more) to your own wallets'),
|
|
17
|
+
args: {
|
|
18
|
+
apiKey: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
label: en('Secret key'),
|
|
21
|
+
description: en('sk_live_… or sk_test_…, from Developers → API keys in the Orboni dashboard. The key decides test or live.'),
|
|
22
|
+
ui: { component: 'password-form-input' },
|
|
23
|
+
},
|
|
24
|
+
webhookSecret: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
required: false,
|
|
27
|
+
label: en('Webhook signing secret'),
|
|
28
|
+
description: en('whsec_…, from the endpoint you add under Developers → Webhooks at https://<your Vendure server>/payments/orboni/<channel token>.'),
|
|
29
|
+
ui: { component: 'password-form-input' },
|
|
30
|
+
},
|
|
31
|
+
successUrl: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
required: false,
|
|
34
|
+
label: en('Return address'),
|
|
35
|
+
description: en('Your storefront page the buyer comes back to once paid, unless the storefront passes its own. {ORDER_CODE} is replaced by the order code.'),
|
|
36
|
+
},
|
|
37
|
+
cancelUrl: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
required: false,
|
|
40
|
+
label: en('Back address'),
|
|
41
|
+
description: en('Where the payment page\'s back link goes, unless the storefront passes its own. {ORDER_CODE} is replaced by the order code.'),
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
init(injector) {
|
|
45
|
+
service = injector.get(orboni_service_1.OrboniService);
|
|
46
|
+
},
|
|
47
|
+
createPayment(ctx, order, amount, args, metadata) {
|
|
48
|
+
return service.createPayment(ctx, order, amount, args, metadata);
|
|
49
|
+
},
|
|
50
|
+
settlePayment(ctx, order, payment, args) {
|
|
51
|
+
return service.settlePayment(payment, args);
|
|
52
|
+
},
|
|
53
|
+
createRefund(ctx, input, amount, order, payment, args) {
|
|
54
|
+
return service.createRefund(ctx, input.reason, amount, order, payment, args);
|
|
55
|
+
},
|
|
56
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Type } from '@vendure/core';
|
|
2
|
+
import { OrboniPluginOptions } from './constants';
|
|
3
|
+
/**
|
|
4
|
+
* Crypto payments through Orboni.
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* plugins: [OrboniPlugin.init()]
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* Then add a payment method with the Orboni handler in the dashboard, and an
|
|
11
|
+
* Orboni webhook endpoint at /payments/orboni/<channel token>.
|
|
12
|
+
*/
|
|
13
|
+
export declare class OrboniPlugin {
|
|
14
|
+
static options: OrboniPluginOptions;
|
|
15
|
+
static init(options?: OrboniPluginOptions): Type<OrboniPlugin>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var OrboniPlugin_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.OrboniPlugin = void 0;
|
|
11
|
+
const core_1 = require("@vendure/core");
|
|
12
|
+
const body_parser_1 = require("body-parser");
|
|
13
|
+
const graphql_tag_1 = require("graphql-tag");
|
|
14
|
+
const constants_1 = require("./constants");
|
|
15
|
+
const orboni_controller_1 = require("./orboni.controller");
|
|
16
|
+
const orboni_handler_1 = require("./orboni.handler");
|
|
17
|
+
const orboni_resolver_1 = require("./orboni.resolver");
|
|
18
|
+
const orboni_service_1 = require("./orboni.service");
|
|
19
|
+
/** The webhook's body as it came, for its signature. */
|
|
20
|
+
const rawBody = (0, body_parser_1.raw)({
|
|
21
|
+
type: '*/*',
|
|
22
|
+
limit: '1mb',
|
|
23
|
+
verify(request, _response, buffer) {
|
|
24
|
+
request.rawBody = Buffer.from(buffer);
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
const shopSchema = (0, graphql_tag_1.gql) `
|
|
28
|
+
input OrboniPaymentIntentInput {
|
|
29
|
+
"The code of an Orboni payment method eligible for the order."
|
|
30
|
+
paymentMethodCode: String!
|
|
31
|
+
"Where the buyer comes back once paid; {ORDER_CODE} is replaced. Default: the payment method's Return address."
|
|
32
|
+
successUrl: String
|
|
33
|
+
"Where the payment page's back link goes; {ORDER_CODE} is replaced. Default: the payment method's Back address."
|
|
34
|
+
cancelUrl: String
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type OrboniPaymentIntent {
|
|
38
|
+
"The payment page: send the buyer there."
|
|
39
|
+
url: String!
|
|
40
|
+
"The Orboni session, cs_…: pass it as { sessionId } to addPaymentToOrder when the buyer is back."
|
|
41
|
+
sessionId: String!
|
|
42
|
+
expiresAt: DateTime!
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
extend type Mutation {
|
|
46
|
+
"Moves the active order to ArrangingPayment and returns its Orboni payment page."
|
|
47
|
+
createOrboniPaymentIntent(input: OrboniPaymentIntentInput!): OrboniPaymentIntent!
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
/**
|
|
51
|
+
* Crypto payments through Orboni.
|
|
52
|
+
*
|
|
53
|
+
* ```ts
|
|
54
|
+
* plugins: [OrboniPlugin.init()]
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* Then add a payment method with the Orboni handler in the dashboard, and an
|
|
58
|
+
* Orboni webhook endpoint at /payments/orboni/<channel token>.
|
|
59
|
+
*/
|
|
60
|
+
let OrboniPlugin = class OrboniPlugin {
|
|
61
|
+
static { OrboniPlugin_1 = this; }
|
|
62
|
+
static options = {};
|
|
63
|
+
static init(options = {}) {
|
|
64
|
+
OrboniPlugin_1.options = options;
|
|
65
|
+
return OrboniPlugin_1;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
exports.OrboniPlugin = OrboniPlugin;
|
|
69
|
+
exports.OrboniPlugin = OrboniPlugin = OrboniPlugin_1 = __decorate([
|
|
70
|
+
(0, core_1.VendurePlugin)({
|
|
71
|
+
imports: [core_1.PluginCommonModule],
|
|
72
|
+
controllers: [orboni_controller_1.OrboniController],
|
|
73
|
+
providers: [{ provide: constants_1.ORBONI_PLUGIN_OPTIONS, useFactory: () => OrboniPlugin.options }, orboni_service_1.OrboniService],
|
|
74
|
+
configuration: (config) => {
|
|
75
|
+
config.paymentOptions.paymentMethodHandlers.push(orboni_handler_1.orboniPaymentHandler);
|
|
76
|
+
config.apiOptions.middleware.push({ route: `/${constants_1.WEBHOOK_ROUTE}`, handler: rawBody, beforeListen: true });
|
|
77
|
+
return config;
|
|
78
|
+
},
|
|
79
|
+
shopApiExtensions: { schema: shopSchema, resolvers: [orboni_resolver_1.OrboniShopResolver] },
|
|
80
|
+
compatibility: '^3.0.0',
|
|
81
|
+
})
|
|
82
|
+
], OrboniPlugin);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RequestContext } from '@vendure/core';
|
|
2
|
+
import { OrboniService, PaymentIntent, PaymentIntentInput } from './orboni.service';
|
|
3
|
+
export declare class OrboniShopResolver {
|
|
4
|
+
private readonly service;
|
|
5
|
+
constructor(service: OrboniService);
|
|
6
|
+
createOrboniPaymentIntent(ctx: RequestContext, input: PaymentIntentInput): Promise<PaymentIntent>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.OrboniShopResolver = void 0;
|
|
16
|
+
const graphql_1 = require("@nestjs/graphql");
|
|
17
|
+
const core_1 = require("@vendure/core");
|
|
18
|
+
const orboni_service_1 = require("./orboni.service");
|
|
19
|
+
let OrboniShopResolver = class OrboniShopResolver {
|
|
20
|
+
service;
|
|
21
|
+
constructor(service) {
|
|
22
|
+
this.service = service;
|
|
23
|
+
}
|
|
24
|
+
createOrboniPaymentIntent(ctx, input) {
|
|
25
|
+
return this.service.createPaymentIntent(ctx, input);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
exports.OrboniShopResolver = OrboniShopResolver;
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, graphql_1.Mutation)(),
|
|
31
|
+
(0, core_1.Transaction)(),
|
|
32
|
+
(0, core_1.Allow)(core_1.Permission.Owner),
|
|
33
|
+
__param(0, (0, core_1.Ctx)()),
|
|
34
|
+
__param(1, (0, graphql_1.Args)('input')),
|
|
35
|
+
__metadata("design:type", Function),
|
|
36
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object]),
|
|
37
|
+
__metadata("design:returntype", Promise)
|
|
38
|
+
], OrboniShopResolver.prototype, "createOrboniPaymentIntent", null);
|
|
39
|
+
exports.OrboniShopResolver = OrboniShopResolver = __decorate([
|
|
40
|
+
(0, graphql_1.Resolver)(),
|
|
41
|
+
__metadata("design:paramtypes", [orboni_service_1.OrboniService])
|
|
42
|
+
], OrboniShopResolver);
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ActiveOrderService, CreatePaymentErrorResult, CreatePaymentResult, CreateRefundResult, HistoryService, Order, OrderService, Payment, PaymentMethodService, PaymentMetadata, RequestContext, RequestContextService, SettlePaymentErrorResult, SettlePaymentResult, TransactionalConnection } from '@vendure/core';
|
|
2
|
+
import { Orboni } from 'orboni';
|
|
3
|
+
import { OrboniPluginOptions } from './constants';
|
|
4
|
+
/** The payment method's settings, from the dashboard. */
|
|
5
|
+
export interface OrboniArgs {
|
|
6
|
+
apiKey: string;
|
|
7
|
+
webhookSecret?: string;
|
|
8
|
+
successUrl?: string;
|
|
9
|
+
cancelUrl?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface PaymentIntentInput {
|
|
12
|
+
paymentMethodCode: string;
|
|
13
|
+
successUrl?: string | null;
|
|
14
|
+
cancelUrl?: string | null;
|
|
15
|
+
}
|
|
16
|
+
export interface PaymentIntent {
|
|
17
|
+
url: string;
|
|
18
|
+
sessionId: string;
|
|
19
|
+
expiresAt: Date;
|
|
20
|
+
}
|
|
21
|
+
export interface WebhookAnswer {
|
|
22
|
+
status: number;
|
|
23
|
+
body: string;
|
|
24
|
+
}
|
|
25
|
+
export declare class OrboniService {
|
|
26
|
+
private readonly options;
|
|
27
|
+
private readonly activeOrderService;
|
|
28
|
+
private readonly orderService;
|
|
29
|
+
private readonly paymentMethodService;
|
|
30
|
+
private readonly historyService;
|
|
31
|
+
private readonly requestContextService;
|
|
32
|
+
private readonly connection;
|
|
33
|
+
/** Work on one order at a time, so a webhook and the buyer's return never record one payment twice. */
|
|
34
|
+
private readonly locks;
|
|
35
|
+
constructor(options: OrboniPluginOptions, activeOrderService: ActiveOrderService, orderService: OrderService, paymentMethodService: PaymentMethodService, historyService: HistoryService, requestContextService: RequestContextService, connection: TransactionalConnection);
|
|
36
|
+
/**
|
|
37
|
+
* The Shop API's `createOrboniPaymentIntent`: moves the active order to
|
|
38
|
+
* ArrangingPayment and returns the payment page to send the buyer to.
|
|
39
|
+
* An open page of the same order, total and currency is sent again; any
|
|
40
|
+
* other open page of it is closed, so it can no longer be paid.
|
|
41
|
+
*/
|
|
42
|
+
createPaymentIntent(ctx: RequestContext, input: PaymentIntentInput): Promise<PaymentIntent>;
|
|
43
|
+
/**
|
|
44
|
+
* The handler's createPayment: records a payment only as Orboni has it,
|
|
45
|
+
* read back with the merchant's key. Called by the webhook, and by the
|
|
46
|
+
* storefront's `addPaymentToOrder` with `{ sessionId }` when the buyer is
|
|
47
|
+
* back. A session not paid yet records nothing.
|
|
48
|
+
*/
|
|
49
|
+
createPayment(ctx: RequestContext, order: Order, amount: number, args: OrboniArgs, metadata: PaymentMetadata): Promise<CreatePaymentResult | CreatePaymentErrorResult>;
|
|
50
|
+
/** The handler's settlePayment: an authorized payment is settled once Orboni says it is paid. */
|
|
51
|
+
settlePayment(payment: Payment, args: OrboniArgs): Promise<SettlePaymentResult | SettlePaymentErrorResult>;
|
|
52
|
+
/**
|
|
53
|
+
* The handler's createRefund. Orboni holds no money, so nothing is sent:
|
|
54
|
+
* the refund you sent from your own wallet is recorded against the
|
|
55
|
+
* session, where the dashboard shows it. Send the money first.
|
|
56
|
+
*/
|
|
57
|
+
createRefund(ctx: RequestContext, reason: string | null | undefined, amount: number, order: Order, payment: Payment, args: OrboniArgs): Promise<CreateRefundResult>;
|
|
58
|
+
/**
|
|
59
|
+
* Orboni's webhook, at /payments/orboni/<channel token>. Events of
|
|
60
|
+
* sessions this channel did not make (another store on the same Orboni
|
|
61
|
+
* project) are answered 200 and left alone. Every change is made from the
|
|
62
|
+
* session as Orboni has it now, so an event sent twice, late or out of
|
|
63
|
+
* order changes nothing.
|
|
64
|
+
*/
|
|
65
|
+
handleWebhook(channelToken: string, rawBody: Buffer | undefined, signature: string | undefined): Promise<WebhookAnswer>;
|
|
66
|
+
private apply;
|
|
67
|
+
/** The payment of this session already on the order, if any. */
|
|
68
|
+
private recorded;
|
|
69
|
+
/** What payments already cover of the order. */
|
|
70
|
+
private coveredAmount;
|
|
71
|
+
private methodFor;
|
|
72
|
+
private argsOf;
|
|
73
|
+
client(args: OrboniArgs): Orboni;
|
|
74
|
+
private note;
|
|
75
|
+
/** An Orboni call, its refusal turned into an error with Orboni's own words. */
|
|
76
|
+
private call;
|
|
77
|
+
private locked;
|
|
78
|
+
}
|
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.OrboniService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const core_1 = require("@vendure/core");
|
|
18
|
+
const generated_types_1 = require("@vendure/common/lib/generated-types");
|
|
19
|
+
const orboni_1 = require("orboni");
|
|
20
|
+
const constants_1 = require("./constants");
|
|
21
|
+
const money_1 = require("./money");
|
|
22
|
+
const status_1 = require("./status");
|
|
23
|
+
/** A payment that counts: not declined, failed or cancelled. */
|
|
24
|
+
const LIVE_PAYMENT_STATES = ['Created', 'Authorized', 'Settled'];
|
|
25
|
+
/** An open page is sent again only with this long still to run (seconds). */
|
|
26
|
+
const REUSE_MIN_SECONDS = 300;
|
|
27
|
+
let OrboniService = class OrboniService {
|
|
28
|
+
options;
|
|
29
|
+
activeOrderService;
|
|
30
|
+
orderService;
|
|
31
|
+
paymentMethodService;
|
|
32
|
+
historyService;
|
|
33
|
+
requestContextService;
|
|
34
|
+
connection;
|
|
35
|
+
/** Work on one order at a time, so a webhook and the buyer's return never record one payment twice. */
|
|
36
|
+
locks = new Map();
|
|
37
|
+
constructor(options, activeOrderService, orderService, paymentMethodService, historyService, requestContextService, connection) {
|
|
38
|
+
this.options = options;
|
|
39
|
+
this.activeOrderService = activeOrderService;
|
|
40
|
+
this.orderService = orderService;
|
|
41
|
+
this.paymentMethodService = paymentMethodService;
|
|
42
|
+
this.historyService = historyService;
|
|
43
|
+
this.requestContextService = requestContextService;
|
|
44
|
+
this.connection = connection;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The Shop API's `createOrboniPaymentIntent`: moves the active order to
|
|
48
|
+
* ArrangingPayment and returns the payment page to send the buyer to.
|
|
49
|
+
* An open page of the same order, total and currency is sent again; any
|
|
50
|
+
* other open page of it is closed, so it can no longer be paid.
|
|
51
|
+
*/
|
|
52
|
+
async createPaymentIntent(ctx, input) {
|
|
53
|
+
let order = await this.activeOrderService.getActiveOrder(ctx, undefined);
|
|
54
|
+
if (!order) {
|
|
55
|
+
throw new core_1.UserInputError('There is no active order to pay.');
|
|
56
|
+
}
|
|
57
|
+
if (order.state !== 'ArrangingPayment') {
|
|
58
|
+
const moved = await this.orderService.transitionToState(ctx, order.id, 'ArrangingPayment');
|
|
59
|
+
if (moved instanceof core_1.OrderStateTransitionError) {
|
|
60
|
+
throw new core_1.UserInputError(moved.transitionError || moved.message);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
order = (await this.orderService.findOne(ctx, order.id, ['lines', 'lines.productVariant', 'customer'])) ?? order;
|
|
64
|
+
if (!order.customer?.emailAddress) {
|
|
65
|
+
throw new core_1.UserInputError('The order needs a customer before it is paid.');
|
|
66
|
+
}
|
|
67
|
+
const method = await this.methodFor(ctx, order, input.paymentMethodCode);
|
|
68
|
+
const args = this.argsOf(method);
|
|
69
|
+
const currency = order.currencyCode.toLowerCase();
|
|
70
|
+
if (!(0, money_1.supports)(currency)) {
|
|
71
|
+
throw new core_1.UserInputError(`Orboni does not price in ${order.currencyCode}.`);
|
|
72
|
+
}
|
|
73
|
+
const outstanding = order.totalWithTax - (await this.coveredAmount(ctx, order));
|
|
74
|
+
const amount = (0, money_1.toOrboni)(outstanding, currency);
|
|
75
|
+
const client = this.client(args);
|
|
76
|
+
const open = await this.call(async () => await client.checkout.sessions.list({ client_reference_id: order.code, status: 'open', limit: 10 }));
|
|
77
|
+
const now = Math.floor(Date.now() / 1000);
|
|
78
|
+
let reuse;
|
|
79
|
+
for (const session of open.data) {
|
|
80
|
+
if (session.metadata?.vendure_channel !== ctx.channel.token) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
const same = session.amount_total === amount &&
|
|
84
|
+
session.currency === currency &&
|
|
85
|
+
session.metadata?.vendure_payment_method === method.code &&
|
|
86
|
+
session.expires_at - now > REUSE_MIN_SECONDS;
|
|
87
|
+
if (same && !reuse) {
|
|
88
|
+
reuse = session;
|
|
89
|
+
}
|
|
90
|
+
else if (session.payment_status === 'unpaid') {
|
|
91
|
+
// An older page for another total: closed, so it cannot be paid.
|
|
92
|
+
await this.call(() => client.checkout.sessions.expire(session.id)).catch((error) => core_1.Logger.warn(`Could not close ${session.id}: ${error.message}`, constants_1.loggerCtx));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (reuse) {
|
|
96
|
+
return { url: reuse.url, sessionId: reuse.id, expiresAt: new Date(reuse.expires_at * 1000) };
|
|
97
|
+
}
|
|
98
|
+
const params = {
|
|
99
|
+
amount,
|
|
100
|
+
currency: currency,
|
|
101
|
+
success_url: fill(text(input.successUrl) ?? text(args.successUrl), order.code),
|
|
102
|
+
cancel_url: fill(text(input.cancelUrl) ?? text(args.cancelUrl), order.code),
|
|
103
|
+
client_reference_id: order.code,
|
|
104
|
+
customer_email: order.customer.emailAddress,
|
|
105
|
+
description: describe(order),
|
|
106
|
+
details: `Order ${order.code}`,
|
|
107
|
+
locale: ctx.languageCode,
|
|
108
|
+
metadata: {
|
|
109
|
+
vendure_order_code: order.code,
|
|
110
|
+
vendure_order_id: String(order.id),
|
|
111
|
+
vendure_channel: ctx.channel.token,
|
|
112
|
+
vendure_payment_method: method.code,
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
// A second press within the same minute gets the same page back.
|
|
116
|
+
const key = `vendure-${ctx.channel.token}-${order.code}-${amount}${currency}-${Math.floor(now / 60)}`;
|
|
117
|
+
const session = await this.call(() => client.checkout.sessions.create(params, { idempotencyKey: key }));
|
|
118
|
+
return { url: session.url, sessionId: session.id, expiresAt: new Date(session.expires_at * 1000) };
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The handler's createPayment: records a payment only as Orboni has it,
|
|
122
|
+
* read back with the merchant's key. Called by the webhook, and by the
|
|
123
|
+
* storefront's `addPaymentToOrder` with `{ sessionId }` when the buyer is
|
|
124
|
+
* back. A session not paid yet records nothing.
|
|
125
|
+
*/
|
|
126
|
+
async createPayment(ctx, order, amount, args, metadata) {
|
|
127
|
+
const sessionId = typeof metadata?.sessionId === 'string' ? metadata.sessionId : '';
|
|
128
|
+
if (!/^cs_(live|test)_\w+$/.test(sessionId)) {
|
|
129
|
+
throw new core_1.UserInputError('Orboni needs the payment page\'s session: pass { sessionId } in the metadata.');
|
|
130
|
+
}
|
|
131
|
+
let session;
|
|
132
|
+
try {
|
|
133
|
+
session = await this.client(args).checkout.sessions.retrieve(sessionId);
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
return { amount, state: 'Error', errorMessage: `Orboni: ${error.message}` };
|
|
137
|
+
}
|
|
138
|
+
if (session.client_reference_id !== order.code || session.metadata?.vendure_channel !== ctx.channel.token) {
|
|
139
|
+
throw new core_1.UserInputError('This Orboni payment is not this order\'s.');
|
|
140
|
+
}
|
|
141
|
+
if (session.currency !== order.currencyCode.toLowerCase() || session.amount_total !== (0, money_1.toOrboni)(amount, order.currencyCode)) {
|
|
142
|
+
return {
|
|
143
|
+
amount,
|
|
144
|
+
state: 'Declined',
|
|
145
|
+
errorMessage: 'The order\'s total changed after its payment page was opened, so this payment does not pay it. The store will be in touch about it.',
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
if (await this.recorded(ctx, order, session.id)) {
|
|
149
|
+
throw new core_1.UserInputError('This payment is already recorded on the order.');
|
|
150
|
+
}
|
|
151
|
+
const state = (0, status_1.paymentState)(session);
|
|
152
|
+
if (!state) {
|
|
153
|
+
throw new core_1.UserInputError((0, status_1.notPaidReason)(session));
|
|
154
|
+
}
|
|
155
|
+
return { amount, state, transactionId: session.id, metadata: paymentMetadata(session) };
|
|
156
|
+
}
|
|
157
|
+
/** The handler's settlePayment: an authorized payment is settled once Orboni says it is paid. */
|
|
158
|
+
async settlePayment(payment, args) {
|
|
159
|
+
const session = await this.client(args).checkout.sessions.retrieve(payment.transactionId);
|
|
160
|
+
if ((0, status_1.paymentState)(session) === 'Settled') {
|
|
161
|
+
return { success: true, metadata: paymentMetadata(session) };
|
|
162
|
+
}
|
|
163
|
+
return {
|
|
164
|
+
success: false,
|
|
165
|
+
state: 'Authorized',
|
|
166
|
+
errorMessage: `Orboni session ${session.id} is not paid yet (${session.status}, ${session.payment_status}).`,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* The handler's createRefund. Orboni holds no money, so nothing is sent:
|
|
171
|
+
* the refund you sent from your own wallet is recorded against the
|
|
172
|
+
* session, where the dashboard shows it. Send the money first.
|
|
173
|
+
*/
|
|
174
|
+
async createRefund(ctx, reason, amount, order, payment, args) {
|
|
175
|
+
try {
|
|
176
|
+
const refund = await this.client(args).refunds.create({
|
|
177
|
+
checkout_session: payment.transactionId,
|
|
178
|
+
amount: (0, money_1.toOrboni)(amount, order.currencyCode),
|
|
179
|
+
reason: 'requested_by_customer',
|
|
180
|
+
note: (reason ? `Recorded from Vendure: ${reason}` : 'Recorded from Vendure').slice(0, 500),
|
|
181
|
+
});
|
|
182
|
+
return { state: 'Settled', transactionId: refund.id, metadata: { orboniRefund: refund.id } };
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
core_1.Logger.warn(`Refund of ${payment.transactionId} was not recorded: ${error.message}`, constants_1.loggerCtx);
|
|
186
|
+
return { state: 'Failed', transactionId: payment.transactionId, metadata: { message: `Orboni: ${error.message}` } };
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Orboni's webhook, at /payments/orboni/<channel token>. Events of
|
|
191
|
+
* sessions this channel did not make (another store on the same Orboni
|
|
192
|
+
* project) are answered 200 and left alone. Every change is made from the
|
|
193
|
+
* session as Orboni has it now, so an event sent twice, late or out of
|
|
194
|
+
* order changes nothing.
|
|
195
|
+
*/
|
|
196
|
+
async handleWebhook(channelToken, rawBody, signature) {
|
|
197
|
+
if (!rawBody?.length) {
|
|
198
|
+
return { status: 400, body: 'No body.' };
|
|
199
|
+
}
|
|
200
|
+
let unverified;
|
|
201
|
+
try {
|
|
202
|
+
unverified = JSON.parse(rawBody.toString('utf8'));
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
return { status: 400, body: 'Not JSON.' };
|
|
206
|
+
}
|
|
207
|
+
const unverifiedSession = unverified?.data?.object;
|
|
208
|
+
if (unverifiedSession?.object !== 'checkout.session' || unverifiedSession.metadata?.vendure_channel !== channelToken) {
|
|
209
|
+
return { status: 200, body: 'Not this store\'s.' };
|
|
210
|
+
}
|
|
211
|
+
let ctx;
|
|
212
|
+
try {
|
|
213
|
+
ctx = await this.requestContextService.create({ apiType: 'admin', channelOrToken: channelToken });
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
return { status: 404, body: 'No such channel.' };
|
|
217
|
+
}
|
|
218
|
+
// An unknown token falls back to the default channel: it is not that channel.
|
|
219
|
+
if (ctx.channel.token !== channelToken) {
|
|
220
|
+
return { status: 404, body: 'No such channel.' };
|
|
221
|
+
}
|
|
222
|
+
const methodCode = String(unverifiedSession.metadata?.vendure_payment_method ?? '');
|
|
223
|
+
const method = (await this.paymentMethodService.findAll(ctx)).items.find((m) => m.code === methodCode && m.handler.code === constants_1.HANDLER_CODE);
|
|
224
|
+
if (!method) {
|
|
225
|
+
return { status: 404, body: 'No Orboni payment method with that code in this channel.' };
|
|
226
|
+
}
|
|
227
|
+
const args = this.argsOf(method);
|
|
228
|
+
if (!text(args.webhookSecret)) {
|
|
229
|
+
core_1.Logger.warn(`A webhook came, but the payment method ${method.code} has no webhook signing secret: it was not read.`, constants_1.loggerCtx);
|
|
230
|
+
return { status: 503, body: 'No webhook signing secret is set.' };
|
|
231
|
+
}
|
|
232
|
+
const client = this.client(args);
|
|
233
|
+
let event;
|
|
234
|
+
try {
|
|
235
|
+
event = await client.webhooks.constructEvent(rawBody, signature, args.webhookSecret.trim());
|
|
236
|
+
}
|
|
237
|
+
catch (error) {
|
|
238
|
+
core_1.Logger.warn(`A webhook was refused: ${error.message}`, constants_1.loggerCtx);
|
|
239
|
+
return { status: 401, body: 'Bad signature.' };
|
|
240
|
+
}
|
|
241
|
+
const sent = event.data?.object;
|
|
242
|
+
if (!sent?.id) {
|
|
243
|
+
return { status: 200, body: 'Nothing to do.' };
|
|
244
|
+
}
|
|
245
|
+
let session;
|
|
246
|
+
try {
|
|
247
|
+
session = await client.checkout.sessions.retrieve(sent.id);
|
|
248
|
+
}
|
|
249
|
+
catch (error) {
|
|
250
|
+
const status = error instanceof orboni_1.OrboniError ? error.statusCode : undefined;
|
|
251
|
+
if (status === undefined || status >= 500 || status === 429) {
|
|
252
|
+
return { status: 503, body: 'Orboni could not be read; send it again.' };
|
|
253
|
+
}
|
|
254
|
+
return { status: 200, body: 'Not a session of this key.' };
|
|
255
|
+
}
|
|
256
|
+
const code = session.client_reference_id;
|
|
257
|
+
if (!code || session.metadata?.vendure_channel !== channelToken) {
|
|
258
|
+
return { status: 200, body: 'Not this store\'s.' };
|
|
259
|
+
}
|
|
260
|
+
return this.locked(code, () => this.connection.withTransaction(ctx, async (tx) => {
|
|
261
|
+
const order = await this.orderService.findOneByCode(tx, code);
|
|
262
|
+
if (!order) {
|
|
263
|
+
return { status: 200, body: 'No such order.' };
|
|
264
|
+
}
|
|
265
|
+
await this.apply(tx, order, method, event.type, session);
|
|
266
|
+
return { status: 200, body: 'Ok' };
|
|
267
|
+
}));
|
|
268
|
+
}
|
|
269
|
+
async apply(ctx, order, method, type, session) {
|
|
270
|
+
if (type === 'checkout.session.payment_reversed') {
|
|
271
|
+
await this.note(ctx, order, `Orboni: money that paid this order left the chain (session ${session.id}). Do not ship it until the Orboni dashboard shows it paid again.`);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
const state = (0, status_1.paymentState)(session);
|
|
275
|
+
if (!state) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
const existing = await this.recorded(ctx, order, session.id);
|
|
279
|
+
if (existing) {
|
|
280
|
+
if (existing.state === 'Authorized' && state === 'Settled') {
|
|
281
|
+
const settled = await this.orderService.settlePayment(ctx, existing.id);
|
|
282
|
+
if (!(settled instanceof core_1.Payment)) {
|
|
283
|
+
core_1.Logger.error(`Payment ${existing.id} of order ${order.code} was not settled: ${settled.message}`, constants_1.loggerCtx);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
if (order.state === 'AddingItems' || order.state === 'ArrangingShipping') {
|
|
289
|
+
const moved = await this.orderService.transitionToState(ctx, order.id, 'ArrangingPayment');
|
|
290
|
+
if (moved instanceof core_1.OrderStateTransitionError) {
|
|
291
|
+
await this.note(ctx, order, `Orboni: session ${session.id} is paid, but the order could not take the payment: ${moved.transitionError || moved.message}`);
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
const added = await this.orderService.addPaymentToOrder(ctx, order.id, { method: method.code, metadata: { sessionId: session.id } });
|
|
296
|
+
if (!(added instanceof core_1.Order)) {
|
|
297
|
+
const reason = 'paymentErrorMessage' in added && added.paymentErrorMessage ? added.paymentErrorMessage : added.message;
|
|
298
|
+
core_1.Logger.error(`Session ${session.id} was not recorded on order ${order.code}: ${reason}`, constants_1.loggerCtx);
|
|
299
|
+
await this.note(ctx, order, `Orboni: session ${session.id} is paid, but it was not recorded on the order: ${reason}`);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
/** The payment of this session already on the order, if any. */
|
|
303
|
+
async recorded(ctx, order, sessionId) {
|
|
304
|
+
const payments = await this.connection
|
|
305
|
+
.getRepository(ctx, core_1.Payment)
|
|
306
|
+
.find({ where: { order: { id: order.id }, transactionId: sessionId } });
|
|
307
|
+
return payments.find((p) => LIVE_PAYMENT_STATES.includes(p.state));
|
|
308
|
+
}
|
|
309
|
+
/** What payments already cover of the order. */
|
|
310
|
+
async coveredAmount(ctx, order) {
|
|
311
|
+
const payments = await this.connection.getRepository(ctx, core_1.Payment).find({ where: { order: { id: order.id } } });
|
|
312
|
+
return payments.filter((p) => p.state === 'Authorized' || p.state === 'Settled').reduce((sum, p) => sum + p.amount, 0);
|
|
313
|
+
}
|
|
314
|
+
async methodFor(ctx, order, code) {
|
|
315
|
+
const quotes = await this.paymentMethodService.getEligiblePaymentMethods(ctx, order);
|
|
316
|
+
const quote = quotes.find((q) => q.code === code);
|
|
317
|
+
if (!quote || !quote.isEligible) {
|
|
318
|
+
throw new core_1.UserInputError(quote?.eligibilityMessage || `The payment method ${code} cannot pay this order.`);
|
|
319
|
+
}
|
|
320
|
+
const method = (await this.paymentMethodService.findAll(ctx)).items.find((m) => m.code === code);
|
|
321
|
+
if (!method || method.handler.code !== constants_1.HANDLER_CODE) {
|
|
322
|
+
throw new core_1.UserInputError(`The payment method ${code} is not an Orboni one.`);
|
|
323
|
+
}
|
|
324
|
+
return method;
|
|
325
|
+
}
|
|
326
|
+
argsOf(method) {
|
|
327
|
+
const args = {};
|
|
328
|
+
for (const arg of method.handler.args) {
|
|
329
|
+
args[arg.name] = arg.value;
|
|
330
|
+
}
|
|
331
|
+
return args;
|
|
332
|
+
}
|
|
333
|
+
client(args) {
|
|
334
|
+
const key = String(args.apiKey ?? '').trim();
|
|
335
|
+
if (!/^sk_(live|test)_/.test(key)) {
|
|
336
|
+
throw new core_1.UserInputError('The Orboni payment method has no secret key: set sk_live_… or sk_test_… in its settings.');
|
|
337
|
+
}
|
|
338
|
+
return new orboni_1.Orboni(key, this.options.apiUrl ? { baseUrl: this.options.apiUrl } : {});
|
|
339
|
+
}
|
|
340
|
+
async note(ctx, order, note) {
|
|
341
|
+
await this.historyService.createHistoryEntryForOrder({ ctx, orderId: order.id, type: generated_types_1.HistoryEntryType.ORDER_NOTE, data: { note } }, false);
|
|
342
|
+
}
|
|
343
|
+
/** An Orboni call, its refusal turned into an error with Orboni's own words. */
|
|
344
|
+
async call(fn) {
|
|
345
|
+
try {
|
|
346
|
+
return await fn();
|
|
347
|
+
}
|
|
348
|
+
catch (error) {
|
|
349
|
+
if (error instanceof orboni_1.OrboniError) {
|
|
350
|
+
core_1.Logger.warn(`Orboni refused: ${error.message}`, constants_1.loggerCtx);
|
|
351
|
+
throw new core_1.UserInputError(`Orboni: ${error.message}`);
|
|
352
|
+
}
|
|
353
|
+
throw error;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
async locked(key, fn) {
|
|
357
|
+
const before = this.locks.get(key) ?? Promise.resolve();
|
|
358
|
+
const run = before.catch(() => undefined).then(fn);
|
|
359
|
+
this.locks.set(key, run);
|
|
360
|
+
try {
|
|
361
|
+
return await run;
|
|
362
|
+
}
|
|
363
|
+
finally {
|
|
364
|
+
if (this.locks.get(key) === run) {
|
|
365
|
+
this.locks.delete(key);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
exports.OrboniService = OrboniService;
|
|
371
|
+
exports.OrboniService = OrboniService = __decorate([
|
|
372
|
+
(0, common_1.Injectable)(),
|
|
373
|
+
__param(0, (0, common_1.Inject)(constants_1.ORBONI_PLUGIN_OPTIONS)),
|
|
374
|
+
__metadata("design:paramtypes", [Object, core_1.ActiveOrderService,
|
|
375
|
+
core_1.OrderService,
|
|
376
|
+
core_1.PaymentMethodService,
|
|
377
|
+
core_1.HistoryService,
|
|
378
|
+
core_1.RequestContextService,
|
|
379
|
+
core_1.TransactionalConnection])
|
|
380
|
+
], OrboniService);
|
|
381
|
+
/** What the payment keeps: `public` is what the Shop API shows. */
|
|
382
|
+
function paymentMetadata(session) {
|
|
383
|
+
return {
|
|
384
|
+
sessionId: session.id,
|
|
385
|
+
livemode: session.livemode,
|
|
386
|
+
public: {
|
|
387
|
+
asset: session.payment?.asset ?? null,
|
|
388
|
+
coin: session.payment?.coin ?? null,
|
|
389
|
+
network: session.payment?.chain ?? null,
|
|
390
|
+
amount: session.payment?.amount ?? null,
|
|
391
|
+
},
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
/** The order's lines, as "Blue mug × 2, Tea × 1", cut to Orboni's 250 characters. */
|
|
395
|
+
function describe(order) {
|
|
396
|
+
const lines = (order.lines ?? [])
|
|
397
|
+
.map((line) => `${line.productVariant?.name ?? 'Item'} × ${line.quantity}`)
|
|
398
|
+
.join(', ');
|
|
399
|
+
if (lines === '') {
|
|
400
|
+
return null;
|
|
401
|
+
}
|
|
402
|
+
return lines.length > 250 ? `${lines.slice(0, 249)}…` : lines;
|
|
403
|
+
}
|
|
404
|
+
function fill(url, code) {
|
|
405
|
+
return url ? url.replace(/\{ORDER_CODE\}/g, encodeURIComponent(code)) : null;
|
|
406
|
+
}
|
|
407
|
+
function text(value) {
|
|
408
|
+
return typeof value === 'string' && value.trim() !== '' ? value.trim() : null;
|
|
409
|
+
}
|
package/dist/status.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How an Orboni checkout session reads in Vendure's terms. Kept apart from
|
|
3
|
+
* the service so it is tested without Vendure.
|
|
4
|
+
*
|
|
5
|
+
* A session is `open`, `complete` or `expired`; its money is `unpaid`,
|
|
6
|
+
* `processing` (seen on the chain, not final), `partially_paid` (final but
|
|
7
|
+
* short), `held` (for the merchant to review in Orboni) or `paid` (final:
|
|
8
|
+
* only with `complete`).
|
|
9
|
+
*/
|
|
10
|
+
export interface SessionState {
|
|
11
|
+
status: 'open' | 'complete' | 'expired';
|
|
12
|
+
payment_status: 'unpaid' | 'processing' | 'partially_paid' | 'paid' | 'held';
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* - paid: `Settled` — the order is paid;
|
|
16
|
+
* - on its way, or held for review: `Authorized` — the order is placed and
|
|
17
|
+
* waits for its payment, which is settled once Orboni says it is paid;
|
|
18
|
+
* - anything else: nothing to record yet (`null`).
|
|
19
|
+
*/
|
|
20
|
+
export declare function paymentState(session: SessionState): 'Settled' | 'Authorized' | null;
|
|
21
|
+
/** What the buyer is told when a session has nothing to record yet. */
|
|
22
|
+
export declare function notPaidReason(session: SessionState): string;
|
package/dist/status.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.paymentState = paymentState;
|
|
4
|
+
exports.notPaidReason = notPaidReason;
|
|
5
|
+
/**
|
|
6
|
+
* - paid: `Settled` — the order is paid;
|
|
7
|
+
* - on its way, or held for review: `Authorized` — the order is placed and
|
|
8
|
+
* waits for its payment, which is settled once Orboni says it is paid;
|
|
9
|
+
* - anything else: nothing to record yet (`null`).
|
|
10
|
+
*/
|
|
11
|
+
function paymentState(session) {
|
|
12
|
+
if (session.status === 'complete' && session.payment_status === 'paid') {
|
|
13
|
+
return 'Settled';
|
|
14
|
+
}
|
|
15
|
+
if (session.payment_status === 'processing' || session.payment_status === 'held') {
|
|
16
|
+
return 'Authorized';
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
/** What the buyer is told when a session has nothing to record yet. */
|
|
21
|
+
function notPaidReason(session) {
|
|
22
|
+
if (session.payment_status === 'partially_paid') {
|
|
23
|
+
return session.status === 'open'
|
|
24
|
+
? 'Only part of the payment has arrived: the payment page shows what is still to send.'
|
|
25
|
+
: 'Only part of the payment arrived before the payment page closed. The store will be in touch about it.';
|
|
26
|
+
}
|
|
27
|
+
if (session.status === 'expired') {
|
|
28
|
+
return 'The payment page closed before it was paid. Open it again to pay.';
|
|
29
|
+
}
|
|
30
|
+
return 'The order is not paid yet. Pay on the payment page, or choose another way to pay.';
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,57 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@orboni/vendure-plugin",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Crypto payments for Vendure: USDT, USDC, Bitcoin and more, paid straight to your own wallets through Orboni's payment page.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"vendure",
|
|
7
|
+
"vendure-plugin",
|
|
8
|
+
"vendure-payment",
|
|
9
|
+
"orboni",
|
|
10
|
+
"crypto",
|
|
11
|
+
"payments",
|
|
12
|
+
"usdt",
|
|
13
|
+
"usdc",
|
|
14
|
+
"bitcoin",
|
|
15
|
+
"payment-gateway"
|
|
16
|
+
],
|
|
17
|
+
"homepage": "https://orboni.com/docs/vendure",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/orboni/vendure-plugin-orboni.git"
|
|
21
|
+
},
|
|
22
|
+
"bugs": "https://github.com/orboni/vendure-plugin-orboni/issues",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"author": "Orboni <support@orboni.com>",
|
|
25
|
+
"main": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"README.md",
|
|
30
|
+
"CHANGELOG.md",
|
|
31
|
+
"LICENSE"
|
|
32
|
+
],
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=20"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "rm -rf dist && tsc -p tsconfig.json",
|
|
38
|
+
"test": "npm run build && node --test test/*.test.js",
|
|
39
|
+
"prepublishOnly": "npm test"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"body-parser": "^2.2.0",
|
|
43
|
+
"graphql-tag": "^2.12.6",
|
|
44
|
+
"orboni": "^1.0.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"@nestjs/common": "*",
|
|
48
|
+
"@nestjs/graphql": "*",
|
|
49
|
+
"@vendure/core": "^3.0.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@types/body-parser": "^1.19.5",
|
|
53
|
+
"@types/node": "^22.0.0",
|
|
54
|
+
"@vendure/core": "3.8.2",
|
|
55
|
+
"typescript": "^5.6.0"
|
|
56
|
+
}
|
|
57
|
+
}
|