@riocrypto/common 1.0.445 → 1.0.447
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/build/clients/ccxt-client.js +0 -3
- package/build/clients/kushki-client.d.ts +14 -0
- package/build/clients/kushki-client.js +150 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/models/kushki-payment.d.ts +1 -1
- package/build/models/kushki-payment.js +1 -0
- package/package.json +1 -1
|
@@ -91,9 +91,7 @@ class CCXTClient {
|
|
|
91
91
|
}
|
|
92
92
|
getBuyQuote(amount, crypto, fiat) {
|
|
93
93
|
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
-
console.log("getBuyQuote", amount, crypto, fiat);
|
|
95
94
|
if (this.env === "production") {
|
|
96
|
-
console.log("its prod");
|
|
97
95
|
const exchange = yield this.getOptimalExchange(crypto);
|
|
98
96
|
if (!exchange)
|
|
99
97
|
throw new Error("Unable to get optimal exchange");
|
|
@@ -110,7 +108,6 @@ class CCXTClient {
|
|
|
110
108
|
};
|
|
111
109
|
}
|
|
112
110
|
else {
|
|
113
|
-
console.log("its dev");
|
|
114
111
|
return {
|
|
115
112
|
price: 0.5,
|
|
116
113
|
amountCrypto: amount,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BusinessUser } from "../types/business-user";
|
|
2
|
+
import { Order } from "../types/order";
|
|
3
|
+
import { User } from "../types/user";
|
|
4
|
+
declare class KushkiClient {
|
|
5
|
+
private privateMerchantId;
|
|
6
|
+
private environment;
|
|
7
|
+
private baseUrl;
|
|
8
|
+
constructor(privateMerchantId: string, environment: "sandbox" | "production");
|
|
9
|
+
createPaymentLink(order: Order, user: User, token: string): Promise<any>;
|
|
10
|
+
createBankPaymentToken(order: Order, user: User | BusinessUser): Promise<any>;
|
|
11
|
+
createBankPayment(order: Order, user: User | BusinessUser, token: string): Promise<any>;
|
|
12
|
+
}
|
|
13
|
+
export declare const kushkiClient: KushkiClient;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.kushkiClient = void 0;
|
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
const user_type_1 = require("../types/user-type");
|
|
18
|
+
class KushkiClient {
|
|
19
|
+
constructor(privateMerchantId, environment) {
|
|
20
|
+
this.privateMerchantId = privateMerchantId;
|
|
21
|
+
this.environment = environment;
|
|
22
|
+
this.baseUrl = `https://api${this.environment === "production" ? "." : "-uat."}kushkipagos.com`;
|
|
23
|
+
}
|
|
24
|
+
createPaymentLink(order, user, token) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const body = {
|
|
27
|
+
token,
|
|
28
|
+
amount: {
|
|
29
|
+
currency: order.fiat,
|
|
30
|
+
subtotalIva: 0,
|
|
31
|
+
subtotalIva0: order.amountFiat,
|
|
32
|
+
iva: 0,
|
|
33
|
+
ice: 0,
|
|
34
|
+
},
|
|
35
|
+
contactDetails: {
|
|
36
|
+
firstName: user.firstName,
|
|
37
|
+
lastName: user.lastName,
|
|
38
|
+
email: user.email,
|
|
39
|
+
documentType: "CC",
|
|
40
|
+
phoneNumber: user.phoneNumber,
|
|
41
|
+
},
|
|
42
|
+
orderDetails: {
|
|
43
|
+
siteDomain: "riocrypto.com",
|
|
44
|
+
shippingDetails: {
|
|
45
|
+
name: `${user.firstName} ${user.lastName}`,
|
|
46
|
+
phone: user.phoneNumber,
|
|
47
|
+
address1: user.street1,
|
|
48
|
+
address2: user.street2,
|
|
49
|
+
city: user.city,
|
|
50
|
+
region: user.state,
|
|
51
|
+
country: user.country,
|
|
52
|
+
zipcode: user.postalCode,
|
|
53
|
+
},
|
|
54
|
+
billingDetails: {
|
|
55
|
+
name: `${user.firstName} ${user.lastName}`,
|
|
56
|
+
phone: user.phoneNumber,
|
|
57
|
+
address1: user.street1,
|
|
58
|
+
address2: user.street2,
|
|
59
|
+
city: user.city,
|
|
60
|
+
region: user.state,
|
|
61
|
+
country: user.country,
|
|
62
|
+
zipcode: user.postalCode,
|
|
63
|
+
},
|
|
64
|
+
product: {
|
|
65
|
+
id: order.id,
|
|
66
|
+
title: order.crypto,
|
|
67
|
+
price: order.amountFiat,
|
|
68
|
+
sku: order.id,
|
|
69
|
+
quantity: 1,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
const response = yield (0, axios_1.default)({
|
|
74
|
+
method: "post",
|
|
75
|
+
url: `${this.baseUrl}/card/v1/charges`,
|
|
76
|
+
headers: {
|
|
77
|
+
"Content-Type": "application/json",
|
|
78
|
+
"Private-Merchant-Id": this.privateMerchantId,
|
|
79
|
+
"Accept-Encoding": "gzip,deflate,compress",
|
|
80
|
+
},
|
|
81
|
+
data: body,
|
|
82
|
+
});
|
|
83
|
+
const data = response.data;
|
|
84
|
+
return data;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
createBankPaymentToken(order, user) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
const body = {
|
|
90
|
+
amount: {
|
|
91
|
+
subtotalIva: 0,
|
|
92
|
+
subtotalIva0: order.amountFiat,
|
|
93
|
+
iva: 0,
|
|
94
|
+
},
|
|
95
|
+
callbackUrl: "https://riocrypto.com",
|
|
96
|
+
userType: user.type === user_type_1.UserType.Business ? 1 : 0,
|
|
97
|
+
documentType: "CC",
|
|
98
|
+
documentNumber: "123456789",
|
|
99
|
+
paymentDescription: `Compra de ${order.crypto} en riocrypto.com`,
|
|
100
|
+
email: user.email,
|
|
101
|
+
currency: order.fiat,
|
|
102
|
+
};
|
|
103
|
+
const response = yield (0, axios_1.default)({
|
|
104
|
+
method: "post",
|
|
105
|
+
url: `${this.baseUrl}/transfer/v1/tokens`,
|
|
106
|
+
headers: {
|
|
107
|
+
"Content-Type": "application/json",
|
|
108
|
+
"Private-Merchant-Id": this.privateMerchantId,
|
|
109
|
+
"Accept-Encoding": "gzip,deflate,compress",
|
|
110
|
+
},
|
|
111
|
+
data: body,
|
|
112
|
+
});
|
|
113
|
+
const data = response.data;
|
|
114
|
+
return data;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
createBankPayment(order, user, token) {
|
|
118
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
const body = {
|
|
120
|
+
token,
|
|
121
|
+
amount: {
|
|
122
|
+
subtotalIva: 0,
|
|
123
|
+
subtotalIva0: order.amountFiat,
|
|
124
|
+
iva: 0,
|
|
125
|
+
},
|
|
126
|
+
contactDetails: {
|
|
127
|
+
fullName: user.type === user_type_1.UserType.Business
|
|
128
|
+
? user.companyName
|
|
129
|
+
: `${user.firstName} ${user.lastName}`,
|
|
130
|
+
email: user.email,
|
|
131
|
+
documentType: "CC",
|
|
132
|
+
phoneNumber: user.phoneNumber,
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
const response = yield (0, axios_1.default)({
|
|
136
|
+
method: "post",
|
|
137
|
+
url: `${this.baseUrl}/transfer/v1/init`,
|
|
138
|
+
headers: {
|
|
139
|
+
"Content-Type": "application/json",
|
|
140
|
+
"Private-Merchant-Id": this.privateMerchantId,
|
|
141
|
+
"Accept-Encoding": "gzip,deflate,compress",
|
|
142
|
+
},
|
|
143
|
+
data: body,
|
|
144
|
+
});
|
|
145
|
+
const data = response.data;
|
|
146
|
+
return data;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.kushkiClient = new KushkiClient(process.env.KUSHKI_PRIVATE_MERCHANT_ID, process.env.KUSHKI_ENV);
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -177,3 +177,4 @@ __exportStar(require("./models/kushki-payment"), exports);
|
|
|
177
177
|
__exportStar(require("./clients/bitstamp-client"), exports);
|
|
178
178
|
__exportStar(require("./clients/ccxt-client"), exports);
|
|
179
179
|
__exportStar(require("./clients/fixer-client"), exports);
|
|
180
|
+
__exportStar(require("./clients/kushki-client"), exports);
|
|
@@ -12,5 +12,5 @@ interface KushkiPaymentDoc extends mongoose.Document {
|
|
|
12
12
|
interface KushkiPaymentModel extends mongoose.Model<KushkiPaymentDoc> {
|
|
13
13
|
build(attrs: KushkiPaymentAttrs): KushkiPaymentDoc;
|
|
14
14
|
}
|
|
15
|
-
declare const buildKushkiPayment: (mongoose: typeof mongoose) => KushkiPaymentModel
|
|
15
|
+
declare const buildKushkiPayment: (mongoose: typeof mongoose) => KushkiPaymentModel;
|
|
16
16
|
export { buildKushkiPayment, KushkiPaymentDoc };
|