payrex-node 1.2.0 → 1.2.1
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 +4 -0
- package/package.json +1 -1
- package/src/services/RefundService.js +10 -0
- package/test2.js +55 -0
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -16,6 +16,16 @@ RefundService.prototype.create = function (payload) {
|
|
|
16
16
|
});
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
+
RefundService.prototype.update = function (id, payload) {
|
|
20
|
+
return this.request({
|
|
21
|
+
path: `${this.path}/${id}`,
|
|
22
|
+
payload: payload,
|
|
23
|
+
method: 'put',
|
|
24
|
+
}).then(function (response) {
|
|
25
|
+
return new RefundEntity(response);
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
|
|
19
29
|
Object.setPrototypeOf(RefundService.prototype, BaseService.prototype);
|
|
20
30
|
|
|
21
31
|
module.exports = RefundService;
|
package/test2.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const payrex = require('payrex-node')(
|
|
2
|
+
'sk_live_znE26cM4ZbZP3mfTLeZsnw7EceWHKiPN'
|
|
3
|
+
);
|
|
4
|
+
|
|
5
|
+
const RequestInvalidError = require('./src/errors/RequestInvalidError');
|
|
6
|
+
const AuthenticationInvalidError = require('./src/errors/AuthenticationInvalidError');
|
|
7
|
+
const ResourceNotFoundError = require('./src/errors/ResourceNotFoundError');
|
|
8
|
+
|
|
9
|
+
// try {
|
|
10
|
+
// const paymentIntent = await payrex.paymentIntents.create({ amount: 10000 });
|
|
11
|
+
// } catch (error) {
|
|
12
|
+
// console.log('caught error!')
|
|
13
|
+
// if (error instanceof ResourceNotFoundError) {
|
|
14
|
+
// // handle error if a resource does not exist.
|
|
15
|
+
// } else if (error instanceof AuthenticationInvalidError) {
|
|
16
|
+
// // handle authentication error
|
|
17
|
+
// } else if (error instanceof RequestInvalidError) {
|
|
18
|
+
// console.log('handle error if there\'s validation error');
|
|
19
|
+
|
|
20
|
+
// error.errors.forEach((e) => {
|
|
21
|
+
// console.log(e.code);
|
|
22
|
+
// console.log(e.detail);
|
|
23
|
+
// });
|
|
24
|
+
// }
|
|
25
|
+
// }
|
|
26
|
+
|
|
27
|
+
(async () => {
|
|
28
|
+
try {
|
|
29
|
+
const paymentIntent = await payrex.paymentIntents.create({ amount: 10000 });
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.log('caught error!');
|
|
32
|
+
console.log(error.name);
|
|
33
|
+
if (error.name === 'ResourceNotFoundError') {
|
|
34
|
+
// handle error if a resource does not exist.
|
|
35
|
+
} else if (error.name === 'AuthenticationInvalidError') {
|
|
36
|
+
// handle authentication error
|
|
37
|
+
} else if (error.name === 'RequestInvalidError') {
|
|
38
|
+
console.log("handle error if there's validation error");
|
|
39
|
+
|
|
40
|
+
error.errors.forEach((e) => {
|
|
41
|
+
console.log(e.code);
|
|
42
|
+
console.log(e.detail);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
})();
|
|
47
|
+
|
|
48
|
+
const refund = await payrex.refunds.update(
|
|
49
|
+
're_xPy5nb7p6R7jG4ZPEJu5WvVCb8Lz31qx',
|
|
50
|
+
{
|
|
51
|
+
metadata: {
|
|
52
|
+
'some_key3': 'some_val3'
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
)
|