payrex-node 0.1.5 → 0.1.7

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.7] - 2024-07-30
4
+
5
+ - Add amount_capturable and amount_received for hold then capture partial amount support.
6
+
7
+ ## [0.1.6] - 2024-07-24
8
+
9
+ - Adjust building of parameter query due to changes in checkout session endpoints.
10
+
3
11
  ## [0.1.5] - 2024-07-24
4
12
 
5
13
  - Finalize the checkout session endpoints.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payrex-node",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "PayRex Node JS Library",
5
5
  "keywords": [
6
6
  "payrex",
@@ -30,7 +30,8 @@
30
30
  "prettier": "^3.2.5"
31
31
  },
32
32
  "dependencies": {
33
- "axios": "^1.6.8"
33
+ "axios": "^1.6.8",
34
+ "qs": "^6.12.1"
34
35
  },
35
36
  "license": "MIT",
36
37
  "scripts": {
package/src/HttpClient.js CHANGED
@@ -1,11 +1,11 @@
1
1
  const axios = require('axios');
2
+ const qs = require('qs');
2
3
 
3
4
  const ApiResource = require('./ApiResource');
4
5
  const RequestInvalidError = require('./errors/RequestInvalidError');
5
6
  const AuthenticationInvalidError = require('./errors/AuthenticationInvalidError');
6
7
  const ResourceNotFoundError = require('./errors/ResourceNotFoundError');
7
8
  const BaseError = require('./errors/BaseError');
8
- const Parameter = require('./helpers/Parameter');
9
9
 
10
10
  function HttpClient(apiKey, baseUrl) {
11
11
  this.apiKey = apiKey;
@@ -27,7 +27,12 @@ HttpClient.prototype.request = async function ({ path, method, payload }) {
27
27
  let data = null;
28
28
 
29
29
  if (method === 'post' || method === 'put') {
30
- data = Parameter.encode(payload);
30
+ data = qs.stringify(
31
+ payload,
32
+ {
33
+ arrayFormat: 'brackets'
34
+ }
35
+ );
31
36
  }
32
37
 
33
38
  try {
@@ -3,6 +3,8 @@ function PaymentIntentEntity(apiResource) {
3
3
 
4
4
  this.id = data.id;
5
5
  this.amount = data.amount;
6
+ this.amountReceived = data.amount_received;
7
+ this.amountCapturable = data.amount_capturable;
6
8
  this.clientSecret = data.client_secret;
7
9
  this.currency = data.currency;
8
10
  this.description = data.description;
@@ -1,35 +0,0 @@
1
- function Parameter() {}
2
-
3
- Parameter.encode = (params, prefix = '') => {
4
- const finalQuery = [];
5
-
6
- for(const [key, value] of Object.entries(params)) {
7
- let newKey = prefix === '' ? key : `${prefix}[${key}]`
8
-
9
- if(prefix === '') {
10
- newKey = key;
11
- } else {
12
- if(
13
- !isNaN(key) &&
14
- !Array.isArray(value) &&
15
- (typeof value !== 'object' && value !== null)
16
- ) {
17
- newKey = `${prefix}[]`;
18
- } else {
19
- newKey = `${prefix}[${key}]`;
20
- }
21
- }
22
-
23
- if(typeof value === 'object' && value !== null) {
24
- finalQuery.push(Parameter.encode(value, newKey));
25
- } else {
26
- finalQuery.push(
27
- `${encodeURI(newKey)}=${encodeURI(value)}`
28
- );
29
- }
30
- }
31
-
32
- return finalQuery.join('&');
33
- }
34
-
35
- module.exports = Parameter;