@storecraft/payments-paypal 1.0.17 → 1.2.5

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.
Files changed (3) hide show
  1. package/README.md +3 -7
  2. package/adapter.js +7 -7
  3. package/package.json +2 -3
package/README.md CHANGED
@@ -46,13 +46,9 @@ const app = new App(config)
46
46
  .withPlatform(new NodePlatform())
47
47
  .withDatabase(new MongoDB())
48
48
  .withStorage(new GoogleStorage())
49
- .withPaymentGateways(
50
- {
51
- 'paypal_standard_prod': new Paypal() // config can be inferred from env variables
52
- }
53
- );
54
-
55
- await app.init();
49
+ .withPaymentGateways({
50
+ paypal_standard_prod: new Paypal() // config can be inferred from env variables
51
+ }).init();
56
52
 
57
53
  ```
58
54
 
package/adapter.js CHANGED
@@ -26,13 +26,13 @@ import html_buy_ui from './adapter.html.js';
26
26
  export class Paypal {
27
27
 
28
28
  /** @satisfies {ENV<Config>} */
29
- static EnvConfigProd = /** @type{const} */ ({
29
+ static EnvConfigProd = /** @type {const} */ ({
30
30
  client_id: `PAYPAL_CLIENT_ID_PROD`,
31
31
  secret: 'PAYPAL_SECRET_PROD',
32
32
  });
33
33
 
34
34
  /** @satisfies {ENV<Config>} */
35
- static EnvConfigTest = /** @type{const} */ ({
35
+ static EnvConfigTest = /** @type {const} */ ({
36
36
  client_id: `PAYPAL_CLIENT_ID_TEST`,
37
37
  secret: 'PAYPAL_SECRET_TEST',
38
38
  });
@@ -56,19 +56,19 @@ export class Paypal {
56
56
  /** @type {Impl["onInit"]} */
57
57
  onInit = (app) => {
58
58
  const is_prod = Boolean(this.config.env==='prod');
59
- this.config.client_id ??= app.platform.env[
59
+ this.config.client_id ??= app.env[
60
60
  is_prod ? Paypal.EnvConfigProd.client_id : Paypal.EnvConfigTest.client_id
61
- ] ?? app.platform.env['PAYPAL_CLIENT_ID'];
61
+ ] ?? app.env['PAYPAL_CLIENT_ID'];
62
62
 
63
- this.config.secret ??= app.platform.env[
63
+ this.config.secret ??= app.env[
64
64
  is_prod ? Paypal.EnvConfigProd.secret : Paypal.EnvConfigTest.secret
65
- ] ?? app.platform.env['PAYPAL_SECRET'];
65
+ ] ?? app.env['PAYPAL_SECRET'];
66
66
 
67
67
  const is_valid = this.config.client_id && this.config.secret;
68
68
 
69
69
  if(!is_valid) {
70
70
  throw new StorecraftError(
71
- `Payment gateway ${this.info.name ?? 'unknown'} has invalid config !!!
71
+ `Payment gateway ${this.info?.name ?? 'unknown'} has invalid config !!!
72
72
  Missing client_id or secret`
73
73
  )
74
74
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storecraft/payments-paypal",
3
- "version": "1.0.17",
3
+ "version": "1.2.5",
4
4
  "description": "Official Paypal integration with Storecraft",
5
5
  "license": "MIT",
6
6
  "author": "Tomer Shalev (https://github.com/store-craft)",
@@ -21,8 +21,7 @@
21
21
  "types": "types.public.d.ts",
22
22
  "scripts": {
23
23
  "payments-paypal:test": "uvu -c",
24
- "test": "npm run payments-paypal:test",
25
- "prepublishOnly": "npm version patch --force"
24
+ "test": "npm run payments-paypal:test"
26
25
  },
27
26
  "dependencies": {},
28
27
  "devDependencies": {