@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 CHANGED
@@ -1,6 +1,11 @@
1
1
  # Paypal payment gateway for **StoreCraft**
2
2
 
3
- [paypal standard](https://developer.paypal.com/docs/checkout/standard/) integration
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-standard
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 PaypalStandard(config);
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/studio/checkout/standard/integrate
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
- - Think about adding more dynamic config
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.js").Config} config
14
- * @param {Partial<import("@storecraft/core/v-api").OrderData>} order_data
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 { CheckoutStatusEnum, PaymentOptionsEnum } from '@storecraft/core/v-api/types.api.enums.js';
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/v-api/utils.func.js';
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.js').paypal_order} CreateResult
8
- * @typedef {import('@storecraft/core/v-api').PaymentGatewayStatus} PaymentGatewayStatus
9
- * @typedef {import('@storecraft/core/v-api').CheckoutStatusEnum} CheckoutStatusOptions
10
- * @typedef {import('@storecraft/core/v-api').OrderData} OrderData
11
- * @typedef {import('./types.public.js').Config} Config
12
- * @typedef {import('@storecraft/core/v-payments').payment_gateway<Config, CreateResult>} payment_gateway
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
@@ -5,7 +5,7 @@ export const endpoints = {
5
5
  }
6
6
 
7
7
  /**
8
- * @typedef {import("./types.public.js").Config} Config
8
+ * @typedef {import("./types.public.d.ts").Config} Config
9
9
  */
10
10
 
11
11
  /**
@@ -1,11 +1,6 @@
1
1
  {
2
- "compileOnSave": false,
3
2
  "compilerOptions": {
4
- "noEmit": true,
5
- "allowJs": true,
6
3
  "checkJs": true,
7
- "target": "ESNext",
8
- "resolveJsonModule": true,
9
4
  "moduleResolution": "NodeNext",
10
5
  "module": "NodeNext",
11
6
  "composite": true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storecraft/payments-paypal",
3
- "version": "1.0.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": "index.js",
21
- "types": "./types.public.d.ts",
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
@@ -1,4 +1,4 @@
1
- export * from './index.js';
1
+ export { Paypal } from './adapter.js';
2
2
 
3
3
  /**
4
4
  * @description gateway config
package/index.js DELETED
@@ -1 +0,0 @@
1
- export * from './adapter.js'