@cloudcommerce/app-galaxpay 0.1.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/.turbo/turbo-build.log +4 -0
- package/CHANGELOG.md +1 -0
- package/LICENSE.md +230 -0
- package/README.md +1 -0
- package/assets/onload-expression.js +23 -0
- package/events.js +1 -0
- package/lib/functions-lib/all-parses.d.ts +5 -0
- package/lib/functions-lib/all-parses.js +79 -0
- package/lib/functions-lib/all-parses.js.map +1 -0
- package/lib/functions-lib/ecom/events-to-galaxpay.d.ts +3 -0
- package/lib/functions-lib/ecom/events-to-galaxpay.js +75 -0
- package/lib/functions-lib/ecom/events-to-galaxpay.js.map +1 -0
- package/lib/functions-lib/galaxpay/auth/create-access.d.ts +11 -0
- package/lib/functions-lib/galaxpay/auth/create-access.js +60 -0
- package/lib/functions-lib/galaxpay/auth/create-access.js.map +1 -0
- package/lib/functions-lib/galaxpay/auth/create-axios.d.ts +2 -0
- package/lib/functions-lib/galaxpay/auth/create-axios.js +20 -0
- package/lib/functions-lib/galaxpay/auth/create-axios.js.map +1 -0
- package/lib/functions-lib/galaxpay/auth/gerate-token.d.ts +2 -0
- package/lib/functions-lib/galaxpay/auth/gerate-token.js +32 -0
- package/lib/functions-lib/galaxpay/auth/gerate-token.js.map +1 -0
- package/lib/functions-lib/galaxpay/handle-plans.d.ts +30 -0
- package/lib/functions-lib/galaxpay/handle-plans.js +73 -0
- package/lib/functions-lib/galaxpay/handle-plans.js.map +1 -0
- package/lib/functions-lib/galaxpay/update-subscription.d.ts +8 -0
- package/lib/functions-lib/galaxpay/update-subscription.js +56 -0
- package/lib/functions-lib/galaxpay/update-subscription.js.map +1 -0
- package/lib/functions-lib/galaxpay/webhook.d.ts +3 -0
- package/lib/functions-lib/galaxpay/webhook.js +291 -0
- package/lib/functions-lib/galaxpay/webhook.js.map +1 -0
- package/lib/functions-lib/utils.d.ts +8 -0
- package/lib/functions-lib/utils.js +17 -0
- package/lib/functions-lib/utils.js.map +1 -0
- package/lib/galaxpay-create-transaction.d.ts +71 -0
- package/lib/galaxpay-create-transaction.js +199 -0
- package/lib/galaxpay-create-transaction.js.map +1 -0
- package/lib/galaxpay-events.d.ts +6 -0
- package/lib/galaxpay-events.js +21 -0
- package/lib/galaxpay-events.js.map +1 -0
- package/lib/galaxpay-list-payments.d.ts +7 -0
- package/lib/galaxpay-list-payments.js +105 -0
- package/lib/galaxpay-list-payments.js.map +1 -0
- package/lib/galaxpay.d.ts +76 -0
- package/lib/galaxpay.js +12 -0
- package/lib/galaxpay.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -0
- package/package.json +36 -0
- package/scripts/build.sh +5 -0
- package/src/functions-lib/all-parses.ts +91 -0
- package/src/functions-lib/ecom/events-to-galaxpay.ts +85 -0
- package/src/functions-lib/galaxpay/auth/create-access.ts +80 -0
- package/src/functions-lib/galaxpay/auth/create-axios.ts +21 -0
- package/src/functions-lib/galaxpay/auth/gerate-token.ts +36 -0
- package/src/functions-lib/galaxpay/handle-plans.ts +92 -0
- package/src/functions-lib/galaxpay/update-subscription.ts +73 -0
- package/src/functions-lib/galaxpay/webhook.ts +381 -0
- package/src/functions-lib/utils.ts +23 -0
- package/src/galaxpay-create-transaction.ts +240 -0
- package/src/galaxpay-events.ts +28 -0
- package/src/galaxpay-list-payments.ts +130 -0
- package/src/galaxpay.ts +12 -0
- package/src/index.ts +2 -0
- package/tsconfig.json +6 -0
- package/types/config-app.d.ts +99 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { ApiEventHandler } from '@cloudcommerce/firebase/lib/helpers/pubsub';
|
|
2
|
+
import type { Orders } from '@cloudcommerce/types';
|
|
3
|
+
import logger from 'firebase-functions/logger';
|
|
4
|
+
import { getFirestore } from 'firebase-admin/firestore';
|
|
5
|
+
import config from '@cloudcommerce/firebase/lib/config';
|
|
6
|
+
import GalaxpayAxios from '../galaxpay/auth/create-access';
|
|
7
|
+
|
|
8
|
+
const collectionSubscription = getFirestore().collection('subscriptions');
|
|
9
|
+
|
|
10
|
+
const handleApiEvent: ApiEventHandler = async ({
|
|
11
|
+
evName,
|
|
12
|
+
apiEvent,
|
|
13
|
+
apiDoc,
|
|
14
|
+
app,
|
|
15
|
+
}) => {
|
|
16
|
+
const resourceId = apiEvent.resource_id;
|
|
17
|
+
logger.info('>> ', resourceId, ' - Action: ', apiEvent.action);
|
|
18
|
+
const key = `${evName}_${resourceId}`;
|
|
19
|
+
const appData = { ...app.data, ...app.hidden_data };
|
|
20
|
+
if (
|
|
21
|
+
Array.isArray(appData.ignore_events)
|
|
22
|
+
&& appData.ignore_events.includes(evName)
|
|
23
|
+
) {
|
|
24
|
+
logger.info('>> ', key, ' - Ignored event');
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
logger.info(`> Webhook ${resourceId} [${evName}] => ${apiDoc}`);
|
|
28
|
+
const galaxpayAxios = new GalaxpayAxios({
|
|
29
|
+
galaxpayId: appData.galaxpay_id,
|
|
30
|
+
galaxpayHash: appData.galaxpay_hash,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
await galaxpayAxios.preparing;
|
|
34
|
+
const { axios } = galaxpayAxios;
|
|
35
|
+
if (axios) {
|
|
36
|
+
if (evName === 'orders-cancelled') {
|
|
37
|
+
const order = apiDoc as Orders;
|
|
38
|
+
|
|
39
|
+
if (!order.subscription_order) {
|
|
40
|
+
const documentSnapshot = await collectionSubscription.doc(order._id).get();
|
|
41
|
+
if (documentSnapshot && documentSnapshot.exists) {
|
|
42
|
+
const docSubscription = documentSnapshot.data();
|
|
43
|
+
if (docSubscription) {
|
|
44
|
+
const { status } = docSubscription.data();
|
|
45
|
+
if (status !== 'cancelled') {
|
|
46
|
+
try {
|
|
47
|
+
await axios.delete(`/subscriptions/${order._id}/myId`);
|
|
48
|
+
await collectionSubscription.doc(order._id)
|
|
49
|
+
.set({
|
|
50
|
+
status: 'cancelled',
|
|
51
|
+
updatedAt: new Date().toISOString(),
|
|
52
|
+
}, { merge: true })
|
|
53
|
+
.catch(logger.error);
|
|
54
|
+
} catch (err: any) {
|
|
55
|
+
const statusCode = err.response?.status;
|
|
56
|
+
if (statusCode === 404) {
|
|
57
|
+
logger.warn('> (App:GalaxPay): Subscription not found in GalaxPay');
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
if (statusCode === 401 || statusCode === 403) {
|
|
61
|
+
logger.warn('> (App:GalaxPay): Unauthorized subscription deletion request');
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
throw err;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
logger.warn('> (App:GalaxPay): Subscription not fount in Firestore');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
const locationId = config.get().httpsFunctionOptions.region;
|
|
74
|
+
const webhookUrl = `https://${locationId}-${process.env.GCLOUD_PROJECT}.cloudfunctions.net/galapay-webhook`;
|
|
75
|
+
|
|
76
|
+
return axios.put('/webhooks', {
|
|
77
|
+
url: webhookUrl,
|
|
78
|
+
events: ['subscription.addTransaction', 'transaction.updateStatus'],
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
logger.warn('> (App GalaxPay) Access not found');
|
|
82
|
+
return null;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export default handleApiEvent;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { AxiosInstance } from 'axios';
|
|
2
|
+
import { getFirestore } from 'firebase-admin/firestore';
|
|
3
|
+
import logger from 'firebase-functions/logger';
|
|
4
|
+
import { isSandbox } from '../../utils';
|
|
5
|
+
import gerateAccessToken from './gerate-token';
|
|
6
|
+
import createAxios from './create-axios';
|
|
7
|
+
|
|
8
|
+
const { GALAXPAY_PARTNER_ID, GALAXPAY_PARTNER_HASH } = process.env;
|
|
9
|
+
|
|
10
|
+
const firestoreColl = 'galaxpayTokens';
|
|
11
|
+
|
|
12
|
+
type Option = {
|
|
13
|
+
galaxpayId: string;
|
|
14
|
+
galaxpayHash: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default class GalaxPay {
|
|
18
|
+
preparing: Promise<unknown>;
|
|
19
|
+
axios: AxiosInstance | undefined;
|
|
20
|
+
|
|
21
|
+
constructor(options: Option) {
|
|
22
|
+
const {
|
|
23
|
+
galaxpayId,
|
|
24
|
+
galaxpayHash,
|
|
25
|
+
} = options;
|
|
26
|
+
|
|
27
|
+
const self = this;
|
|
28
|
+
|
|
29
|
+
let documentRef;
|
|
30
|
+
const hashLogin = Buffer.from(`${galaxpayId}:${galaxpayHash}`).toString('base64');
|
|
31
|
+
|
|
32
|
+
if (firestoreColl) {
|
|
33
|
+
documentRef = getFirestore()
|
|
34
|
+
.doc(`${firestoreColl}/${hashLogin}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let galaxpayPartnerHash: string | undefined;
|
|
38
|
+
|
|
39
|
+
if (GALAXPAY_PARTNER_ID && GALAXPAY_PARTNER_HASH) {
|
|
40
|
+
galaxpayPartnerHash = Buffer.from(`${GALAXPAY_PARTNER_ID}:${GALAXPAY_PARTNER_HASH}`).toString('base64');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
this.preparing = new Promise((resolve, reject) => {
|
|
44
|
+
const authenticate = (token: string) => {
|
|
45
|
+
self.axios = createAxios(token, isSandbox);
|
|
46
|
+
resolve(self);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const handleAuth = () => {
|
|
50
|
+
logger.log('>(App Galaxpay) Auth02 ');
|
|
51
|
+
gerateAccessToken(hashLogin, isSandbox, galaxpayPartnerHash)
|
|
52
|
+
.then((accessToken) => {
|
|
53
|
+
// logger.log(`>(App Galaxpay) ${hashLogin}: ${accessToken}`);
|
|
54
|
+
authenticate(accessToken as string);
|
|
55
|
+
if (documentRef) {
|
|
56
|
+
documentRef.set({ accessToken }).catch(logger.error);
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
.catch(reject);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
if (documentRef) {
|
|
63
|
+
documentRef.get()
|
|
64
|
+
.then((documentSnapshot) => {
|
|
65
|
+
if (documentSnapshot.exists
|
|
66
|
+
&& Date.now() - documentSnapshot.updateTime.toDate().getTime()
|
|
67
|
+
<= 9 * 60 * 1000 // access token expires in 10 minutes
|
|
68
|
+
) {
|
|
69
|
+
authenticate(documentSnapshot.get('accessToken'));
|
|
70
|
+
} else {
|
|
71
|
+
handleAuth();
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
.catch(logger.error);
|
|
75
|
+
} else {
|
|
76
|
+
handleAuth();
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
// import logger from 'firebase-functions/logger';
|
|
3
|
+
|
|
4
|
+
export default (accessToken: string | undefined | null, isSandbox?: boolean) => {
|
|
5
|
+
// https://docs.galaxpay.com.br/autenticacao
|
|
6
|
+
// https://docs.galaxpay.com.br/auth/token
|
|
7
|
+
|
|
8
|
+
const headers = {
|
|
9
|
+
'Content-Type': 'application/json',
|
|
10
|
+
};
|
|
11
|
+
if (accessToken) {
|
|
12
|
+
// logger.log('>(App GalaxPay) token: ', accessToken);
|
|
13
|
+
Object.assign(headers, { Authorization: `Bearer ${accessToken}` });
|
|
14
|
+
Object.assign(headers, { 'Accept-Encoding': 'gzip,deflate,compress' });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return axios.create({
|
|
18
|
+
baseURL: `https://api.${isSandbox ? 'sandbox.cloud.' : ''}galaxpay.com.br/v2`,
|
|
19
|
+
headers,
|
|
20
|
+
});
|
|
21
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// import logger from 'firebase-functions/logger';
|
|
2
|
+
import Axios from './create-axios';
|
|
3
|
+
|
|
4
|
+
const gereteToken = (
|
|
5
|
+
hashLogin: string,
|
|
6
|
+
isSandbox?: boolean,
|
|
7
|
+
galaxpayPartnerHash?: string,
|
|
8
|
+
) => new Promise((resolve, reject) => {
|
|
9
|
+
// https://docs.galaxpay.com.br/autenticacao
|
|
10
|
+
// https://docs.galaxpay.com.br/auth/token
|
|
11
|
+
|
|
12
|
+
const axios = Axios(null, isSandbox);
|
|
13
|
+
const request = (isRetry?: boolean) => {
|
|
14
|
+
const headers = { Authorization: `Basic ${hashLogin}` };
|
|
15
|
+
if (!isSandbox && galaxpayPartnerHash) {
|
|
16
|
+
// logger.log('#AuthorizationPartner ');
|
|
17
|
+
Object.assign(headers, { AuthorizationPartner: galaxpayPartnerHash });
|
|
18
|
+
}
|
|
19
|
+
axios.post('/token', {
|
|
20
|
+
grant_type: 'authorization_code',
|
|
21
|
+
scope: 'customers.read customers.write plans.read plans.write transactions.read transactions.write webhooks.write cards.read cards.write card-brands.read subscriptions.read subscriptions.write charges.read charges.write boletos.read',
|
|
22
|
+
}, { headers })
|
|
23
|
+
.then(({ data }) => {
|
|
24
|
+
resolve(data.access_token);
|
|
25
|
+
})
|
|
26
|
+
.catch((err) => {
|
|
27
|
+
if (!isRetry && err.response && err.response.status >= 429) {
|
|
28
|
+
setTimeout(() => request(true), 700);
|
|
29
|
+
}
|
|
30
|
+
reject(err);
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
request();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export default gereteToken;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { GalaxpayApp } from '../../../types/config-app';
|
|
2
|
+
// import type { ListPaymentsResponse } from '@cloudcommerce/types/modules/list_payments:response';
|
|
3
|
+
import type { ListPaymentsParams } from '@cloudcommerce/types/modules/list_payments:params';
|
|
4
|
+
|
|
5
|
+
// type Gateway = ListPaymentsResponse['payment_gateways'][number]
|
|
6
|
+
|
|
7
|
+
const handleGateway = (appData: GalaxpayApp) => {
|
|
8
|
+
const plans: Exclude<GalaxpayApp['plans'], undefined> = [];
|
|
9
|
+
if (appData.plans) {
|
|
10
|
+
// Newer versions of the app will have a list of plans
|
|
11
|
+
appData.plans.forEach((plan) => {
|
|
12
|
+
plans.push(plan);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return plans;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// for create-transaction
|
|
20
|
+
const findPlanToCreateTransction = (label: string | undefined, appData: GalaxpayApp) => {
|
|
21
|
+
let sendPlan: Exclude<GalaxpayApp['plans'], undefined>[number] | undefined;
|
|
22
|
+
if (appData.plans) {
|
|
23
|
+
/*
|
|
24
|
+
More recent versions of the application will have a list of plans,
|
|
25
|
+
where it will be necessary to find the plan by name,
|
|
26
|
+
and return it since it will be necessary to use the periodicity and quantity property
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
// find plan by name (label)
|
|
30
|
+
appData.plans.forEach((plan) => {
|
|
31
|
+
// if the name of the plan is blank, on the list-payments side it is set to 'Plano'
|
|
32
|
+
let planLabel = plan.label || 'Plano';
|
|
33
|
+
planLabel = `${planLabel} ${plan.periodicity}`;
|
|
34
|
+
label = label?.trim();
|
|
35
|
+
if (label === planLabel) {
|
|
36
|
+
sendPlan = plan;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return sendPlan;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const discountPlan = (
|
|
44
|
+
planDiscount: Exclude<GalaxpayApp['plans'], undefined>[number]['discount'],
|
|
45
|
+
amount: Exclude<ListPaymentsParams['amount'], undefined>,
|
|
46
|
+
) => {
|
|
47
|
+
if (planDiscount && planDiscount.value > 0) {
|
|
48
|
+
// default discount option
|
|
49
|
+
const discountOption = {
|
|
50
|
+
value: planDiscount.value,
|
|
51
|
+
apply_at: (planDiscount.apply_at === 'frete' ? 'freight' : planDiscount) as 'total' | 'subtotal' | 'freight',
|
|
52
|
+
type: planDiscount.percentage ? 'percentage' : 'fixed' as 'percentage' | 'fixed' | undefined,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
if (amount.total) {
|
|
56
|
+
// check amount value to apply discount
|
|
57
|
+
if (planDiscount.min_amount && amount.total < planDiscount.min_amount) {
|
|
58
|
+
planDiscount.value = 0;
|
|
59
|
+
} else {
|
|
60
|
+
delete planDiscount.min_amount;
|
|
61
|
+
|
|
62
|
+
const maxDiscount = amount[discountOption.apply_at || 'subtotal'];
|
|
63
|
+
let discountValue: number | undefined;
|
|
64
|
+
|
|
65
|
+
if (maxDiscount && discountOption.type === 'percentage') {
|
|
66
|
+
discountValue = (maxDiscount * planDiscount.value) / 100;
|
|
67
|
+
} else {
|
|
68
|
+
discountValue = planDiscount.value;
|
|
69
|
+
if (maxDiscount && discountValue > maxDiscount) {
|
|
70
|
+
discountValue = maxDiscount;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (discountValue && discountValue > 0) {
|
|
75
|
+
amount.discount = (amount.discount || 0) + discountValue;
|
|
76
|
+
amount.total -= discountValue;
|
|
77
|
+
if (amount.total < 0) {
|
|
78
|
+
amount.total = 0;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return discountOption;
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export {
|
|
89
|
+
handleGateway,
|
|
90
|
+
findPlanToCreateTransction,
|
|
91
|
+
discountPlan,
|
|
92
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Orders, Applications } from '@cloudcommerce/types';
|
|
2
|
+
import GalaxpayAxios from './auth/create-access';
|
|
3
|
+
|
|
4
|
+
const checkAmountItemsOrder = (
|
|
5
|
+
amount: Orders['amount'],
|
|
6
|
+
items: Exclude<Orders['items'], undefined>,
|
|
7
|
+
plan: { [x: string]: any },
|
|
8
|
+
) => {
|
|
9
|
+
let subtotal = 0;
|
|
10
|
+
let item: Exclude<Orders['items'], undefined>[number];
|
|
11
|
+
for (let i = 0; i < items.length; i++) {
|
|
12
|
+
item = items[i];
|
|
13
|
+
if (item.flags && (item.flags.includes('freebie') || item.flags.includes('discount-set-free'))) {
|
|
14
|
+
items.splice(i, 1);
|
|
15
|
+
} else {
|
|
16
|
+
subtotal += item.quantity * (item.final_price || item.price);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
amount.subtotal = subtotal;
|
|
20
|
+
amount.total = amount.subtotal + (amount.tax || 0) + (amount.freight || 0) + (amount.extra || 0);
|
|
21
|
+
let planDiscount;
|
|
22
|
+
if (plan && plan.discount) {
|
|
23
|
+
if (plan.discount.percentage) {
|
|
24
|
+
planDiscount = amount[plan.discount.apply_at];
|
|
25
|
+
planDiscount *= ((plan.discount.value) / 100);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// if the plan doesn't exist, because it's subscription before the update
|
|
29
|
+
if (plan) {
|
|
30
|
+
amount.discount = (plan.discount && !plan.discount.percentage
|
|
31
|
+
? plan.discount.value : planDiscount) || 0;
|
|
32
|
+
}
|
|
33
|
+
if (amount.discount) {
|
|
34
|
+
amount.total -= amount.discount;
|
|
35
|
+
}
|
|
36
|
+
const total: any = amount.total - (amount.discount || 0); // BUG :(
|
|
37
|
+
return Math.floor(total.toFixed(2) * 100);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const updateValueSubscription = (
|
|
41
|
+
appData: Applications,
|
|
42
|
+
subscriptionId: string,
|
|
43
|
+
amount: Orders['amount'],
|
|
44
|
+
items: Exclude<Orders['items'], undefined>,
|
|
45
|
+
plan: { [x: string]: any },
|
|
46
|
+
// GalaxPaySubscription: { [x: string]: any },
|
|
47
|
+
) => {
|
|
48
|
+
const value = checkAmountItemsOrder({ ...amount }, [...items], { ...plan });
|
|
49
|
+
|
|
50
|
+
return new Promise((resolve, reject) => {
|
|
51
|
+
const galaxpayAxios = new GalaxpayAxios({
|
|
52
|
+
galaxpayId: appData.hidden_data?.galaxpay_id,
|
|
53
|
+
galaxpayHash: appData.hidden_data?.galaxpay_hash,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
galaxpayAxios.preparing
|
|
57
|
+
.then(async () => {
|
|
58
|
+
if (galaxpayAxios.axios) {
|
|
59
|
+
const { data } = await galaxpayAxios.axios.put(`subscriptions/${subscriptionId}/myId`, { value });
|
|
60
|
+
if (data.type) {
|
|
61
|
+
resolve(true);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}).catch((err) => {
|
|
65
|
+
reject(err);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export {
|
|
71
|
+
updateValueSubscription,
|
|
72
|
+
checkAmountItemsOrder,
|
|
73
|
+
};
|