@ngn-net/payment-provider-sdk 1.0.6 → 1.0.8

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,9 +1,9 @@
1
- import { FiatCurrency, PayCurrency, PaymentIntentStatus } from '../entity/crypto.entity';
1
+ import { FiatCurrency, PayCurrency, PaymentIntentStatus } from "../entity/crypto.entity";
2
2
  export declare const RABBIT_URI: () => string[];
3
3
  export declare const rabbitUri: string[];
4
4
  export interface RabbitAddress {
5
5
  exchange: string;
6
- type: 'topic' | 'direct' | 'fanout';
6
+ type: "topic" | "direct" | "fanout";
7
7
  routingkeys: {
8
8
  [key: string]: {
9
9
  key: string;
@@ -61,7 +61,7 @@ export interface CreateCryptoIntentResponse {
61
61
  amountInFiat: number;
62
62
  fiatCurrency: FiatCurrency;
63
63
  payCurrency: PayCurrency;
64
- payAddress: string;
64
+ payAdress: string;
65
65
  payAmount: number;
66
66
  status: PaymentIntentStatus;
67
67
  orderId: string;
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PaymentRabbitApi = exports.rabbitUri = exports.RABBIT_URI = void 0;
4
4
  const RABBIT_URI = () => {
5
- const rabbitUri = process.env.RABBIT_URI || 'amqp://user:pass@localhost:5672';
6
- const [creadential, hosts] = rabbitUri.split('@');
7
- const hostList = hosts.split(',');
5
+ const rabbitUri = process.env.RABBIT_URI || "amqp://user:pass@localhost:5672";
6
+ const [creadential, hosts] = rabbitUri.split("@");
7
+ const hostList = hosts.split(",");
8
8
  return hostList.map((host, index) => {
9
9
  return `${creadential}@${host}`;
10
10
  });
@@ -12,23 +12,23 @@ const RABBIT_URI = () => {
12
12
  exports.RABBIT_URI = RABBIT_URI;
13
13
  exports.rabbitUri = (0, exports.RABBIT_URI)();
14
14
  exports.PaymentRabbitApi = {
15
- exchange: 'payment',
16
- type: 'topic',
15
+ exchange: "payment",
16
+ type: "topic",
17
17
  routingkeys: {
18
18
  default: {
19
- key: 'default',
19
+ key: "default",
20
20
  },
21
21
  events: {
22
- key: 'paymentEvents',
22
+ key: "paymentEvents",
23
23
  },
24
24
  stripe_checkout: {
25
- key: 'stripeCheckout',
25
+ key: "stripeCheckout",
26
26
  },
27
27
  stripe_intent: {
28
- key: 'stripePaymentIntent',
28
+ key: "stripePaymentIntent",
29
29
  },
30
30
  crypto_intent: {
31
- key: 'cryptoPaymentIntent',
31
+ key: "cryptoIntent",
32
32
  },
33
33
  },
34
34
  };
@@ -0,0 +1,6 @@
1
+ import { PayCurrency } from "../entity/crypto.entity";
2
+ export declare class CreateCryptoPaymentDto {
3
+ orderId: string;
4
+ amount: number;
5
+ currency: PayCurrency;
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.CreateCryptoPaymentDto = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ const class_validator_1 = require("class-validator");
15
+ const crypto_entity_1 = require("../entity/crypto.entity");
16
+ class CreateCryptoPaymentDto {
17
+ }
18
+ exports.CreateCryptoPaymentDto = CreateCryptoPaymentDto;
19
+ __decorate([
20
+ (0, swagger_1.ApiProperty)(),
21
+ (0, class_validator_1.IsNotEmpty)(),
22
+ (0, class_validator_1.IsString)(),
23
+ __metadata("design:type", String)
24
+ ], CreateCryptoPaymentDto.prototype, "orderId", void 0);
25
+ __decorate([
26
+ (0, swagger_1.ApiProperty)({ example: 50 }),
27
+ (0, class_validator_1.IsNotEmpty)(),
28
+ (0, class_validator_1.IsNumber)(),
29
+ (0, class_validator_1.Min)(50),
30
+ __metadata("design:type", Number)
31
+ ], CreateCryptoPaymentDto.prototype, "amount", void 0);
32
+ __decorate([
33
+ (0, swagger_1.ApiProperty)({ enum: crypto_entity_1.PayCurrency, example: crypto_entity_1.PayCurrency.usdt }),
34
+ (0, class_validator_1.IsNotEmpty)(),
35
+ (0, class_validator_1.IsEnum)(crypto_entity_1.PayCurrency),
36
+ __metadata("design:type", String)
37
+ ], CreateCryptoPaymentDto.prototype, "currency", void 0);
@@ -26,6 +26,7 @@ export declare class CryptoIntent {
26
26
  payAddress?: string;
27
27
  payAmount?: number;
28
28
  receivedAmount?: number;
29
+ receivedAmountFiat?: string;
29
30
  purchaseId?: string;
30
31
  includeFee: boolean;
31
32
  fees?: Partial<{
@@ -33,5 +34,6 @@ export declare class CryptoIntent {
33
34
  serviceFee: number;
34
35
  withdrawalFee: number;
35
36
  }>;
36
- metaData?: {};
37
+ metaData?: Record<string, unknown>;
38
+ rawResponse?: any;
37
39
  }
package/dist/main.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export * from "./payment.module";
2
2
  export * from "./payment.provider";
3
+ export * from "./dto/crypto.dto";
3
4
  export * from "./dto/stripe.dto";
4
5
  export * from "./dto/common.interface";
6
+ export * from "./entity/crypto.entity";
package/dist/main.js CHANGED
@@ -16,5 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./payment.module"), exports);
18
18
  __exportStar(require("./payment.provider"), exports);
19
+ __exportStar(require("./dto/crypto.dto"), exports);
19
20
  __exportStar(require("./dto/stripe.dto"), exports);
20
21
  __exportStar(require("./dto/common.interface"), exports);
22
+ __exportStar(require("./entity/crypto.entity"), exports);
@@ -1,2 +1,7 @@
1
+ import { DynamicModule } from "@nestjs/common";
2
+ export interface PaymentModuleOptions {
3
+ uri: string | string[];
4
+ }
1
5
  export declare class PaymentModule {
6
+ static forRoot(options: PaymentModuleOptions): DynamicModule;
2
7
  }
@@ -5,17 +5,42 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
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
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
+ var PaymentModule_1;
8
9
  Object.defineProperty(exports, "__esModule", { value: true });
9
10
  exports.PaymentModule = void 0;
10
11
  const common_1 = require("@nestjs/common");
12
+ const nestjs_rabbitmq_1 = require("@golevelup/nestjs-rabbitmq");
11
13
  const payment_provider_1 = require("./payment.provider");
12
- let PaymentModule = class PaymentModule {
14
+ const common_interface_1 = require("./dto/common.interface");
15
+ let PaymentModule = PaymentModule_1 = class PaymentModule {
16
+ static forRoot(options) {
17
+ return {
18
+ module: PaymentModule_1,
19
+ imports: [
20
+ nestjs_rabbitmq_1.RabbitMQModule.forRoot({
21
+ uri: options.uri,
22
+ exchanges: [
23
+ {
24
+ name: common_interface_1.PaymentRabbitApi.exchange,
25
+ type: common_interface_1.PaymentRabbitApi.type,
26
+ createExchangeIfNotExists: true,
27
+ },
28
+ ],
29
+ enableControllerDiscovery: true,
30
+ connectionInitOptions: {
31
+ timeout: 20000,
32
+ wait: false,
33
+ reject: false,
34
+ },
35
+ }),
36
+ ],
37
+ providers: [payment_provider_1.PaymentProvider],
38
+ exports: [payment_provider_1.PaymentProvider],
39
+ };
40
+ }
13
41
  };
14
42
  exports.PaymentModule = PaymentModule;
15
- exports.PaymentModule = PaymentModule = __decorate([
43
+ exports.PaymentModule = PaymentModule = PaymentModule_1 = __decorate([
16
44
  (0, common_1.Global)(),
17
- (0, common_1.Module)({
18
- providers: [payment_provider_1.PaymentProvider],
19
- exports: [payment_provider_1.PaymentProvider],
20
- })
45
+ (0, common_1.Module)({})
21
46
  ], PaymentModule);
@@ -1,10 +1,12 @@
1
- import { CreateStripeCheckoutDto, CreateStripePaymentIntentDto } from './dto/stripe.dto';
2
- import { AmqpConnection } from '@golevelup/nestjs-rabbitmq';
3
- import { CreateStripeCheckoutResponse, CreateStripePaymentIntentResponse, PaymentEvent } from './dto/common.interface';
1
+ import { CreateStripeCheckoutDto, CreateStripePaymentIntentDto } from "./dto/stripe.dto";
2
+ import { AmqpConnection } from "@golevelup/nestjs-rabbitmq";
3
+ import { CreateCryptoIntentResponse, CreateStripeCheckoutResponse, CreateStripePaymentIntentResponse, PaymentEvent } from "./dto/common.interface";
4
+ import { CreateCryptoPaymentDto } from "./dto/crypto.dto";
4
5
  export declare class PaymentProvider {
5
6
  private readonly rabbit;
6
7
  constructor(rabbit: AmqpConnection);
7
8
  createStripeCheckout(payload: CreateStripeCheckoutDto): Promise<CreateStripeCheckoutResponse>;
8
9
  createStripePaymentIntent(payload: CreateStripePaymentIntentDto): Promise<CreateStripePaymentIntentResponse>;
10
+ createCryptoPayment(payload: CreateCryptoPaymentDto): Promise<CreateCryptoIntentResponse>;
9
11
  emitPaymentEvent(event: PaymentEvent): Promise<void>;
10
12
  }
@@ -39,6 +39,17 @@ let PaymentProvider = class PaymentProvider {
39
39
  }
40
40
  return res.data;
41
41
  }
42
+ async createCryptoPayment(payload) {
43
+ const res = await this.rabbit.request({
44
+ exchange: common_interface_1.PaymentRabbitApi.exchange,
45
+ routingKey: common_interface_1.PaymentRabbitApi.routingkeys.crypto_intent.key,
46
+ payload,
47
+ });
48
+ if (res.code !== 200) {
49
+ throw new Error(res.message);
50
+ }
51
+ return res.data;
52
+ }
42
53
  async emitPaymentEvent(event) {
43
54
  await this.rabbit.publish(common_interface_1.PaymentRabbitApi.exchange, common_interface_1.PaymentRabbitApi.routingkeys.events.key, event);
44
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngn-net/payment-provider-sdk",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Payment provider SDK",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/main.d.ts",
@@ -15,17 +15,26 @@
15
15
  "dist"
16
16
  ],
17
17
  "dependencies": {
18
+ "@ngn-net/giftcard-shared": "1.0.59",
18
19
  "class-transformer": "^0.5.1",
19
20
  "class-validator": "^0.15.1"
20
21
  },
21
22
  "peerDependencies": {
22
23
  "@golevelup/nestjs-rabbitmq": "^9.0.2",
23
24
  "@nestjs/common": "^11.1.26",
24
- "@nestjs/swagger": "^11.4.4",
25
- "@ngn-net/giftcard-shared": "*"
25
+ "@nestjs/swagger": "^11.4.4"
26
26
  },
27
27
  "devDependencies": {
28
+ "@golevelup/nestjs-discovery": "^7.0.3",
29
+ "@golevelup/nestjs-rabbitmq": "^9.0.2",
30
+ "@nestjs/common": "^11.2.3",
31
+ "@nestjs/core": "^11.2.3",
32
+ "@nestjs/swagger": "^11.4.7",
33
+ "@types/amqplib": "^0.10.8",
28
34
  "@types/node": "^25.9.2",
35
+ "amqplib": "^0.10.9",
36
+ "reflect-metadata": "^0.2.2",
37
+ "rxjs": "^7.8.2",
29
38
  "typescript": "^6.0.3"
30
39
  }
31
40
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"common.interface.js","sourceRoot":"","sources":["../../src/dto/common.interface.ts"],"names":[],"mappings":";;;AAAO,MAAM,UAAU,GAAG,GAAa,EAAE;IACvC,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,uBAAuB,CAAC;IAEpE,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClD,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAElC,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EA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ED
@@ -1,4 +0,0 @@
1
- export * from "./payment.module";
2
- export * from "./payment.provider";
3
- export * from "./dto/stripe.dto";
4
- export * from "./dto/common.interface";
package/dist/index.js DELETED
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./payment.module"), exports);
18
- __exportStar(require("./payment.provider"), exports);
19
- __exportStar(require("./dto/stripe.dto"), exports);
20
- __exportStar(require("./dto/common.interface"), exports);
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,qDAAmC;AAEnC,mDAAiC;AACjC,yDAAuC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"payment.module.js","sourceRoot":"","sources":["../src/payment.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAgD;AAChD,yDAAqD;AAO9C,IAAM,aAAa,GAAnB,MAAM,aAAa;CAAG,CAAA;AAAhB,sCAAa;wBAAb,aAAa;IALzB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,kCAAe,CAAC;QAC5B,OAAO,EAAE,CAAC,kCAAe,CAAC;KAC3B,CAAC;GACW,aAAa,CAAG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"payment.provider.js","sourceRoot":"","sources":["../src/payment.provider.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAoD;AAMpD,gEAA4D;AAE5D,6DAIgC;AAGzB,IAAM,eAAe,GAArB,MAAM,eAAe;IAI1B,oBAAoB,CAAC,OAAgC;QACnD,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAA+B;YACvD,QAAQ,EAAE,mCAAgB,CAAC,QAAQ;YACnC,UAAU,EAAE,mCAAgB,CAAC,WAAW,CAAC,eAAe,CAAC,GAAG;YAC5D,OAAO;SACR,CAAC,CAAC;IACL,CAAC;IAED,yBAAyB,CAAC,OAAqC;QAC7D,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAoC;YAC5D,QAAQ,EAAE,mCAAgB,CAAC,QAAQ;YACnC,UAAU,EAAE,mCAAgB,CAAC,WAAW,CAAC,aAAa,CAAC,GAAG;YAC1D,OAAO;SACR,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAnBY,0CAAe;AAET;IADhB,IAAA,eAAM,GAAE;8BACgB,gCAAc;+CAAC;0BAF7B,eAAe;IAD3B,IAAA,mBAAU,GAAE;GACA,eAAe,CAmB3B"}