@ngn-net/payment-provider-sdk 1.0.8 → 1.0.10
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/app.controller.d.ts +6 -0
- package/dist/app.controller.js +33 -0
- package/dist/app.module.d.ts +3 -0
- package/dist/app.module.js +27 -0
- package/dist/app.service.d.ts +6 -0
- package/dist/app.service.js +37 -0
- package/dist/dto/common.interface.d.ts +3 -0
- package/dist/dto/common.interface.js +3 -0
- package/dist/dto/nowPayment.response.d.ts +79 -0
- package/dist/dto/nowPayment.response.js +2 -0
- package/dist/payment.provider.d.ts +2 -0
- package/dist/payment.provider.js +12 -0
- package/package.json +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AppController = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const app_service_1 = require("./app.service");
|
|
15
|
+
let AppController = class AppController {
|
|
16
|
+
constructor(appService) {
|
|
17
|
+
this.appService = appService;
|
|
18
|
+
}
|
|
19
|
+
getHello() {
|
|
20
|
+
return this.appService.getHello();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
exports.AppController = AppController;
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, common_1.Get)(),
|
|
26
|
+
__metadata("design:type", Function),
|
|
27
|
+
__metadata("design:paramtypes", []),
|
|
28
|
+
__metadata("design:returntype", void 0)
|
|
29
|
+
], AppController.prototype, "getHello", null);
|
|
30
|
+
exports.AppController = AppController = __decorate([
|
|
31
|
+
(0, common_1.Controller)(),
|
|
32
|
+
__metadata("design:paramtypes", [app_service_1.AppService])
|
|
33
|
+
], AppController);
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AppModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const payment_provider_sdk_1 = require("@ngn-net/payment-provider-sdk");
|
|
12
|
+
const app_controller_1 = require("./app.controller");
|
|
13
|
+
const app_service_1 = require("./app.service");
|
|
14
|
+
require("dotenv/config");
|
|
15
|
+
if (!process.env.RABBIT_URI) {
|
|
16
|
+
throw new Error("RABBIT_URI is not set");
|
|
17
|
+
}
|
|
18
|
+
let AppModule = class AppModule {
|
|
19
|
+
};
|
|
20
|
+
exports.AppModule = AppModule;
|
|
21
|
+
exports.AppModule = AppModule = __decorate([
|
|
22
|
+
(0, common_1.Module)({
|
|
23
|
+
imports: [payment_provider_sdk_1.PaymentModule.forRoot({ uri: process.env.RABBIT_URI })],
|
|
24
|
+
controllers: [app_controller_1.AppController],
|
|
25
|
+
providers: [app_service_1.AppService],
|
|
26
|
+
})
|
|
27
|
+
], AppModule);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PaymentProvider } from "@ngn-net/payment-provider-sdk";
|
|
2
|
+
export declare class AppService {
|
|
3
|
+
private readonly paymentProvider;
|
|
4
|
+
constructor(paymentProvider: PaymentProvider);
|
|
5
|
+
getHello(): Promise<import("@ngn-net/payment-provider-sdk").CreateStripeCheckoutResponse>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AppService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const payment_provider_sdk_1 = require("@ngn-net/payment-provider-sdk");
|
|
15
|
+
let AppService = class AppService {
|
|
16
|
+
constructor(paymentProvider) {
|
|
17
|
+
this.paymentProvider = paymentProvider;
|
|
18
|
+
}
|
|
19
|
+
async getHello() {
|
|
20
|
+
try {
|
|
21
|
+
return await this.paymentProvider.createStripeCheckout({
|
|
22
|
+
amount: 1000,
|
|
23
|
+
orderId: "123e4567-e89b-12d3-a456-426614174000",
|
|
24
|
+
productName: "Test Product",
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
console.error("SDK error:", err.message);
|
|
29
|
+
throw err;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
exports.AppService = AppService;
|
|
34
|
+
exports.AppService = AppService = __decorate([
|
|
35
|
+
(0, common_1.Injectable)(),
|
|
36
|
+
__metadata("design:paramtypes", [payment_provider_sdk_1.PaymentProvider])
|
|
37
|
+
], AppService);
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export interface NPGetPayment {
|
|
2
|
+
payment_id: number;
|
|
3
|
+
invoice_id: number | null;
|
|
4
|
+
payment_status: "waiting" | "confirming" | "confirmed" | "sending" | "partially_paid" | "finished" | "failed" | "refunded" | "expired";
|
|
5
|
+
pay_address: string;
|
|
6
|
+
payin_extra_id: string | null;
|
|
7
|
+
price_amount: number;
|
|
8
|
+
price_currency: string;
|
|
9
|
+
pay_amount: number;
|
|
10
|
+
actually_paid: number;
|
|
11
|
+
pay_currency: string;
|
|
12
|
+
order_id: string;
|
|
13
|
+
order_description: string;
|
|
14
|
+
purchase_id: number;
|
|
15
|
+
outcome_amount: number;
|
|
16
|
+
outcome_currency: string;
|
|
17
|
+
payout_hash: string | null;
|
|
18
|
+
payin_hash: string | null;
|
|
19
|
+
created_at: string;
|
|
20
|
+
updated_at: string;
|
|
21
|
+
burning_percent: string | null;
|
|
22
|
+
type: "crypto2crypto" | "crypto2fiat";
|
|
23
|
+
}
|
|
24
|
+
export interface NowPaymentsFee {
|
|
25
|
+
currency: string;
|
|
26
|
+
depositFee: number;
|
|
27
|
+
serviceFee: number;
|
|
28
|
+
withdrawalFee: number;
|
|
29
|
+
}
|
|
30
|
+
export type PaymentStatus = "waiting" | "confirming" | "partially_paid" | "confirmed" | "sending" | "finished" | "failed" | "expired";
|
|
31
|
+
export interface NowPaymentsPaymentCallback {
|
|
32
|
+
actually_paid: number;
|
|
33
|
+
actually_paid_at_fiat: number;
|
|
34
|
+
fee: NowPaymentsFee;
|
|
35
|
+
invoice_id: string | null;
|
|
36
|
+
order_description: string;
|
|
37
|
+
order_id: string;
|
|
38
|
+
outcome_amount: number;
|
|
39
|
+
outcome_currency: string;
|
|
40
|
+
parent_payment_id: number | null;
|
|
41
|
+
pay_address: string;
|
|
42
|
+
pay_amount: number;
|
|
43
|
+
pay_currency: string;
|
|
44
|
+
payin_extra_id: string | null;
|
|
45
|
+
payment_extra_ids: string | null;
|
|
46
|
+
payment_id: string;
|
|
47
|
+
payment_status: PaymentStatus;
|
|
48
|
+
price_amount: number;
|
|
49
|
+
price_currency: string;
|
|
50
|
+
purchase_id: string;
|
|
51
|
+
updated_at: number;
|
|
52
|
+
}
|
|
53
|
+
export interface NowPaymentMinAmount {
|
|
54
|
+
fiat_equivalent: number;
|
|
55
|
+
min_amout: number;
|
|
56
|
+
}
|
|
57
|
+
export interface NowPaymentsCreatePaymentResponse {
|
|
58
|
+
payment_id: string;
|
|
59
|
+
payment_status: PaymentStatus;
|
|
60
|
+
pay_address: string;
|
|
61
|
+
price_amount: number;
|
|
62
|
+
price_currency: string;
|
|
63
|
+
pay_amount: number;
|
|
64
|
+
pay_currency: string;
|
|
65
|
+
order_id: string;
|
|
66
|
+
order_description: string;
|
|
67
|
+
ipn_callback_url: string;
|
|
68
|
+
created_at: string;
|
|
69
|
+
updated_at: string;
|
|
70
|
+
purchase_id: string;
|
|
71
|
+
amount_received: number | null;
|
|
72
|
+
payin_extra_id: string | null;
|
|
73
|
+
smart_contract: string;
|
|
74
|
+
network: string;
|
|
75
|
+
network_precision: number;
|
|
76
|
+
time_limit: number | null;
|
|
77
|
+
burning_percent: number | null;
|
|
78
|
+
expiration_estimate_date: string;
|
|
79
|
+
}
|
|
@@ -2,11 +2,13 @@ import { CreateStripeCheckoutDto, CreateStripePaymentIntentDto } from "./dto/str
|
|
|
2
2
|
import { AmqpConnection } from "@golevelup/nestjs-rabbitmq";
|
|
3
3
|
import { CreateCryptoIntentResponse, CreateStripeCheckoutResponse, CreateStripePaymentIntentResponse, PaymentEvent } from "./dto/common.interface";
|
|
4
4
|
import { CreateCryptoPaymentDto } from "./dto/crypto.dto";
|
|
5
|
+
import { NowPaymentsPaymentCallback } from "./dto/nowPayment.response";
|
|
5
6
|
export declare class PaymentProvider {
|
|
6
7
|
private readonly rabbit;
|
|
7
8
|
constructor(rabbit: AmqpConnection);
|
|
8
9
|
createStripeCheckout(payload: CreateStripeCheckoutDto): Promise<CreateStripeCheckoutResponse>;
|
|
9
10
|
createStripePaymentIntent(payload: CreateStripePaymentIntentDto): Promise<CreateStripePaymentIntentResponse>;
|
|
10
11
|
createCryptoPayment(payload: CreateCryptoPaymentDto): Promise<CreateCryptoIntentResponse>;
|
|
12
|
+
resolveCryptoPayment(payload: NowPaymentsPaymentCallback): Promise<CreateCryptoIntentResponse>;
|
|
11
13
|
emitPaymentEvent(event: PaymentEvent): Promise<void>;
|
|
12
14
|
}
|
package/dist/payment.provider.js
CHANGED
|
@@ -24,6 +24,7 @@ let PaymentProvider = class PaymentProvider {
|
|
|
24
24
|
payload,
|
|
25
25
|
});
|
|
26
26
|
if (res.code !== 200) {
|
|
27
|
+
console.error("Raw RPC response:", JSON.stringify(res));
|
|
27
28
|
throw new Error(res.message);
|
|
28
29
|
}
|
|
29
30
|
return res.data;
|
|
@@ -50,6 +51,17 @@ let PaymentProvider = class PaymentProvider {
|
|
|
50
51
|
}
|
|
51
52
|
return res.data;
|
|
52
53
|
}
|
|
54
|
+
async resolveCryptoPayment(payload) {
|
|
55
|
+
const res = await this.rabbit.request({
|
|
56
|
+
exchange: common_interface_1.PaymentRabbitApi.exchange,
|
|
57
|
+
routingKey: common_interface_1.PaymentRabbitApi.routingkeys.crypto_webhook.key,
|
|
58
|
+
payload,
|
|
59
|
+
});
|
|
60
|
+
if (res.code !== 200) {
|
|
61
|
+
throw new Error(res.message);
|
|
62
|
+
}
|
|
63
|
+
return res.data;
|
|
64
|
+
}
|
|
53
65
|
async emitPaymentEvent(event) {
|
|
54
66
|
await this.rabbit.publish(common_interface_1.PaymentRabbitApi.exchange, common_interface_1.PaymentRabbitApi.routingkeys.events.key, event);
|
|
55
67
|
}
|