{"_id":"@alsharie/jawalijs","_rev":"1-639214f17850b9de786f685e72359fa3","name":"@alsharie/jawalijs","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.2":{"name":"@alsharie/jawalijs","version":"1.0.2","keywords":["jawali","payment","gateway"],"author":{"name":"Abdulrahman alsharie"},"license":"MIT","_id":"@alsharie/jawalijs@1.0.2","maintainers":[{"name":"alsharie","email":"abdulrahman.alsharie@gmail.com"}],"homepage":"https://github.com/Alsharie/jawali-payment-js#readme","bugs":{"url":"https://github.com/Alsharie/jawali-payment-js/issues"},"dist":{"shasum":"be10c0a028f33fdb0f32956129113e6443eb5c6a","tarball":"https://registry.npmjs.org/@alsharie/jawalijs/-/jawalijs-1.0.2.tgz","fileCount":62,"integrity":"sha512-VytX3Z4v4FLALj3zbzH/ORmSZ257bJpjXc5QGe7YQbpvqkt3PcffsXaJXOMZTk8RkjBt1Hit1PucQEw9yPgjxw==","signatures":[{"sig":"MEQCIEPI1WTdSUqMJ2wNqAVH9wJXMmv/03YgVmPWZM6P8FNsAiAwV4x+QMOiT+rzBFhXmi1q2dAv4fQnjJ44yplVZwcTlg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":72180},"main":"./dist/cjs/index.js","type":"module","types":"./dist/cjs/index.d.ts","module":"./dist/esm/index.js","exports":{"import":"./dist/esm/index.js","require":"./dist/cjs/index.js"},"gitHead":"996d46c925ec15d28980d45d30f90359bd326771","scripts":{"build":"npm run build:esm && npm run build:cjs","build:cjs":"tsc --project tsconfig.cjs.json","build:esm":"tsc --project tsconfig.esm.json"},"_npmUser":{"name":"alsharie","email":"abdulrahman.alsharie@gmail.com"},"repository":{"url":"git+https://github.com/Alsharie/jawali-payment-js.git","type":"git"},"_npmVersion":"10.9.0","description":"A Node.js package for interacting with the Jawali payment gateway","directories":{},"_nodeVersion":"22.11.0","dependencies":{"axios":"^1.7.9","node-fetch":"^3.3.1","axios-retry":"^4.5.0"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.7.3","@types/node":"^22.13.4"},"_npmOperationalInternal":{"tmp":"tmp/jawalijs_1.0.2_1739949964255_0.8140825649416283","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@alsharie/jawalijs","version":"1.0.3","main":"./dist/cjs/index.js","module":"./dist/esm/index.js","exports":{"import":"./dist/esm/index.js","require":"./dist/cjs/index.js"},"type":"module","description":"A Node.js package for interacting with the Jawali payment gateway","keywords":["jawali","payment","gateway"],"author":{"name":"Abdulrahman alsharie"},"license":"MIT","dependencies":{"axios":"^1.7.9","axios-retry":"^4.5.0","node-fetch":"^3.3.1"},"scripts":{"build":"npm run build:esm && npm run build:cjs","build:esm":"tsc --project tsconfig.esm.json","build:cjs":"tsc --project tsconfig.cjs.json"},"repository":{"type":"git","url":"git+https://github.com/Alsharie/jawali-payment-js.git"},"devDependencies":{"@types/node":"^22.13.4","typescript":"^5.7.3"},"_id":"@alsharie/jawalijs@1.0.3","gitHead":"996d46c925ec15d28980d45d30f90359bd326771","types":"./dist/cjs/index.d.ts","bugs":{"url":"https://github.com/Alsharie/jawali-payment-js/issues"},"homepage":"https://github.com/Alsharie/jawali-payment-js#readme","_nodeVersion":"22.11.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-FpSmn0tYcv2FA8nMCMBSuLWkMB7h5ROpSm4er0IAX5V+GmtbnS+nFn/jf7NiamgvcW/gbJCnxcJhODKjbtAutQ==","shasum":"3a7b36764158639a32fa1b4992dbb12773f228ad","tarball":"https://registry.npmjs.org/@alsharie/jawalijs/-/jawalijs-1.0.3.tgz","fileCount":63,"unpackedSize":109925,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDVh91l2OES6JVjAshkw8pcaguUJiTk+iY4D+fO5828dAIhAIgtXri2lC/9UsZBxzG5uT9YSdItyX6i0IMjSlw/fjqz"}]},"_npmUser":{"name":"alsharie","email":"abdulrahman.alsharie@gmail.com"},"directories":{},"maintainers":[{"name":"alsharie","email":"abdulrahman.alsharie@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/jawalijs_1.0.3_1739950914805_0.06636176837365415"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-19T07:26:04.194Z","modified":"2025-02-19T07:41:55.197Z","1.0.2":"2025-02-19T07:26:04.508Z","1.0.3":"2025-02-19T07:41:55.005Z"},"bugs":{"url":"https://github.com/Alsharie/jawali-payment-js/issues"},"author":{"name":"Abdulrahman alsharie"},"license":"MIT","homepage":"https://github.com/Alsharie/jawali-payment-js#readme","keywords":["jawali","payment","gateway"],"repository":{"type":"git","url":"git+https://github.com/Alsharie/jawali-payment-js.git"},"description":"A Node.js package for interacting with the Jawali payment gateway","maintainers":[{"name":"alsharie","email":"abdulrahman.alsharie@gmail.com"}],"readme":"# Jawali Payment\n\n![Logo](img.png)\n\nJawali Payment is a Node.js package for interacting with the Jawali payment gateway. It provides a simple API to perform operations like ecommerce inquiry and cash out.\n\n---\n\n## Installation\n\nFirst, install the package via npm:\n\n```bash\nnpm install @alsharie/jawalijs\n```\n\n---\n\n## Configuration\n\nCreate a configuration object with your gateway credentials and URL. For example:\n\n```js\nconst config = {\n  auth: {\n    phone: '',\n    username: '',\n    password: '',\n    org_id: '',\n    user_id: '',\n    external_user: '',\n    wallet: '',\n    wallet_password: '',\n    wallet_identifier: '',\n  },\n  url: {\n    base: '',\n    disableSslVerification: true, // set to false if you want SSL verification enabled\n  },\n};\n\nthis.jawali = new JawaliGateway(config);\n```\n\nIn the configuration above, the `disableSslVerification` flag is used to control SSL behavior.\n\n---\n\n## Usage Example\n\nBelow is an example of how to perform an ecommerce inquiry and then a cash out (ecommca shout). This example demonstrates how to use the provided response classes and handle different response states.\n\n```js\nimport {\n  JawaliEcommcaShoutResponse,\n  JawaliEcommerceInquiryResponse,\n  JawaliGateway,\n} from '@alsharie/jawalijs';\n\nasync function requestPayment() {\n  try {\n    const voucher = 'xxxxx';\n    const phone = '7xxxxxxxx';\n    const note = '';\n    const price = 1000;\n    const currency = 'YER';\n\n    // Perform an ecommerce inquiry\n    const data = await this.jawali.ecommerceInquiry(voucher, phone, note);\n\n    if (data instanceof JawaliEcommerceInquiryResponse && data.isSuccess()) {\n      // Check if the state is \"PENDING\" and the amount and currency are correct\n      if (data.getState() === 'PENDING') {\n        if (data.getAmount() == price && data.getCurrency() === currency) {\n          // Perform cash-out using ecommcaShout\n          const ecommcaShout = await this.jawali.ecommcaShout(voucher, phone, note);\n\n          if (ecommcaShout instanceof JawaliEcommcaShoutResponse && ecommcaShout.isSuccess()) {\n            return {\n              message: 'تم تحويل المبلغ بنجاح',\n              success: ecommcaShout.isSuccess(),\n              data: ecommcaShout.getResponse(),\n            };\n          } else {\n            return {\n              message: 'حدث خطأ أثناء تحويل المبلغ',\n              success: ecommcaShout?.isSuccess?.() || false,\n              data: ecommcaShout?.getResponse?.(),\n            };\n          }\n        }\n      } else {\n        return {\n          message: 'تم تحويل المبلغ من قبل',\n          success: data.isSuccess(),\n          data: data.getResponse(),\n        };\n      }\n    } else {\n      return {\n        message: 'حدث خطأ أثناء التاكد من قيمة المبلغ',\n        success: data?.isSuccess?.(),\n        data: data?.getResponse?.(),\n      };\n    }\n  } catch (error) {\n    return error;\n  }\n}\n```\n\n### Explanation\n\n- **ecommerceInquiry**  \n  This method contacts the gateway to verify payment details. The response is an instance of `JawaliEcommerceInquiryResponse` if successful.\n\n- **ecommcaShout**  \n  When the inquiry indicates a pending state with the correct amount and currency, the `ecommcaShout` method is called to complete the cash-out. Its response is wrapped in the `JawaliEcommcaShoutResponse` class.\n\n- **Response Handling**  \n  Use `instanceof` checks to verify the type of the response. Then call methods like `getAmount()`, `getCurrency()`, `getState()`, and `getResponse()` to access the details.\n\n---\n\n## License\n\nThis project is licensed under the MIT License. See the LICENSE file for more details.\n```","readmeFilename":"README.md"}