@pintahub/shopify-api 2.3.0 → 2.3.2
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/classes/AdminAPI.d.ts +2 -0
- package/dist/classes/AdminAPI.js +9 -7
- package/dist/classes/admin/payments/GetMenu.d.ts +23 -0
- package/dist/classes/admin/payments/GetMenu.js +58 -0
- package/dist/classes/admin/payments/SearchMenus.d.ts +13 -0
- package/dist/classes/admin/payments/SearchMenus.js +47 -0
- package/dist/classes/admin/payments/SearchPayouts.d.ts +13 -0
- package/dist/classes/admin/payments/SearchPayouts.js +55 -0
- package/dist/classes/admin/payments/index.d.ts +10 -0
- package/dist/classes/admin/payments/index.js +28 -0
- package/dist/classes/rest/orders/GetOrderTransaction.d.ts +0 -1
- package/dist/classes/rest/orders/GetOrderTransaction.js +2 -21
- package/dist/classes/rest/orders/transactions/_parseFee.d.ts +1 -0
- package/dist/classes/rest/orders/transactions/_parseFee.js +50 -0
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@ import { AdminMenuAPIInterface } from "./admin/menus";
|
|
|
7
7
|
import { AdminProductsAPIInterface } from "./admin/products-v2";
|
|
8
8
|
import { AdminCustomersAPIInterface } from "./admin/customers";
|
|
9
9
|
import { AdminCollectionAPIInterface } from "./admin/collections-v2";
|
|
10
|
+
import { AdminPaymentsAPIInterface } from "./admin/payments";
|
|
10
11
|
export declare class AdminAPI {
|
|
11
12
|
private readonly options;
|
|
12
13
|
private readonly client?;
|
|
@@ -19,6 +20,7 @@ export declare class AdminAPI {
|
|
|
19
20
|
readonly collections: AdminCollectionAPIInterface;
|
|
20
21
|
readonly metaobject: AdminMetaObjectAPIInterface;
|
|
21
22
|
readonly orders: AdminOrderAPIInterface;
|
|
23
|
+
readonly payments: AdminPaymentsAPIInterface;
|
|
22
24
|
constructor(options: APIOptions);
|
|
23
25
|
private _createClient;
|
|
24
26
|
}
|
package/dist/classes/AdminAPI.js
CHANGED
|
@@ -10,6 +10,7 @@ const menus_1 = require("./admin/menus");
|
|
|
10
10
|
const products_v2_1 = require("./admin/products-v2");
|
|
11
11
|
const customers_1 = require("./admin/customers");
|
|
12
12
|
const collections_v2_1 = require("./admin/collections-v2");
|
|
13
|
+
const payments_1 = require("./admin/payments");
|
|
13
14
|
class AdminAPI {
|
|
14
15
|
constructor(options) {
|
|
15
16
|
const defaultOptions = {
|
|
@@ -22,13 +23,14 @@ class AdminAPI {
|
|
|
22
23
|
this.product = new products_1.AdminProductAPI(this.client);
|
|
23
24
|
this.order = new orders_1.AdminOrderAPI(this.client);
|
|
24
25
|
}
|
|
25
|
-
this.menus = new menus_1.AdminMenuAPI(this._createClient('
|
|
26
|
-
this.products = new products_v2_1.AdminProductsAPI(this._createClient('
|
|
27
|
-
this.customers = new customers_1.AdminCustomersAPI(this._createClient('
|
|
28
|
-
this.collections = new collections_v2_1.AdminCollectionAPI(this._createClient('
|
|
29
|
-
this.files = new files_1.AdminFileAPI(this._createClient('
|
|
30
|
-
this.metaobject = new metaobjects_1.AdminMetaObjectAPI(this._createClient('
|
|
31
|
-
this.orders = new orders_1.AdminOrderAPI(this._createClient('
|
|
26
|
+
this.menus = new menus_1.AdminMenuAPI(this._createClient('2025-01'));
|
|
27
|
+
this.products = new products_v2_1.AdminProductsAPI(this._createClient('2025-01'));
|
|
28
|
+
this.customers = new customers_1.AdminCustomersAPI(this._createClient('2025-01'));
|
|
29
|
+
this.collections = new collections_v2_1.AdminCollectionAPI(this._createClient('2025-01'));
|
|
30
|
+
this.files = new files_1.AdminFileAPI(this._createClient('2025-01'));
|
|
31
|
+
this.metaobject = new metaobjects_1.AdminMetaObjectAPI(this._createClient('2025-01'));
|
|
32
|
+
this.orders = new orders_1.AdminOrderAPI(this._createClient('2025-01'));
|
|
33
|
+
this.payments = new payments_1.AdminPaymentsAPI(this._createClient('2025-07'));
|
|
32
34
|
}
|
|
33
35
|
_createClient(apiVersion = '2023-10') {
|
|
34
36
|
const { shop, accessToken } = this.options;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
|
|
2
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
3
|
+
export interface GetMenuInput extends Record<string, any> {
|
|
4
|
+
id: string;
|
|
5
|
+
}
|
|
6
|
+
interface MenuItem extends Record<string, any> {
|
|
7
|
+
id: string;
|
|
8
|
+
title: string;
|
|
9
|
+
url: string;
|
|
10
|
+
type: string;
|
|
11
|
+
items: MenuItem[];
|
|
12
|
+
}
|
|
13
|
+
export interface GetMenuOutput extends Record<string, any> {
|
|
14
|
+
handle: string;
|
|
15
|
+
id: string;
|
|
16
|
+
isDefault: boolean;
|
|
17
|
+
title: string;
|
|
18
|
+
items: MenuItem[];
|
|
19
|
+
}
|
|
20
|
+
export declare class GetMenu extends ActionBuilder<AdminApiClient, GetMenuInput, GetMenuOutput> {
|
|
21
|
+
run(args: GetMenuInput): Promise<GetMenuOutput>;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.GetMenu = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
const getGlobalID_1 = require("../../../utils/getGlobalID");
|
|
15
|
+
const handleErrors_1 = require("../../../utils/handleErrors");
|
|
16
|
+
class GetMenu extends ActionBuilder_1.ActionBuilder {
|
|
17
|
+
run(args) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const { id } = args;
|
|
20
|
+
const globalId = (0, getGlobalID_1.getGlobalID)(id, 'Menu');
|
|
21
|
+
console.log('globalId', globalId);
|
|
22
|
+
const query = `
|
|
23
|
+
{
|
|
24
|
+
menu(id: "${globalId}") {
|
|
25
|
+
handle
|
|
26
|
+
id
|
|
27
|
+
isDefault
|
|
28
|
+
title
|
|
29
|
+
items(limit: 250) {
|
|
30
|
+
id
|
|
31
|
+
title
|
|
32
|
+
url
|
|
33
|
+
type
|
|
34
|
+
items {
|
|
35
|
+
id
|
|
36
|
+
title
|
|
37
|
+
url
|
|
38
|
+
type
|
|
39
|
+
items {
|
|
40
|
+
id
|
|
41
|
+
title
|
|
42
|
+
url
|
|
43
|
+
type
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
const { data, errors, extensions } = yield this.client.request(query);
|
|
51
|
+
console.log('data', data);
|
|
52
|
+
yield (0, handleErrors_1.handleErrors)(errors);
|
|
53
|
+
const { menu } = Object.assign({}, data);
|
|
54
|
+
return Object.assign({}, menu);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.GetMenu = GetMenu;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
|
|
2
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
3
|
+
export interface SearchMenusInput extends Record<string, any> {
|
|
4
|
+
after?: string;
|
|
5
|
+
limit?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface SearchMenusOutput extends Record<string, any> {
|
|
8
|
+
items: any[];
|
|
9
|
+
pageInfo: any;
|
|
10
|
+
}
|
|
11
|
+
export declare class SearchMenus extends ActionBuilder<AdminApiClient, SearchMenusInput, SearchMenusOutput> {
|
|
12
|
+
run(args?: SearchMenusInput): Promise<SearchMenusOutput>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SearchMenus = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
const handleErrors_1 = require("../../../utils/handleErrors");
|
|
15
|
+
class SearchMenus extends ActionBuilder_1.ActionBuilder {
|
|
16
|
+
run(args) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const { limit } = Object.assign({}, args);
|
|
19
|
+
const vLimit = limit || 10;
|
|
20
|
+
const query = `
|
|
21
|
+
{
|
|
22
|
+
menus(first: ${vLimit}) {
|
|
23
|
+
nodes {
|
|
24
|
+
handle
|
|
25
|
+
id
|
|
26
|
+
title
|
|
27
|
+
}
|
|
28
|
+
pageInfo {
|
|
29
|
+
hasNextPage
|
|
30
|
+
endCursor
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
const { data, errors } = yield this.client.request(query);
|
|
36
|
+
yield (0, handleErrors_1.handleErrors)(errors);
|
|
37
|
+
const { menus } = Object.assign({}, data);
|
|
38
|
+
const { nodes, pageInfo } = Object.assign({}, menus);
|
|
39
|
+
const items = Array.isArray(nodes) ? nodes : [];
|
|
40
|
+
return {
|
|
41
|
+
items,
|
|
42
|
+
pageInfo
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.SearchMenus = SearchMenus;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
|
|
2
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
3
|
+
export interface SearchPayoutsInput extends Record<string, any> {
|
|
4
|
+
after?: string;
|
|
5
|
+
limit?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface SearchPayoutsOutput extends Record<string, any> {
|
|
8
|
+
items: any[];
|
|
9
|
+
pageInfo: any;
|
|
10
|
+
}
|
|
11
|
+
export declare class SearchPayouts extends ActionBuilder<AdminApiClient, SearchPayoutsInput, SearchPayoutsOutput> {
|
|
12
|
+
run(args?: SearchPayoutsInput): Promise<SearchPayoutsOutput>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SearchPayouts = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
const handleErrors_1 = require("../../../utils/handleErrors");
|
|
15
|
+
class SearchPayouts extends ActionBuilder_1.ActionBuilder {
|
|
16
|
+
run(args) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const { limit } = Object.assign({}, args);
|
|
19
|
+
const vLimit = limit || 10;
|
|
20
|
+
const query = `
|
|
21
|
+
query payouts {
|
|
22
|
+
shopifyPaymentsAccount {
|
|
23
|
+
payouts(first: ${vLimit}, sortKey: ISSUED_AT, reverse: true) {
|
|
24
|
+
nodes {
|
|
25
|
+
id
|
|
26
|
+
status
|
|
27
|
+
issuedAt
|
|
28
|
+
net {
|
|
29
|
+
amount
|
|
30
|
+
currencyCode
|
|
31
|
+
}
|
|
32
|
+
transactionType
|
|
33
|
+
}
|
|
34
|
+
pageInfo {
|
|
35
|
+
hasNextPage
|
|
36
|
+
endCursor
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
const { data, errors } = yield this.client.request(query);
|
|
43
|
+
yield (0, handleErrors_1.handleErrors)(errors);
|
|
44
|
+
const { shopifyPaymentsAccount } = Object.assign({}, data);
|
|
45
|
+
const { payouts } = Object.assign({}, shopifyPaymentsAccount);
|
|
46
|
+
const { nodes, pageInfo } = Object.assign({}, payouts);
|
|
47
|
+
const items = Array.isArray(nodes) ? nodes : [];
|
|
48
|
+
return {
|
|
49
|
+
items,
|
|
50
|
+
pageInfo
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.SearchPayouts = SearchPayouts;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
|
|
2
|
+
import { APIBase } from "../../APIBase";
|
|
3
|
+
import { SearchPayoutsInput, SearchPayoutsOutput } from "./SearchPayouts";
|
|
4
|
+
export interface AdminPaymentsAPIInterface {
|
|
5
|
+
searchPayouts(args: SearchPayoutsInput): Promise<SearchPayoutsOutput>;
|
|
6
|
+
}
|
|
7
|
+
export declare class AdminPaymentsAPI extends APIBase<AdminApiClient> implements AdminPaymentsAPIInterface {
|
|
8
|
+
private _runAction;
|
|
9
|
+
searchPayouts(args?: SearchPayoutsInput): Promise<SearchPayoutsOutput>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AdminPaymentsAPI = void 0;
|
|
13
|
+
const APIBase_1 = require("../../APIBase");
|
|
14
|
+
const SearchPayouts_1 = require("./SearchPayouts");
|
|
15
|
+
class AdminPaymentsAPI extends APIBase_1.APIBase {
|
|
16
|
+
_runAction(Action, args) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const action = new Action(this.client);
|
|
19
|
+
return action.run(args);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
searchPayouts(args) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
return this._runAction(SearchPayouts_1.SearchPayouts, args);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.AdminPaymentsAPI = AdminPaymentsAPI;
|
|
@@ -6,7 +6,6 @@ export interface GetOrderTransactionInput extends Record<string, any> {
|
|
|
6
6
|
export interface GetOrderTransactionOutput extends Record<string, any> {
|
|
7
7
|
}
|
|
8
8
|
export declare class GetOrderTransaction extends ActionBuilder<AxiosInstance, GetOrderTransactionInput, GetOrderTransactionOutput> {
|
|
9
|
-
private _parseFee;
|
|
10
9
|
private _parsePaymentMethod;
|
|
11
10
|
private _parseTransaction;
|
|
12
11
|
run(args: GetOrderTransactionInput): Promise<GetOrderTransactionOutput>;
|
|
@@ -12,27 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.GetOrderTransaction = void 0;
|
|
13
13
|
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
14
|
const parseOnlyId_1 = require("../../../utils/parseOnlyId");
|
|
15
|
+
const _parseFee_1 = require("./transactions/_parseFee");
|
|
15
16
|
class GetOrderTransaction extends ActionBuilder_1.ActionBuilder {
|
|
16
|
-
_parseFee(receipt, gateway) {
|
|
17
|
-
console.log('receipt', receipt);
|
|
18
|
-
if (gateway === 'shopify_payments') {
|
|
19
|
-
const { metadata } = Object.assign({}, receipt);
|
|
20
|
-
const { transaction_fee_total_amount } = Object.assign({}, metadata);
|
|
21
|
-
if (!transaction_fee_total_amount)
|
|
22
|
-
return null;
|
|
23
|
-
const n = parseFloat(transaction_fee_total_amount);
|
|
24
|
-
if (isNaN(n))
|
|
25
|
-
return null;
|
|
26
|
-
return n / 100;
|
|
27
|
-
}
|
|
28
|
-
const { fee_amount } = Object.assign({}, receipt);
|
|
29
|
-
if (fee_amount) {
|
|
30
|
-
const n = parseFloat(fee_amount);
|
|
31
|
-
if (!isNaN(n))
|
|
32
|
-
return n;
|
|
33
|
-
}
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
17
|
_parsePaymentMethod(transaction) {
|
|
37
18
|
const { payment_details } = Object.assign({}, transaction);
|
|
38
19
|
const { payment_method_name } = Object.assign({}, payment_details);
|
|
@@ -49,7 +30,7 @@ class GetOrderTransaction extends ActionBuilder_1.ActionBuilder {
|
|
|
49
30
|
return {};
|
|
50
31
|
}
|
|
51
32
|
const { receipt, gateway, currency } = Object.assign({}, saleTransaction);
|
|
52
|
-
const fee_amount =
|
|
33
|
+
const fee_amount = (0, _parseFee_1._parseFee)(receipt, gateway);
|
|
53
34
|
const paymentMethod = this._parsePaymentMethod(saleTransaction);
|
|
54
35
|
return {
|
|
55
36
|
gateway,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const _parseFee: (receipt: any, gateway: string) => number | null;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._parseFee = void 0;
|
|
4
|
+
const _fromPurchaseUnits = (receipt) => {
|
|
5
|
+
const { purchase_units } = Object.assign({}, receipt);
|
|
6
|
+
if (!Array.isArray(purchase_units) || purchase_units.length === 0)
|
|
7
|
+
return null;
|
|
8
|
+
const pu = purchase_units[0];
|
|
9
|
+
if (!pu)
|
|
10
|
+
return null;
|
|
11
|
+
const { payment_instruction } = Object.assign({}, pu);
|
|
12
|
+
const { platform_fees } = Object.assign({}, payment_instruction);
|
|
13
|
+
const arr = Array.isArray(platform_fees) ? platform_fees : [];
|
|
14
|
+
if (arr.length === 0)
|
|
15
|
+
return null;
|
|
16
|
+
const [firstFee] = arr;
|
|
17
|
+
if (!firstFee)
|
|
18
|
+
return null;
|
|
19
|
+
const { amount } = Object.assign({}, firstFee);
|
|
20
|
+
const { value } = Object.assign({}, amount);
|
|
21
|
+
if (!value)
|
|
22
|
+
return null;
|
|
23
|
+
const n = parseFloat(value);
|
|
24
|
+
if (isNaN(n))
|
|
25
|
+
return null;
|
|
26
|
+
return n;
|
|
27
|
+
};
|
|
28
|
+
const _parseFee = (receipt, gateway) => {
|
|
29
|
+
if (gateway === 'shopify_payments') {
|
|
30
|
+
const { metadata, purchase_units } = Object.assign({}, receipt);
|
|
31
|
+
const fromPU = _fromPurchaseUnits(receipt);
|
|
32
|
+
if (fromPU !== null)
|
|
33
|
+
return fromPU;
|
|
34
|
+
const { transaction_fee_total_amount } = Object.assign({}, metadata);
|
|
35
|
+
if (!transaction_fee_total_amount)
|
|
36
|
+
return null;
|
|
37
|
+
const n = parseFloat(transaction_fee_total_amount);
|
|
38
|
+
if (isNaN(n))
|
|
39
|
+
return null;
|
|
40
|
+
return n / 100;
|
|
41
|
+
}
|
|
42
|
+
const { fee_amount } = Object.assign({}, receipt);
|
|
43
|
+
if (fee_amount) {
|
|
44
|
+
const n = parseFloat(fee_amount);
|
|
45
|
+
if (!isNaN(n))
|
|
46
|
+
return n;
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
};
|
|
50
|
+
exports._parseFee = _parseFee;
|