├── pages ├── docs │ ├── asiapay │ │ ├── integration.mdx │ │ ├── getting-started.mdx │ │ └── _meta.json │ ├── fastpay │ │ ├── integration.mdx │ │ ├── getting-started.mdx │ │ └── _meta.json │ ├── paytabs │ │ ├── integration.mdx │ │ ├── getting-started.mdx │ │ └── _meta.json │ ├── zaincash │ │ ├── index.mdx │ │ ├── _meta.json │ │ ├── getting-started.mdx │ │ ├── transactionFlow.mdx │ │ ├── checkTransaction.mdx │ │ ├── redirectHandling.mdx │ │ └── createTransaction.mdx │ ├── _meta.json │ ├── changelog.mdx │ ├── introduction.mdx │ └── index.mdx ├── index.mdx ├── _app.js ├── about.mdx ├── _document.tsx └── _meta.json ├── .eslintrc.json ├── public ├── favicon.ico ├── images │ ├── flow1.png │ └── github-image.jpg ├── vercel.svg └── next.svg ├── postcss.config.js ├── next.config.js ├── styles └── globals.css ├── .gitignore ├── tailwind.config.js ├── tsconfig.json ├── package.json ├── README.md ├── components └── home.tsx └── theme.config.jsx /pages/docs/asiapay/integration.mdx: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pages/docs/fastpay/integration.mdx: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pages/docs/paytabs/integration.mdx: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "next/core-web-vitals" 3 | } 4 | -------------------------------------------------------------------------------- /pages/index.mdx: -------------------------------------------------------------------------------- 1 | import Home from '../components/home' 2 | 3 | # 4 | 5 | -------------------------------------------------------------------------------- /pages/docs/asiapay/getting-started.mdx: -------------------------------------------------------------------------------- 1 | import Image from 'next/image'; 2 | 3 | # AsiaPay -------------------------------------------------------------------------------- /pages/docs/fastpay/getting-started.mdx: -------------------------------------------------------------------------------- 1 | import Image from 'next/image'; 2 | 3 | # FasyPay -------------------------------------------------------------------------------- /pages/docs/paytabs/getting-started.mdx: -------------------------------------------------------------------------------- 1 | import Image from 'next/image'; 2 | 3 | # PayTabs -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohammedkmo/iraq-payments/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /public/images/flow1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohammedkmo/iraq-payments/HEAD/public/images/flow1.png -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /public/images/github-image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohammedkmo/iraq-payments/HEAD/public/images/github-image.jpg -------------------------------------------------------------------------------- /pages/docs/asiapay/_meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "getting-started": "Getting Started", 3 | "integration": "API Integration" 4 | } 5 | -------------------------------------------------------------------------------- /pages/docs/fastpay/_meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "getting-started": "Getting Started", 3 | "integration": "API Integration" 4 | } 5 | -------------------------------------------------------------------------------- /pages/docs/paytabs/_meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "getting-started": "Getting Started", 3 | "integration": "API Integration" 4 | } 5 | -------------------------------------------------------------------------------- /next.config.js: -------------------------------------------------------------------------------- 1 | const withNextra = require('nextra')({ 2 | theme: 'nextra-theme-docs', 3 | themeConfig: './theme.config.jsx', 4 | }) 5 | 6 | module.exports = withNextra() 7 | -------------------------------------------------------------------------------- /pages/_app.js: -------------------------------------------------------------------------------- 1 | 2 | // write _app.js file 3 | import React from 'react'; 4 | import "../styles/globals.css"; 5 | 6 | 7 | export default function App({ Component, pageProps }) { 8 | return 9 | } -------------------------------------------------------------------------------- /pages/about.mdx: -------------------------------------------------------------------------------- 1 | # About Iraq Payments 🇮🇶 2 | 3 | Iraq Payments is a documents that contains all the Docs of the payment gateways in Iraq. 4 | 5 | ## How to contribute 6 | 7 | 1. Fork the repo 8 | 2. Add your payment gateway docs 9 | 3. Create a pull request 10 | -------------------------------------------------------------------------------- /pages/_document.tsx: -------------------------------------------------------------------------------- 1 | import { Html, Head, Main, NextScript } from 'next/document' 2 | 3 | export default function Document() { 4 | return ( 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | ) 13 | } -------------------------------------------------------------------------------- /pages/docs/zaincash/index.mdx: -------------------------------------------------------------------------------- 1 | # ZainCash 2 | 3 | This documentation helps you integrate and implement ZainCash into your website or mobile application to allow your customers to pay you over ZainCash. 4 | 5 | Version: `1.0` 6 | Updated: `23 Mar, 2023` 7 | Test API: `test.zaincash.iq` 8 | Live API: `api.zaincash.iq` -------------------------------------------------------------------------------- /pages/docs/zaincash/_meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "index": { 3 | "display": "hidden" 4 | }, 5 | "getting-started": "Getting Started", 6 | "transactionFlow": "Transaction Flow", 7 | "createTransaction": "Create transaction", 8 | "redirectHandling": "Redirect handling", 9 | "checkTransaction": "Check transaction" 10 | } 11 | -------------------------------------------------------------------------------- /pages/docs/_meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "index": { 3 | "type": "separator", 4 | "title": "Getting Started" 5 | }, 6 | "introduction": "Introduction", 7 | "changelog": "Changelog", 8 | "---": { 9 | "type": "separator" 10 | }, 11 | "zaincash": "ZainCash", 12 | "asiapay": "AsiaPay", 13 | "paytabs": "PayTabs", 14 | "fastpay": "FastPay" 15 | } 16 | -------------------------------------------------------------------------------- /styles/globals.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | :root { 6 | --foreground-rgb: 0, 0, 0; 7 | --background-start-rgb: 214, 219, 220; 8 | --background-end-rgb: 255, 255, 255; 9 | } 10 | 11 | @media (prefers-color-scheme: dark) { 12 | :root { 13 | --foreground-rgb: 255, 255, 255; 14 | --background-start-rgb: 0, 0, 0; 15 | --background-end-rgb: 0, 0, 0; 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /pages/_meta.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "*": { 4 | "type": "page" 5 | }, 6 | "index": { 7 | "title": "Home", 8 | "theme": { 9 | "sidebar": false, 10 | "layout": "full", 11 | "typesetting": "article" 12 | } 13 | }, 14 | "docs": "Documentations", 15 | "about": { 16 | "title": "About", 17 | "theme": { 18 | "sidebar": false, 19 | "layout": "full", 20 | "typesetting": "article" 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | *.pem 21 | 22 | # debug 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | 27 | # local env files 28 | .env*.local 29 | 30 | # vercel 31 | .vercel 32 | 33 | # typescript 34 | *.tsbuildinfo 35 | next-env.d.ts 36 | -------------------------------------------------------------------------------- /tailwind.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: [ 4 | './pages/**/*.{js,ts,jsx,tsx,mdx}', 5 | './components/**/*.{js,ts,jsx,tsx,mdx}', 6 | './app/**/*.{js,ts,jsx,tsx,mdx}', 7 | ], 8 | theme: { 9 | extend: { 10 | backgroundImage: { 11 | 'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))', 12 | 'gradient-conic': 13 | 'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))', 14 | }, 15 | }, 16 | }, 17 | plugins: [], 18 | } 19 | -------------------------------------------------------------------------------- /public/vercel.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "strict": true, 8 | "forceConsistentCasingInFileNames": true, 9 | "noEmit": true, 10 | "esModuleInterop": true, 11 | "module": "esnext", 12 | "moduleResolution": "node", 13 | "resolveJsonModule": true, 14 | "isolatedModules": true, 15 | "jsx": "preserve", 16 | "incremental": true, 17 | "paths": { 18 | "@/*": ["./*"] 19 | } 20 | }, 21 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], 22 | "exclude": ["node_modules"] 23 | } 24 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "iraq-payments", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "next build", 8 | "start": "next start", 9 | "lint": "next lint" 10 | }, 11 | "dependencies": { 12 | "@types/node": "20.3.1", 13 | "@types/react": "18.2.14", 14 | "@types/react-dom": "18.2.6", 15 | "autoprefixer": "10.4.14", 16 | "eslint": "8.43.0", 17 | "eslint-config-next": "13.4.7", 18 | "next": "13.4.7", 19 | "nextra": "^2.8.0", 20 | "nextra-theme-docs": "^2.8.0", 21 | "postcss": "8.4.24", 22 | "react": "18.2.0", 23 | "react-dom": "18.2.0", 24 | "tailwindcss": "3.3.2", 25 | "typescript": "5.1.3" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /pages/docs/changelog.mdx: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Version 1.0.0 (2023-06-25) 4 | 5 | - Initial launch of the project. 6 | - Completed documentation for the ZainCash payment gateway. 7 | - Added a "Getting Started" guide to help developers kickstart their integration process with Iraqi payment gateways. 8 | - Invited developers to contribute to the project on GitHub. 9 | 10 | We're excited to release the first version of our developer documentation project, focusing on integrating Iraqi payment gateways. With the completion of the ZainCash documentation, developers can now refer to detailed guides, code samples, and examples to seamlessly integrate ZainCash into their applications. 11 | 12 | We're committed to continuously improving and expanding our documentation to provide a comprehensive resource for integrating other Iraqi payment gateways like AsiaPay, FastPay, Paytabs, and more. Stay tuned for future updates and additions. 13 | 14 | We encourage your feedback and suggestions to help us enhance the documentation and make it even more valuable for developers. If you encounter any issues, have questions, or want to contribute, please don't hesitate to reach out to us on GitHub. 15 | 16 | Thank you for your support and happy integrating with Iraqi payment gateways! 17 | 18 | -------------------------------------------------------------------------------- /public/next.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pages/docs/zaincash/getting-started.mdx: -------------------------------------------------------------------------------- 1 | import Image from 'next/image'; 2 | 3 | # ZainCash API 4 | 5 | ZainCash is a mobile wallet service that allows users to perform financial transactions using their mobile devices. It provides a secure and convenient way to send and receive money, pay bills, recharge mobile credit, and more. 6 | 7 | ## Prerequisites 8 | 9 | Before integrating the ZainCash API into your application, make sure you have the following: 10 | 11 | - ZainCash API credentials (username and password) obtained by registering with ZainCash. 12 | - Understanding of the available ZainCash API endpoints and their functionalities. 13 | - Basic knowledge of making HTTP requests using Curl, Node.js, or PHP. 14 | 15 | ## Test credentials 16 | 17 | Before you start you can use the below credentials to test the API. 18 | 19 | ### Merchant 20 | 21 | Use one of the following merchant credentials to test the creation of transaction IDs and checking status, (make sure to copy each with no spaces. also note that the secret is one line). 22 | 23 | | MSISDN | Merchant ID | Merchant Secret | 24 | | :------------ | :-----------------------: | :----- | 25 | | 9647835077893 | 5ffacf6612b5777c6d44266f | $2y$10$hBbAZo2GfSSvyqAyV2SaqOfYewgYpfR1O19gIh4SqyGWdmySZYPuS | 26 | 27 | ### Customer 28 | 29 | Use one of the following customer credentials to test the submition of transactions. 30 | 31 | | MSISDN | PIN | OTP | 32 | | :------------ | :---: | :--- | 33 | | 9647802999569 | 1234 | 1111 | 34 | | 9647806999267 | 6847 | 1111 | 35 | -------------------------------------------------------------------------------- /pages/docs/zaincash/transactionFlow.mdx: -------------------------------------------------------------------------------- 1 | # Transaction flow 2 | The flow of the transaction of ZainCash can be simplified into the following points: 3 | 4 | - FE - Customer start the payment process from website or mobile. 5 | - BE - A request is being sent from the backend to ZainCash to create a Transaction ID ( example ). containing the following parameters: 6 | - amount `integer` - The amount for the transaction, IQD only and min is 250. 7 | - serviceType `string` - Title or info for the transaction, example: "a book". 8 | - msisdn `long integer` - The mobile phone number for your wallet, example format: 9647802999569. 9 | - orderId `string` - a reference for your system to update your tables on, example: "229" or "ss22". 10 | - redirectUrl `string` - a link for your website to receive the user on after he finish his payment. this is used as a webhook as well for the indication of the user's transaction status. 11 | - ZainCash return a Transaction ID to the backend 12 | - BE - The Customer is redirected to the link `https://ZAIN_CASH_API/transaction/pay?id=TRANSACTION_ID`, replace `TRANSACTION_ID` with the received Transaction ID and `ZAIN_CASH_API` with the API of zaincash for if it is on test or live, the APIs mentioned previously. 13 | - FE - The Customer finish the transaction and is then automatically redirected to the redirectUrl of the transaction. 14 | - BE - The backend decodes the token parameter received for the redirectUrl link to indicate the state of the transaction. 15 | - BE - System tables updated. 16 | - FE - Customer notified. 17 | 18 | The below diagram explains the flow. 19 | 20 | ```mermaid 21 | sequenceDiagram 22 | customer->>+backend of server: 1 23 | backend of server->>+ZainCash: 2 24 | ZainCash-->>backend of server: 3 25 | backend of server-->>customer: 4 26 | customer->>+ZainCash: 5 27 | ZainCash-->>backend of server: 6/7 28 | backend of server-->>customer: 8 29 | ``` -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Iraq Payments 2 | 3 | ![Alt text](https://github.com/mohammedkmo/iraq-payments/blob/main/public/images/github-image.jpg "github banner") 4 | 5 | Welcome to the Iraqi Payment Gateway Developer Docs repository! This project aims to provide a comprehensive and easy-to-use resource for developers looking to integrate Iraqi payment gateways into their applications. 6 | 7 | ## Table of Contents 8 | - [Introduction](#introduction) 9 | - [Getting Started](#getting-started) 10 | - [Contributing](#contributing) 11 | - [Changelog](#changelog) 12 | 13 | ## Introduction 14 | The Iraqi Payment Gateway Developer Docs project is designed to simplify the integration process with various payment gateways in Iraq. We understand that integrating payment solutions can be complex, so our goal is to provide clear and concise documentation that guides developers through the integration steps. 15 | 16 | ## Getting Started 17 | To get started with the integration process, please refer to our [Getting Started](./docs/getting-started.md) guide. It provides an overview of the integration requirements and walks you through the necessary steps to begin integrating with Iraqi payment gateways. 18 | 19 | ## Contributing 20 | We welcome contributions from the developer community to help improve and expand the documentation. If you would like to contribute, please see our [Contribution Guidelines](./CONTRIBUTING.md) for more information. Whether it's suggesting improvements, adding support for new payment gateways, or fixing bugs, every contribution is valuable and appreciated. 21 | 22 | ## Changelog 23 | For a detailed list of changes and updates to the documentation, please refer to the [Changelog](./CHANGELOG.md) page. It provides information about each version release, including new features, bug fixes, and any other relevant updates. 24 | 25 | ## License 26 | This project is licensed under the [MIT License](./LICENSE). 27 | 28 | ## Contact 29 | If you have any questions, suggestions, or feedback, please feel free to reach out to us at [hello@mohammedk.me](mailto:hello@mohammedk.me). 30 | 31 | Let's simplify the integration of Iraqi payment gateways together! 32 | -------------------------------------------------------------------------------- /pages/docs/zaincash/checkTransaction.mdx: -------------------------------------------------------------------------------- 1 | import { Tab, Tabs } from "nextra-theme-docs"; 2 | 3 | # Check transaction 4 | 5 | Sometimes transactions go pending due to connectivity issue ove the customer's end, in such cases you can check for the status of the transaction as explained in the following simple example. 6 | 7 | 8 | 9 | 10 | ```php copy 11 | require_once('credentials.php'); 12 | require_once('includes/autoload.php'); 13 | use \Firebase\JWT\JWT; 14 | 15 | // ----------------- Request Details -------------------------- 16 | // The ID for the transaction you want to check 17 | $id = '61ac94f43c22082431672b27'; 18 | 19 | //building data 20 | $data = [ 21 | 'id' => $id, 22 | 'msisdn' => $msisdn, 23 | 'iat' => time(), 24 | 'exp' => time()+60*60*4 25 | ]; 26 | 27 | //Encoding Token 28 | $newtoken = JWT::encode( 29 | $data, //Data to be encoded in the JWT 30 | $secret ,'HS256' 31 | ); 32 | 33 | //Check if test or production mode 34 | if($production_cred){ 35 | $rUrl = 'https://api.zaincash.iq/transaction/get'; 36 | }else{ 37 | $rUrl = 'https://test.zaincash.iq/transaction/get'; 38 | } 39 | 40 | //POST data to ZainCash API 41 | $data_to_post = array(); 42 | $data_to_post['token'] = urlencode($newtoken); 43 | $data_to_post['merchantId'] = $merchantid; 44 | $options = array( 45 | 'http' => array( 46 | 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 47 | 'method' => 'POST', 48 | 'content' => http_build_query($data_to_post), 49 | ), 50 | ); 51 | $context = stream_context_create($options); 52 | $response = file_get_contents($rUrl, false, $context); 53 | 54 | echo $response; 55 | ``` 56 | 57 | 58 | ```js copy 59 | const jwt = require('jsonwebtoken'); 60 | const querystring = require('querystring'); 61 | const https = require('https'); 62 | 63 | const secret = 'your_secret_key'; // Replace with your actual secret key 64 | const productionCred = true; // Set to true for production credentials, false for test credentials 65 | 66 | // Transaction ID 67 | const id = '61ac94f43c22082431672b27'; 68 | 69 | // Building data 70 | const data = { 71 | id: id, 72 | msisdn: msisdn, 73 | iat: Math.floor(Date.now() / 1000), 74 | exp: Math.floor(Date.now() / 1000) + 60 * 60 * 4 75 | }; 76 | 77 | // Encoding Token 78 | const newToken = jwt.sign(data, secret, { algorithm: 'HS256' }); 79 | 80 | // Check if test or production mode 81 | let rUrl; 82 | if (productionCred) { 83 | rUrl = 'https://api.zaincash.iq/transaction/get'; 84 | } else { 85 | rUrl = 'https://test.zaincash.iq/transaction/get'; 86 | } 87 | 88 | // POST data to ZainCash API 89 | const dataToPost = { 90 | token: encodeURIComponent(newToken), 91 | merchantId: merchantid 92 | }; 93 | 94 | const postData = querystring.stringify(dataToPost); 95 | 96 | const options = { 97 | hostname: new URL(rUrl).hostname, 98 | path: new URL(rUrl).pathname, 99 | method: 'POST', 100 | headers: { 101 | 'Content-Type': 'application/x-www-form-urlencoded', 102 | 'Content-Length': Buffer.byteLength(postData) 103 | } 104 | }; 105 | 106 | const req = https.request(options, (res) => { 107 | let responseData = ''; 108 | 109 | res.on('data', (chunk) => { 110 | responseData += chunk; 111 | }); 112 | 113 | res.on('end', () => { 114 | console.log(responseData); 115 | }); 116 | }); 117 | 118 | req.on('error', (error) => { 119 | console.error(error); 120 | }); 121 | 122 | req.write(postData); 123 | req.end(); 124 | ``` 125 | 126 | -------------------------------------------------------------------------------- /pages/docs/zaincash/redirectHandling.mdx: -------------------------------------------------------------------------------- 1 | import { Tab, Tabs } from "nextra-theme-docs"; 2 | 3 | # Redirect handling 4 | 5 | This following is a simple example of handling the redirect and decode of the token received after transaction complete. 6 | 7 | 8 | 9 | ```php copy 10 | require_once('credentials.php'); 11 | require_once('includes/autoload.php'); 12 | use \Firebase\JWT\JWT; 13 | 14 | 15 | /* ------------------------------------------------------------------------------ 16 | Notes about $redirection_url: 17 | in this url, the api will add a new parameter (token) to its end like: 18 | https://example.com/redirect.php?token=XXXXXXXXXXXXXX 19 | */ 20 | 21 | if (isset($_GET['token'])){ 22 | 23 | //you can decode the token by this PHP code: 24 | $result= JWT::decode($_GET['token'], $secret, array('HS256')); 25 | echo json_encode($result); 26 | $result= (array) $result; 27 | 28 | //And to check for status of the transaction, use $result['status'], like this: 29 | if ($result['status']=='success'){ 30 | //Successful transaction 31 | 32 | //$result will be like this example: 33 | /* 34 | array(5) { 35 | ["status"]=> 36 | string(7) "success" 37 | ["orderid"]=> 38 | string(9) "Bill12345" 39 | ["id"]=> 40 | string(24) "58650f0f90c6362288da08cf" 41 | ["iat"]=> 42 | int(1483018052) 43 | ["exp"]=> 44 | int(1483032452) 45 | } 46 | */ 47 | } 48 | if ($result['status']=='failed'){ 49 | //Failed transaction and its reason 50 | $reason=$result['msg']; 51 | //$result will be like this example: 52 | /* 53 | array(6) { 54 | ["status"]=> 55 | string(6) "failed" 56 | ["msg"]=> 57 | string(33) "Invalid credentials for requester" 58 | ["orderid"]=> 59 | string(9) "Bill12345" 60 | ["id"]=> 61 | string(24) "58650ca990c6362288da08c8" 62 | ["iat"]=> 63 | int(1483017397) 64 | ["exp"]=> 65 | int(1483020997) 66 | } 67 | */ 68 | 69 | } 70 | } else { 71 | //Cancelled transaction (if he clicked "Cancel and go back" 72 | //NO TOKEN HERE 73 | } 74 | ``` 75 | 76 | 77 | 78 | ```js copy 79 | const jwt = require('jsonwebtoken'); 80 | const querystring = require('querystring'); 81 | 82 | const secret = 'your_secret_key'; // Replace with your actual secret key 83 | 84 | // Redirect URL 85 | const redirectionUrl = 'https://example.com/redirect.php'; 86 | 87 | // Check if the token is present in the URL 88 | const query = querystring.parse(new URL(redirectionUrl).search.substring(1)); 89 | if (query.token) { 90 | try { 91 | const result = jwt.verify(query.token, secret); 92 | 93 | console.log(JSON.stringify(result)); 94 | const resultObj = JSON.parse(JSON.stringify(result)); 95 | 96 | // Check the transaction status 97 | if (resultObj.status === 'success') { 98 | // Successful transaction 99 | console.log('Successful transaction'); 100 | } else if (resultObj.status === 'failed') { 101 | // Failed transaction and its reason 102 | const reason = resultObj.msg; 103 | console.log('Failed transaction:', reason); 104 | } 105 | } catch (error) { 106 | console.error('Token verification failed:', error.message); 107 | } 108 | } else { 109 | // Cancelled transaction (if the user clicked "Cancel and go back") 110 | // No token here 111 | console.log('Cancelled transaction'); 112 | } 113 | ``` 114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /pages/docs/introduction.mdx: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | github image 4 | 5 | In today's digital era, payment gateways play a crucial role in enabling secure and convenient online transactions. For developers seeking to integrate payment gateways into their applications or websites, navigating through the complex documentation of multiple providers can be a daunting task. However, we have a solution! Welcome to our comprehensive developer documentation project, designed specifically to simplify the integration process for various Iraqi payment gateways. 6 | 7 | ### Overview 8 | Our project aims to streamline the integration process by providing developers with a centralized resource that combines all the necessary documentation for popular Iraqi payment gateways. Whether you are working on an e-commerce platform, a mobile application, or any other online service that requires payment processing, our documentation will serve as your go-to guide, offering a wealth of information in a user-friendly and easy-to-understand format. 9 | 10 | ### Simplifying Integration 11 | We understand that integrating payment gateways can be a complex and time-consuming task, especially when dealing with multiple providers. That's why our project acts as a one-stop solution, offering comprehensive documentation for various payment gateways, including ZainCash, AsiaPay, FastPay, Paytabs, and more. By consolidating all the relevant information in a single location, we aim to simplify the integration process, saving you valuable time and effort. 12 | 13 | ### Comprehensive Documentation 14 | Our documentation covers a wide range of topics, providing detailed explanations, step-by-step integration guides, code samples, and best practices for each payment gateway. Whether you're a seasoned developer or just starting out, our carefully crafted documentation ensures that you have all the information you need to seamlessly integrate payment gateways into your applications. From setting up merchant accounts and generating API keys to handling payment callbacks and managing transaction statuses, we've got you covered. 15 | 16 | ### User-Friendly Interface 17 | We believe that developer documentation should be intuitive and easy to navigate. Our platform provides a clean and user-friendly interface, allowing you to quickly find the information you need. Whether you're searching for specific API endpoints, exploring available payment methods, or learning about the authentication process, our organized and structured documentation makes it effortless to access the desired details. Additionally, we provide search functionality and interactive code snippets to enhance your overall experience. 18 | 19 | ### Regular Updates and Community Support 20 | To ensure the accuracy and relevance of our documentation, we strive to keep it up to date with the latest changes and updates from each payment gateway provider. Our team continuously monitors API changes, new features, and industry trends to provide you with the most current and accurate information. Furthermore, we encourage a vibrant community of developers who can contribute their insights, share experiences, and provide assistance through our dedicated forums and support channels. 21 | 22 | ### Conclusion 23 | Integrating payment gateways should not be a barrier to the success of your online business or application. With our comprehensive developer documentation project, you have access to a centralized resource that simplifies the integration process for various Iraqi payment gateways. By combining detailed explanations, step-by-step guides, and best practices, we empower you to seamlessly incorporate secure and efficient payment processing into your projects. Join our community today and unlock the power of hassle-free payment gateway integration. -------------------------------------------------------------------------------- /components/home.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Home: React.FC = () => { 4 | return ( 5 |
6 | 7 |
8 |

Simplify Payment Gateway Integration in Iraq 🇮🇶

9 |

10 | Welcome to the Iraqi Payment Gateway Developer Docs, your one-stop resource for simplifying payment gateway integration in Iraq. Whether you’re a developer looking to integrate payment gateways into your application or a business seeking seamless payment solutions, we’ve got you covered. 11 |

12 |
13 | 14 |
15 |
16 |

Streamline Your Integration Process

17 |

18 | Integrating payment gateways can be complex and time-consuming, especially when dealing with specific regional requirements. Our mission is to simplify this process by providing comprehensive documentation, code samples, and guides tailored to the Iraqi market. We’ve done the hard work of gathering all the necessary information and best practices, so you can focus on creating exceptional payment experiences for your users. 19 |

20 |
21 | 22 |
23 |

Comprehensive Documentation for Iraqi Payment Gateways

24 |

25 | Our documentation covers a wide range of payment gateways prominent in Iraq, including ZainCash, AsiaPay, FastPay, Paytabs, and more. From understanding the basics to step-by-step integration instructions, our comprehensive guides will walk you through the process, ensuring a smooth integration experience. Say goodbye to the hassle of scouring multiple sources for information – everything you need is right here. 26 |

27 |
28 | 29 |
30 |

Collaborative Community

31 |

32 | We believe in the power of collaboration and community-driven development. The Iraqi Payment Gateway Developer Docs is an open-source project, and we welcome contributions from developers like you. Share your expertise, suggest improvements, or even add support for new payment gateways. Together, we can enhance the documentation and create a robust resource for everyone. 33 |

34 |
35 | 36 |
37 |

Get Started Today!

38 |

39 | Ready to simplify payment gateway integration in Iraq? Start by exploring our documentation and finding the gateway that suits your needs. Whether you’re a seasoned developer or just starting out, our guides will provide the guidance you need to succeed. If you have any questions or need assistance, our dedicated support team is here to help. 40 |

41 |
42 |
43 | 44 |

45 | Join us on this journey of revolutionizing payment solutions in Iraq. Together, we can empower businesses and developers to offer secure, convenient, and seamless payment 46 | experiences for everyone. 47 |

48 |
49 | ); 50 | } 51 | 52 | export default Home; -------------------------------------------------------------------------------- /pages/docs/zaincash/createTransaction.mdx: -------------------------------------------------------------------------------- 1 | import { Tab, Tabs } from "nextra-theme-docs"; 2 | 3 | # Create transaction 4 | 5 | This following is a simple example of creating a transaction ID for the ccustomer to submit 6 | 7 | ### Order Details 8 | 9 | 10 | 11 | ```php copy 12 | $amount = 250; // Amount in IQ dinar 13 | 14 | $service_type = "A book"; //Type of service you provide, like 'Books', 'ecommerce cart', 'Hosting services', ... 15 | 16 | $order_id = "Bill_1234567890"; // you can use it to help you in tagging transactions with your website IDs, if you have no order numbers in your website, leave it 1 17 | 18 | $redirection_url = 'http://localhost/redirect.php'; // after a successful or failed order, the user will redirect to this url 19 | ``` 20 | 21 | 22 | 23 | ```js copy 24 | const amount = 250; // Amount in IQ dinar 25 | 26 | const serviceType = "A book"; // Type of service you provide, like 'Books', 'ecommerce cart', 'Hosting services', ... 27 | 28 | const orderId = "Bill_1234567890"; // You can use it to help you in tagging transactions with your website IDs. If you have no order numbers on your website, you can leave it as 1 29 | 30 | const redirectionUrl = 'http://localhost/redirect.php'; // After a successful or failed order, the user will be redirected to this URL 31 | ``` 32 | 33 | 34 | 35 | ``` 36 | Notes about $redirection_url: 37 | in this url, the api will add a new parameter (token) to its end like: 38 | https://example.com/redirect.php?token=XXXXXXXXXXXXXX``` 39 | 40 | ``` 41 | 42 | ### Building data 43 | 44 | 45 | 46 | ```php copy 47 | $data = [ 48 | 'amount' => $amount, 49 | 'serviceType' => $service_type, 50 | 'msisdn' => $msisdn, // Your wallet phone number 51 | 'orderId' => $order_id, 52 | 'redirectUrl' => $redirection_url, 53 | 'iat' => time(), 54 | 'exp' => time()+60*60*4 55 | ]; 56 | ``` 57 | 58 | 59 | ```js copy 60 | const data = { 61 | amount: amount, 62 | serviceType: serviceType, 63 | msisdn: msisdn, // Your wallet phone number 64 | orderId: orderId, 65 | redirectUrl: redirectionUrl, 66 | iat: Math.floor(Date.now() / 1000), 67 | exp: Math.floor(Date.now() / 1000) + 60 * 60 * 4 68 | }; 69 | ``` 70 | 71 | 72 | 73 | ### Encoding Token 74 | 75 | 76 | 77 | ```php copy 78 | $token = JWT::encode($data, $secret_key); // $secret_key is your secret key 79 | 80 | $tUrl = 'https://test.zaincash.iq/transaction/init'; 81 | $rUrl = 'https://test.zaincash.iq/transaction/pay?id='; 82 | ``` 83 | 84 | 85 | ```js copy 86 | const token = jwt.sign(data, secretKey); // secretKey is your secret key 87 | 88 | const tUrl = 'https://test.zaincash.iq/transaction/init'; 89 | const rUrl = 'https://test.zaincash.iq/transaction/pay?id='; 90 | ``` 91 | 92 | 93 | 94 | ### POST data to ZainCash API 95 | 96 | 97 | 98 | ```php copy 99 | $data_to_post = array(); 100 | $data_to_post['token'] = urlencode($newtoken); 101 | $data_to_post['merchantId'] = $merchantid; // Your merchant ID is requested from ZainCash 102 | $data_to_post['lang'] = $language; 103 | 104 | $options = array( 105 | 'http' => array( 106 | 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 107 | 'method' => 'POST', 108 | 'content' => http_build_query($data_to_post), 109 | ), 110 | ); 111 | 112 | $context = stream_context_create($options); 113 | $response = file_get_contents($tUrl, false, $context); 114 | ``` 115 | 116 | 117 | ```js copy 118 | const postData = { 119 | token: token, // token is the token you got from the previous step 120 | merchantId: merchantId, // Your merchant ID is requested from ZainCash 121 | lang: 'en' | 'ar' // en for English, ar for Arabic 122 | }; 123 | 124 | const requestOptions = { 125 | uri: tUrl, // tUrl is the URL you got from the previous step 126 | body: JSON.stringify(postData), // postData is the data you want to send to the API 127 | method: "POST", 128 | headers: { 129 | "Content-Type": "application/json" 130 | } 131 | }; 132 | 133 | request(requestOptions, function(error, response) { 134 | if (error) reject(error); 135 | if (response && response.body && JSON.parse(response.body).id) 136 | resolve(JSON.parse(response.body).id); 137 | reject(response); 138 | }); 139 | ``` 140 | 141 | -------------------------------------------------------------------------------- /theme.config.jsx: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line import/no-anonymous-default-export 2 | export default { 3 | logo: ( 4 | 5 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | ), 32 | project: { 33 | link: "https://github.com/mohammedkmo/iraq-payments", 34 | }, 35 | footer: { 36 | text: ( 37 | 38 | Iraq Payment {new Date().getFullYear()} ©{" "} 39 | 40 | Mohammedk 41 | 42 | . 43 | 44 | ), 45 | }, 46 | head: ( 47 | <> 48 | 49 | 50 | 51 | 55 | 56 | 57 | 58 | 59 | 60 | 64 | 65 | 66 | 67 | ), 68 | useNextSeoProps() { 69 | return { 70 | titleTemplate: "%s – Iraq Payments", 71 | }; 72 | }, 73 | banner: { 74 | key: "1.0-release", 75 | text: ( 76 | 77 | 🎉 Iraq-Payments 1.0 is released. Read more → 78 | 79 | ), 80 | }, 81 | docsRepositoryBase: 'https://github.com/mohammedkmo/iraq-payments/tree/main' 82 | }; 83 | -------------------------------------------------------------------------------- /pages/docs/index.mdx: -------------------------------------------------------------------------------- 1 | # Getting Started 2 | 3 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | Welcome to our developer documentation project, designed to simplify the integration process for various Iraqi payment gateways. This guide will walk you through the essential steps to get started with integrating payment gateways into your applications. Let's dive in! 30 | 31 | ## Contribute on GitHub 32 | 33 | We value collaboration and the power of the developer community. If you're passionate about simplifying the integration of Iraqi payment gateways and want to make a meaningful contribution, we invite you to join our project on GitHub. 34 | 35 | By contributing to our project, you can help us expand and improve the developer documentation, making it even more comprehensive and user-friendly. Here are some ways you can contribute: 36 | 37 | 1. **Documentation Enhancements**: Have ideas for improving the existing documentation? Feel free to suggest updates, clarifications, or additional examples to make the content more helpful and accessible to developers of all levels of experience. 38 | 39 | 2. **New Payment Gateway Support**: Is there a payment gateway that we haven't covered yet? You can contribute by adding documentation for additional Iraqi payment gateways. Share your knowledge and help other developers integrate these gateways effortlessly. 40 | 41 | 3. **Code Samples and Demos**: Providing code samples and demos can greatly assist developers in understanding the integration process. If you have any relevant code snippets, sample projects, or integration demos, we'd love to include them in our repository. 42 | 43 | 4. **Bug Fixes and Issue Reporting**: If you come across any bugs, inconsistencies, or errors in the documentation, please report them on our GitHub repository. Your feedback will help us maintain the accuracy and quality of our content. 44 | 45 | 5. **Translations**: Are you fluent in multiple languages? Help us translate the documentation into different languages, making it accessible to developers from diverse backgrounds. 46 | 47 | Contributing to our project on GitHub is a fantastic opportunity to showcase your skills, collaborate with fellow developers, and make a lasting impact on the developer community. 48 | 49 | To get started, simply visit our [GitHub repository](https://github.com/mohammedkmo/iraq-payments), explore the existing issues and pull requests, and dive into the areas where you believe your expertise can make a difference. We highly value and appreciate every contribution, big or small, as it takes us one step closer to our goal of simplifying payment gateway integration for developers. 50 | 51 | Join us on this exciting journey and let's create an exceptional developer resource together! 52 | --------------------------------------------------------------------------------