@storecraft/payments-paypal 1.0.0 → 1.0.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/README.md +42 -6
- package/adapter.html.js +2 -2
- package/adapter.js +10 -8
- package/adapter.utils.js +1 -1
- package/{tsconfig.json → jsconfig.json} +0 -5
- package/package.json +4 -4
- package/types.public.d.ts +1 -1
- package/index.js +0 -1
package/README.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# Paypal payment gateway for **StoreCraft**
|
2
2
|
|
3
|
-
|
3
|
+
<div style="text-align:center">
|
4
|
+
<img src='https://storecraft.app/storecraft-color.svg'
|
5
|
+
width='90%' />
|
6
|
+
</div><hr/><br/>
|
7
|
+
|
8
|
+
[paypal](https://developer.paypal.com/docs/checkout/) integration
|
4
9
|
|
5
10
|
## Features
|
6
11
|
- Create checkouts with `AUTHORIZE` or `CAPTURE` intents
|
@@ -9,12 +14,14 @@
|
|
9
14
|
- Supports both `prod` and `test` endpoints
|
10
15
|
|
11
16
|
```bash
|
12
|
-
npm i @storecraft/payments-paypal
|
17
|
+
npm i @storecraft/payments-paypal
|
13
18
|
```
|
14
19
|
|
15
20
|
## Howto
|
16
21
|
|
17
22
|
```js
|
23
|
+
import { PayPal } from '@storecraft/payments-paypal';
|
24
|
+
|
18
25
|
const config = {
|
19
26
|
env: 'prod',
|
20
27
|
client_id: '<get-from-your-paypal-dashboard>',
|
@@ -23,20 +30,49 @@ const config = {
|
|
23
30
|
intent_on_checkout: 'AUTHORIZE'
|
24
31
|
}
|
25
32
|
|
26
|
-
new
|
33
|
+
new Paypal(config);
|
34
|
+
```
|
35
|
+
|
36
|
+
## In Storecraft App
|
37
|
+
|
38
|
+
```ts
|
39
|
+
import { App } from '@storecraft/core';
|
40
|
+
import { MongoDB } from '@storecraft/database-mongodb';
|
41
|
+
import { NodePlatform } from '@storecraft/core/platform/node';
|
42
|
+
import { GoogleStorage } from '@storecraft/storage-google';
|
43
|
+
import { Paypal } from '@storecraft/payments-paypal'
|
44
|
+
|
45
|
+
const app = new App(config)
|
46
|
+
.withPlatform(new NodePlatform())
|
47
|
+
.withDatabase(new MongoDB())
|
48
|
+
.withStorage(new GoogleStorage())
|
49
|
+
.withPaymentGateways(
|
50
|
+
{
|
51
|
+
'paypal_standard_prod': new Paypal(
|
52
|
+
{
|
53
|
+
client_id: process.env.PAYPAL_CLIENT_ID,
|
54
|
+
secret: process.env.PAYPAL_SECRET,
|
55
|
+
env: 'prod'
|
56
|
+
}
|
57
|
+
),
|
58
|
+
}
|
59
|
+
);
|
60
|
+
|
61
|
+
await app.init();
|
62
|
+
|
27
63
|
```
|
28
64
|
|
29
65
|
## Developer info and test
|
30
66
|
|
31
67
|
Integration examples
|
32
|
-
- https://developer.paypal.com/
|
68
|
+
- [https://developer.paypal.com/](https://developer.paypal.com/)
|
33
69
|
|
34
70
|
Credit Card Generator
|
35
|
-
- https://developer.paypal.com/tools/sandbox/card-testing/#link-creditcardgenerator
|
71
|
+
- [https://developer.paypal.com/tools/sandbox/card-testing/#link-creditcardgenerator](https://developer.paypal.com/tools/sandbox/card-testing/#link-creditcardgenerator)
|
36
72
|
|
37
73
|
## todo:
|
38
74
|
- Add tests
|
39
|
-
-
|
75
|
+
- Add webhook support
|
40
76
|
|
41
77
|
```text
|
42
78
|
Author: Tomer Shalev (tomer.shalev@gmail.com)
|
package/adapter.html.js
CHANGED
@@ -10,8 +10,8 @@
|
|
10
10
|
* - Expiry date: 12/2027
|
11
11
|
* - CVC code: 897
|
12
12
|
*
|
13
|
-
* @param {import("./types.public.
|
14
|
-
* @param {Partial<import("@storecraft/core/
|
13
|
+
* @param {import("./types.public.d.ts").Config} config
|
14
|
+
* @param {Partial<import("@storecraft/core/api").OrderData>} order_data
|
15
15
|
*/
|
16
16
|
export default function html_buy_ui(config, order_data) {
|
17
17
|
const orderData = order_data?.payment_gateway?.on_checkout_create;
|
package/adapter.js
CHANGED
@@ -1,15 +1,17 @@
|
|
1
|
-
import {
|
1
|
+
import {
|
2
|
+
CheckoutStatusEnum, PaymentOptionsEnum
|
3
|
+
} from '@storecraft/core/api/types.api.enums.js';
|
2
4
|
import { fetch_with_auth, throw_bad_response } from './adapter.utils.js';
|
3
|
-
import { StorecraftError } from '@storecraft/core/
|
5
|
+
import { StorecraftError } from '@storecraft/core/api/utils.func.js';
|
4
6
|
import html_buy_ui from './adapter.html.js';
|
5
7
|
|
6
8
|
/**
|
7
|
-
* @typedef {import('./types.private.
|
8
|
-
* @typedef {import('@storecraft/core/
|
9
|
-
* @typedef {import('@storecraft/core/
|
10
|
-
* @typedef {import('@storecraft/core/
|
11
|
-
* @typedef {import('./types.public.
|
12
|
-
* @typedef {import('@storecraft/core/
|
9
|
+
* @typedef {import('./types.private.d.ts').paypal_order} CreateResult
|
10
|
+
* @typedef {import('@storecraft/core/api').PaymentGatewayStatus} PaymentGatewayStatus
|
11
|
+
* @typedef {import('@storecraft/core/api').CheckoutStatusEnum} CheckoutStatusOptions
|
12
|
+
* @typedef {import('@storecraft/core/api').OrderData} OrderData
|
13
|
+
* @typedef {import('./types.public.d.ts').Config} Config
|
14
|
+
* @typedef {import('@storecraft/core/payments').payment_gateway<Config, CreateResult>} payment_gateway
|
13
15
|
*/
|
14
16
|
|
15
17
|
/**
|
package/adapter.utils.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@storecraft/payments-paypal",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.2",
|
4
4
|
"description": "Official Paypal integration with Storecraft",
|
5
5
|
"license": "MIT",
|
6
6
|
"author": "Tomer Shalev (https://github.com/store-craft)",
|
@@ -8,7 +8,7 @@
|
|
8
8
|
"repository": {
|
9
9
|
"type": "git",
|
10
10
|
"url": "https://github.com/store-craft/storecraft.git",
|
11
|
-
"directory": "packages/payments-paypal"
|
11
|
+
"directory": "packages/payments/payments-paypal"
|
12
12
|
},
|
13
13
|
"keywords": [
|
14
14
|
"commerce",
|
@@ -17,8 +17,8 @@
|
|
17
17
|
"storecraft"
|
18
18
|
],
|
19
19
|
"type": "module",
|
20
|
-
"main": "
|
21
|
-
"types": "
|
20
|
+
"main": "adapter.js",
|
21
|
+
"types": "types.public.d.ts",
|
22
22
|
"scripts": {
|
23
23
|
"payments-paypal:test": "uvu -c",
|
24
24
|
"payments-paypal:publish": "npm publish --access public"
|
package/types.public.d.ts
CHANGED
package/index.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './adapter.js'
|