@shipengine/js-api 4.6.1 → 4.8.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.
@@ -1,5 +1,5 @@
1
1
  import { AxiosInstance } from "axios";
2
- import { ConfigResponse, CreateSessionRequest, CreateSessionResponse } from "./types";
2
+ import { ConfigResponse, CreateSessionRequest, CreateSessionResponse, PreviewTransactionRequest, PreviewTransactionResponse } from "./types";
3
3
  /**
4
4
  * # Auctane Pay API module - /v1/payments
5
5
  *
@@ -21,4 +21,11 @@ export declare class AuctanePayAPI {
21
21
  * @returns a promise that returns the AuctanePay config
22
22
  */
23
23
  getConfig: () => Promise<import("axios").AxiosResponse<ConfigResponse, any>>;
24
+ /**
25
+ * The `previewTransaction` method previews transaction costs including fees and surcharges
26
+ * @docs https://auctane-pay-dev.kubedev.sslocal.com/swagger/index.html#tag/Transactions
27
+ * @param request - The request object containing amount and transaction category
28
+ * @returns a promise that resolves to the transaction preview with fees
29
+ */
30
+ previewTransaction: (request: PreviewTransactionRequest) => Promise<import("axios").AxiosResponse<PreviewTransactionResponse, any>>;
24
31
  }
@@ -1,13 +1,19 @@
1
1
  /**
2
2
  * @category Entities
3
- * Auctane Pay Session can return a lot of metadata, but will always returns the same 5 keys.
3
+ * Auctane Pay Session can return a lot of metadata,
4
+ * but will always returns the same 5 keys.
4
5
  */
5
6
  export interface AuctanePaySessionMetadata {
6
7
  [key: string]: string;
8
+ /** Adyen client key */
7
9
  adyenClientKey: string;
10
+ /** Adyen expiration */
8
11
  adyenExpiration: string;
12
+ /** Adyen session data */
9
13
  adyenSessionData: string;
14
+ /** Adyen session ID */
10
15
  adyenSessionId: string;
16
+ /** Client key */
11
17
  clientKey: string;
12
18
  }
13
19
  /**
@@ -15,6 +21,13 @@ export interface AuctanePaySessionMetadata {
15
21
  * Allowed Payment Method for AuctanePay
16
22
  */
17
23
  export type AuctanePayPaymentMethod = "credit_card" | "pay_pal" | "stamps" | "pay_by_bank_us" | "pay_by_bank_eu";
24
+ /**
25
+ * @category Entities
26
+ * Payment Method Details for AuctanePay
27
+ */
28
+ export type AuctanePayPaymentMethodDetails = {
29
+ fees: PaymentMethodDetailFee[] | null;
30
+ };
18
31
  /**
19
32
  * @category Entities
20
33
  * Note: This is similar to but distinct from the TransactionCategory in funding-sources
@@ -39,9 +52,7 @@ export interface CreateSessionRequest {
39
52
  * @category Entities
40
53
  */
41
54
  export interface PaymentMethodHolderAddress {
42
- /**
43
- * Account holder address
44
- */
55
+ /** Account holder address */
45
56
  accountHolderAddress: {
46
57
  addressLine1: string;
47
58
  addressLine2: string | null;
@@ -50,55 +61,46 @@ export interface PaymentMethodHolderAddress {
50
61
  postalCode: string;
51
62
  stateProvince: string;
52
63
  } | null;
53
- /**
54
- * Account holder name
55
- */
64
+ /** Account holder name */
56
65
  accountHolderName: string | null;
57
- /**
58
- * The last four of the account number, this is only provided for bank accounts and card schemes.
66
+ /** The last four of the account number, this is only
67
+ * provided for bank accounts and card schemes.
59
68
  */
60
69
  accountNumberLastFour: string;
61
- /**
62
- * An account number preview, for a CC this is the last 4 digits, but shown like 1234.
70
+ /** An account number preview, for a CC this is the last 4 digits, but shown like 1234.
63
71
  * For an e-mail account it might be ay@auctane.com, etc.
64
72
  */
65
73
  accountNumberPreview: string;
66
- /**
67
- * If applicable/available, the current expiration we have on file for the payment method.
74
+ /** If applicable/available, the current expiration
75
+ * we have on file for the payment method.
68
76
  */
69
77
  assignedPreferences: AuctanePayTransactionCategory[];
70
- /**
71
- * Date the payment method was last used. If the date it was last used is unavailable,
78
+ /** Date the payment method was last used.
79
+ * If the date it was last used is unavailable,
72
80
  * this will be the date created/updated.
73
81
  */
74
82
  dateLastUsed: string;
75
- /**
76
- * List of processes or payment gateways in which this Payment Method is registered
83
+ /** List of processes or payment gateways
84
+ * in which this Payment Method is registered
77
85
  */
78
86
  enrolledProcessors: string[];
79
- /**
80
- * If applicable/available, the current expiration we have on file for the payment method.
87
+ /** If applicable/available, the current expiration
88
+ * we have on file for the payment method.
81
89
  */
82
90
  expiration: string;
83
- /**
84
- * The Payment Method ID
85
- */
91
+ /** Array of fee details */
92
+ fees: PaymentMethodDetailFee[];
93
+ /** The Payment Method ID */
86
94
  id: string;
87
- /**
88
- * The nickname of the payment method
89
- */
95
+ /** The nickname of the payment method */
90
96
  nickname: string;
91
- /**
92
- * Enumeration of supported payment methods.
93
- */
97
+ /** Enumeration of supported payment methods. */
94
98
  paymentMethod: "unknown" | "visa" | "mastercard" | "amex" | "discover" | "maestro" | "dinersclub" | "ach" | "jcb" | "pulse" | "star" | "unionpay";
95
- /**
96
- * The Display Name to show in any text based UI/context for the Logo.
99
+ /** The Display Name to show in any text
100
+ * based UI/context for the Logo.
97
101
  */
98
102
  paymentMethodDisplayName: string;
99
- /**
100
- * Source account ID
101
- */
103
+ /** Source account ID */
102
104
  sourceAccountId: string;
103
105
  }
104
106
  /**
@@ -111,33 +113,83 @@ export interface ConfigResponse {
111
113
  * @category Entities
112
114
  */
113
115
  export interface CreateSessionResponse {
114
- /**
115
- * Active payment methods
116
- */
116
+ /** Active payment methods */
117
117
  activePaymentMethods: PaymentMethodHolderAddress[];
118
- /**
119
- * Client key
120
- */
118
+ /** Client key */
121
119
  clientKey: string;
122
- /**
123
- * Eligible payment method types
124
- */
120
+ /** Eligible payment method types */
125
121
  eligiblePaymentMethodTypes: AuctanePayPaymentMethod[];
126
- /**
127
- * The Auctane Pay Internal Session ID, use this ID to request the result of this session
122
+ /** The Auctane Pay Internal Session ID,
123
+ * use this ID to request the result of this session
128
124
  * and payment methods created from it.
129
125
  */
130
126
  id: string;
131
- /**
132
- * Metadata
133
- */
127
+ /** Metadata */
134
128
  metadata: AuctanePaySessionMetadata;
135
- /**
136
- * Recent payment methods
137
- */
129
+ /** Payment Method Meta Type Details */
130
+ paymentMethodMetaTypeDetails: Record<keyof AuctanePayPaymentMethod, AuctanePayPaymentMethodDetails> | null;
131
+ /** Recent payment methods */
138
132
  recentPaymentMethods: PaymentMethodHolderAddress[];
139
133
  /** @deprecated */
140
134
  sessionData: string;
141
135
  /** @deprecated */
142
136
  sessionId: string;
137
+ /** Category of the transaction */
138
+ transactionCategory: AuctanePayTransactionCategory;
139
+ }
140
+ /**
141
+ * @category Entities
142
+ * Request body for preview transaction endpoint
143
+ */
144
+ export interface PreviewTransactionRequest {
145
+ /** Transaction amount */
146
+ amount: number;
147
+ /** Category of the transaction */
148
+ transactionCategory: AuctanePayTransactionCategory;
149
+ }
150
+ /**
151
+ * @category Entities
152
+ * Money amount with currency
153
+ */
154
+ export interface MoneyAmount {
155
+ /** Amount value */
156
+ amount: number;
157
+ /** Currency code */
158
+ currencyCode: string;
159
+ }
160
+ export interface PaymentMethodDetailFee {
161
+ /** Fee percentage */
162
+ percentage: number;
163
+ /** Transaction categories */
164
+ transactionCategories: AuctanePayTransactionCategory[];
165
+ /** Fee type */
166
+ type: string;
167
+ }
168
+ /**
169
+ * @category Entities
170
+ * Fee information for a transaction
171
+ */
172
+ export interface TransactionFee {
173
+ /** Fee amount */
174
+ amount: number;
175
+ /** Fee percentage */
176
+ percentage: number;
177
+ /** Fee type */
178
+ type: string;
179
+ }
180
+ /**
181
+ * @category Entities
182
+ * Response from preview transaction endpoint
183
+ */
184
+ export interface PreviewTransactionResponse {
185
+ /** Total transaction amount */
186
+ amount: MoneyAmount;
187
+ /** Base amount before fees */
188
+ baseAmount: MoneyAmount;
189
+ /** Array of fee details */
190
+ fees: TransactionFee[];
191
+ /** Total transaction fee */
192
+ totalTransactionFee: MoneyAmount;
193
+ /** Transaction currency code */
194
+ transactionCurrencyCode: string;
143
195
  }
@@ -1,5 +1,6 @@
1
1
  import { AbbreviatedCreditCardInfo, BankAccountInfo, Provider } from "../payments";
2
2
  import { PageableResult } from "../resources";
3
+ import { PaymentMethodDetailFee } from "../types";
3
4
  /**
4
5
  * @internal
5
6
  * An encoded device fingerprint string containing information about the end-user's computing device such as OS, browser, etc.
@@ -28,12 +29,7 @@ export type FundingSource = {
28
29
  paymentMethod: {
29
30
  bankAccountInfo: BankAccountInfo | null;
30
31
  creditCardInfo: AbbreviatedCreditCardInfo | null;
31
- fees: [
32
- {
33
- percentage: number;
34
- type: string;
35
- }
36
- ] | null;
32
+ fees: PaymentMethodDetailFee[] | null;
37
33
  paymentMethodId?: string;
38
34
  };
39
35
  };
package/index.js CHANGED
@@ -260,6 +260,18 @@ class AuctanePayAPI {
260
260
  this.getConfig = () => {
261
261
  return this.client.get("/v1/payments/config");
262
262
  };
263
+ /**
264
+ * The `previewTransaction` method previews transaction costs including fees and surcharges
265
+ * @docs https://auctane-pay-dev.kubedev.sslocal.com/swagger/index.html#tag/Transactions
266
+ * @param request - The request object containing amount and transaction category
267
+ * @returns a promise that resolves to the transaction preview with fees
268
+ */
269
+ this.previewTransaction = (request) => {
270
+ return this.client.post(
271
+ "/v1/payments/transaction/preview",
272
+ request
273
+ );
274
+ };
263
275
  this.client = client;
264
276
  }
265
277
  }
package/index.mjs CHANGED
@@ -256,6 +256,18 @@ class AuctanePayAPI {
256
256
  this.getConfig = () => {
257
257
  return this.client.get("/v1/payments/config");
258
258
  };
259
+ /**
260
+ * The `previewTransaction` method previews transaction costs including fees and surcharges
261
+ * @docs https://auctane-pay-dev.kubedev.sslocal.com/swagger/index.html#tag/Transactions
262
+ * @param request - The request object containing amount and transaction category
263
+ * @returns a promise that resolves to the transaction preview with fees
264
+ */
265
+ this.previewTransaction = (request) => {
266
+ return this.client.post(
267
+ "/v1/payments/transaction/preview",
268
+ request
269
+ );
270
+ };
259
271
  this.client = client;
260
272
  }
261
273
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipengine/js-api",
3
- "version": "4.6.1",
3
+ "version": "4.8.0",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {