@storecraft/payments-paypal 1.0.1 → 1.0.3
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 +32 -3
- package/adapter.html.js +1 -1
- package/adapter.js +9 -7
- package/package.json +5 -5
package/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
<div style="text-align:center">
|
4
4
|
<img src='https://storecraft.app/storecraft-color.svg'
|
5
|
-
width='90%'
|
5
|
+
width='90%' />
|
6
6
|
</div><hr/><br/>
|
7
7
|
|
8
8
|
[paypal](https://developer.paypal.com/docs/checkout/) integration
|
@@ -33,13 +33,42 @@ const config = {
|
|
33
33
|
new Paypal(config);
|
34
34
|
```
|
35
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
|
+
|
63
|
+
```
|
64
|
+
|
36
65
|
## Developer info and test
|
37
66
|
|
38
67
|
Integration examples
|
39
|
-
- https://developer.paypal.com/
|
68
|
+
- [https://developer.paypal.com/](https://developer.paypal.com/)
|
40
69
|
|
41
70
|
Credit Card Generator
|
42
|
-
- 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)
|
43
72
|
|
44
73
|
## todo:
|
45
74
|
- Add tests
|
package/adapter.html.js
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
* - CVC code: 897
|
12
12
|
*
|
13
13
|
* @param {import("./types.public.d.ts").Config} config
|
14
|
-
* @param {Partial<import("@storecraft/core/
|
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/
|
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
|
11
13
|
* @typedef {import('./types.public.d.ts').Config} Config
|
12
|
-
* @typedef {import('@storecraft/core/
|
14
|
+
* @typedef {import('@storecraft/core/payments').payment_gateway<Config, CreateResult>} payment_gateway
|
13
15
|
*/
|
14
16
|
|
15
17
|
/**
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@storecraft/payments-paypal",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.3",
|
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",
|
@@ -21,10 +21,10 @@
|
|
21
21
|
"types": "types.public.d.ts",
|
22
22
|
"scripts": {
|
23
23
|
"payments-paypal:test": "uvu -c",
|
24
|
-
"
|
25
|
-
|
26
|
-
"dependencies": {
|
24
|
+
"test": "npm run payments-paypal:test",
|
25
|
+
"prepublishOnly": "npm version patch --force"
|
27
26
|
},
|
27
|
+
"dependencies": {},
|
28
28
|
"devDependencies": {
|
29
29
|
"@storecraft/core": "^1.0.0",
|
30
30
|
"@types/node": "^20.11.0",
|