-
Notifications
You must be signed in to change notification settings - Fork 13
payout-mercyoyelude2 submission #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Mercy-Iyanu
wants to merge
6
commits into
WriteTech-Hub:main
Choose a base branch
from
Mercy-Iyanu:payout-mercyoyelude2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4228742
docs: create submission files
Mercy-Iyanu 4bab965
docs: create submission files
Mercy-Iyanu df2f3a3
update: final submission
Mercy-Iyanu 4f54672
Update tutorial.md
Mercy-Iyanu 213322d
Update setup.md
Mercy-Iyanu 9ff98fd
Update tutorial.md
Mercy-Iyanu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| # How to Use Chimoney’s Interledger Wallet Address Payout Endpoint | ||
| > Endpoint: `/payouts/interledger-wallet-address` | ||
|
|
||
| Before you jump into integrating Chimoneys payout API, here is a quick walkthrough to get everything set up and ready to roll. | ||
|
|
||
| --- | ||
|
|
||
| ## 🧰 Prerequisites | ||
|
|
||
| Before diving in, make sure you have the following: | ||
|
|
||
| - 🔐 **Chimoney Developer Account** | ||
| Create one here: [chimoney.io/developers-api](https://chimoney.io/developers-api) | ||
|
|
||
| Account is funded with $1000(10000 Chimoney) of test amount. | ||
|
|
||
| - 🔑 **API Key** | ||
| Grab it from your dashboard. Need help? [Watch this video](https://www.loom.com/share/436303eb69c44f0d9757ea0c655bed89?sid=b6a0f661-721c-4731-9873-ae6f2d25780) | ||
|
|
||
| - 💳 **Interledger Wallet Address** | ||
| Found on your dashboard after login. It will look something like: | ||
| `https://ilp-sandbox.chimoney.com/your-unique-id` | ||
|
|
||
| - 🧪 **API Testing Tools (Optional)** | ||
| Use any of the following: | ||
| - Postman | ||
| - Curl | ||
| - Your favorite HTTP client (e.g. Axios, Fetch) | ||
|
|
||
| - 🧠 **Basic Knowledge of REST APIs** | ||
| You will be working with `POST` requests and JSON payloads. | ||
|
|
||
| --- | ||
|
|
||
| ## 🚀 Test the Endpoint in the API Explorer | ||
|
|
||
| Let us make a test call using Chimoney’s Swagger (API explorer): | ||
|
|
||
| 1. Go to [Chimoney’s API Explorer](https://api.chimoney.io/v0.2.4/api-docs/#/Payouts/post_v0_2_4_payouts_interledger_wallet_address) | ||
| 2. Switch to `sandbox mode` (top-left dropdown) | ||
|
|
||
|  | ||
|
|
||
| 3. Click **Authorize** and paste your API key | ||
| 4. [Jump](https://api.chimoney.io/v0.2.4/api-docs/#/Payouts/post_v0_2_4_payouts_interledger_wallet_address) to `POST /payouts/interledger-wallet-address` | ||
| 5. Replace the `interledgerWalletAddress` field with your own ILP address | ||
| 6. Hit **Execute**! | ||
|
|
||
| Boom — your first test payout should go through if all is set up correctly ✅ | ||
|
|
||
| --- | ||
|
|
||
| ## 🛠 Common Errors and How to Fix Them | ||
|
|
||
| ### ❌ Error: `CAD is not enabled for the interledger Wallet Address` | ||
|
|
||
| ```json | ||
| { | ||
| "status": "error", | ||
| "message": "CAD is not enabled for the interledger Wallet Address (Payment Pointer), https://ilp-sandbox.chimoney.com/********" | ||
| } | ||
| ``` | ||
|
|
||
| ### 💡 Why it happens: | ||
| Your ILP wallet only supports USD (not CAD). | ||
|
|
||
| ### ✅ Fix: Change both currency fields to USD: | ||
| ```json | ||
| "currency": "USD", | ||
| "debitCurrency": "USD" | ||
| ``` | ||
|
|
||
| **🕵️♀️ Pro tip:** Open your ILP wallet address in a browser to confirm supported assets. | ||
|
|
||
|
|
||
|  | ||
|
|
||
| ### ❌ Error: `sender must be a valid Chimoney user ID` | ||
|
|
||
| ### 💡 Why it happens: | ||
| You have either included an invalid subAccount or do not need one. | ||
|
|
||
| ### ✅ Fix: | ||
|
|
||
| - Don’t have a subAccount? Just remove the field. | ||
|
|
||
| - Or go to your dashboard → Transactions tab → copy your user ID. | ||
|
|
||
| --- | ||
|
|
||
| ## Other API Responses | ||
| If everything checks out, you should see a success response like this: | ||
|
|
||
| ### ✅ 200 OK – Success | ||
| ```json | ||
| { | ||
| "status": "success", | ||
| "message": "Chimoney payout to Interledger wallet completed successfully", | ||
| "data": { | ||
| "paymentLink": "https://sandbox.chimoney.io/pay/?issueID=...", | ||
| "chimoneys": [ | ||
| { | ||
| "interledgerWalletAddress": "https://ilp-sandbox.chimoney.com/your-id", | ||
| "amount": 200, | ||
| "currency": "USD", | ||
| "chiRef": "some-unique-id" | ||
| } | ||
| ], | ||
| "redeemLink": "https://sandbox.chimoney.io/redeem/?chi=..." | ||
| } | ||
| } | ||
| ``` | ||
| Use the `paymentLink` or `redeemLink` to simulate or test payouts end-to-end. | ||
|
|
||
|
|
||
| ### ⚠️ 400 / 401 / 403 – Invalid or Unauthorized Request | ||
|
|
||
| ```json | ||
| { | ||
| "status": "error", | ||
| "error": "sender must be a valid Chimoney user ID" | ||
| } | ||
| ``` | ||
|
|
||
| Or: | ||
|
|
||
| ```json | ||
| { | ||
| "status": "error", | ||
| "message": "Unauthorized – API key missing or invalid" | ||
| } | ||
| ``` | ||
|
|
||
| Refer to the **Common Errors** section above to resolve these. | ||
|
|
||
| ### 💥 500 – Internal Server Error | ||
| ```json | ||
| { | ||
| "status": "error", | ||
| "type": "InternalError", | ||
| "code": "SERVER_ERROR", | ||
| "message": "Something went wrong" | ||
| } | ||
| ``` | ||
| If this happens, double-check your payload format or retry later. | ||
|
|
||
| --- | ||
|
|
||
| ## Wrapping Up | ||
| That is it! At this point, you should be able to: | ||
|
|
||
| - Create a Chimoney developer account and generate an API key | ||
|
|
||
| - Authenticate using your API key | ||
|
|
||
| - Locate and use your ILP wallet address | ||
|
|
||
| - Make a test payout request via the API Explorer | ||
|
|
||
| - Troubleshoot common errors like currency mismatch or sender ID issues | ||
|
|
||
| ### 🎯 Next Step: Integrate the API in your project | ||
|
|
||
| Now that you are all set up, let us write some code and make payouts from your app using this [tutorial guide](./tutorial.md). | ||
|
|
||
| **Happy building!** 🙌 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,218 @@ | ||
| # How to Make Payouts to Interledger Wallets Using Chimoney’s API | ||
|
|
||
| In this tutorial, you will learn how to integrate Chimoney’s `/payouts/interledger-wallet-address` endpoint into your existing project and send live payouts using your wallet-enabled Chimoney account. | ||
|
|
||
| --- | ||
|
|
||
| ## 🔧 What You’ll Build | ||
|
|
||
| - Configure your environment | ||
| - Build a payout service with Chimoney’s API | ||
| - Handle real-world errors (like currency mismatches) | ||
| - Test your first ILP payout | ||
|
|
||
| --- | ||
|
|
||
| ## 🧰 Prerequisites | ||
|
|
||
| Before you start, make sure you have completed the [Setup Guide](./setup.md). You should already have: | ||
| - A Chimoney developer account | ||
| - Your API key | ||
| - Your ILP wallet address | ||
| - Tested the `payouts to interledger wallet address` endpoint | ||
|
|
||
| Additionally; | ||
| - Basic knowledge on RESTful APIs | ||
| - Node.js and npm/yarn installed | ||
| - Axios for HTTP requests | ||
|
|
||
| With that out of the way, let us dive in. | ||
|
|
||
| --- | ||
|
|
||
| ## 🗂 Project Structure | ||
|
|
||
| Here’s what your folder might look like: | ||
|
|
||
| ```bash | ||
| chimoney-payouts/ | ||
| ├── .env | ||
| ├── src/ | ||
| │ ├── config.js | ||
| │ ├── services/ | ||
| │ │ └── chimoneyService.js | ||
| │ └── index.js | ||
| ├── package.json | ||
| └── README.md | ||
| ``` | ||
|
|
||
| ## 🗂 Step 1: 🔧 Configuration & Setup | ||
|
|
||
| ### Install Dependencies | ||
|
|
||
| ```bash | ||
| mkdir chimoney-payouts && cd chimoney-payouts | ||
| npm init -y | ||
| npm install axios dotenv | ||
| ``` | ||
|
|
||
| ### Environment Variables | ||
|
|
||
| Create `.env`: | ||
|
|
||
| ```js | ||
| CHIMONEY_API_KEY=your_api_key_here | ||
| CHIMONEY_ENV=sandbox # or "production" | ||
|
|
||
| ILP_WALLET_ADDRESS=https://ilp-sandbox.chimoney.com/your-id | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### Configuration Module (`config.js`) | ||
|
|
||
| ```js | ||
| import dotenv from "dotenv"; | ||
| dotenv.config(); | ||
|
|
||
| export const config = { | ||
| apiKey: process.env.CHIMONEY_API_KEY, | ||
| baseUrl: | ||
| process.env.CHIMONEY_ENV === "production" | ||
| ? "https://api-v2.chimoney.io/v0.2.4" | ||
| : "https://api-v2-sandbox.chimoney.io/v0.2.4", | ||
| headers: { | ||
| Accept: "application/json", | ||
| "Content-Type": "application/json", | ||
| "X-API-KEY": process.env.CHIMONEY_API_KEY, | ||
| }, | ||
| }; | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## 🧾 Step 2: Build the Chimoney Interledger Service | ||
| ### Create `chimoneyService.js`: | ||
|
|
||
| ```js | ||
| import axios from "axios"; | ||
| import { config } from "./config.js"; | ||
|
|
||
| class ChimoneyService { | ||
| constructor() { | ||
| this.client = axios.create({ | ||
| baseURL: config.baseUrl, | ||
| headers: config.headers, | ||
| }); | ||
| } | ||
|
|
||
| async sendInterledgerPayout({ walletAddress, amount, narration, collectionPaymentIssueID = "" }) { | ||
| try { | ||
| const payload = { | ||
| turnOffNotification: false, | ||
| debitCurrency: "USD", | ||
| interledgerWallets: [ | ||
| { | ||
| interledgerWalletAddress: walletAddress, | ||
| currency: "USD", | ||
| amountToDeliver: amount, | ||
| narration, | ||
| collectionPaymentIssueID, // optional but great for tracking payouts | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| const res = await this.client.post("/payouts/interledger-wallet-address", payload); | ||
| return res.data; | ||
| } catch (err) { | ||
| if (err.response) { | ||
| console.error("Chimoney API error:", err.response.data); | ||
| throw err.response.data; | ||
| } | ||
| throw err; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| export default ChimoneyService; | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## ⚙️ Step 3: Usage Example (`index.js`) | ||
|
|
||
| ```js | ||
| import ChimoneyService from "./chimoneyService.js"; | ||
| import dotenv from "dotenv"; | ||
| dotenv.config(); | ||
|
|
||
| (async () => { | ||
| const service = new ChimoneyService(); | ||
|
|
||
| const walletAddress = process.env.ILP_WALLET_ADDRESS; // e.g., https://ilp-sandbox.chimoney.com/your-id | ||
| const amount = 10; // USD | ||
| const narration = "Freelance payout for job #123"; | ||
| const collectionPaymentIssueID = "job-123-issue"; | ||
|
|
||
| try { | ||
| const result = await service.sendInterledgerPayout({ | ||
| walletAddress, | ||
| amount, | ||
| narration, | ||
| collectionPaymentIssueID, | ||
| }); | ||
| console.log("✅ Payout Success:", result); | ||
| } catch (error) { | ||
| const res = error.response; | ||
| console.error("❌ Payout Failed:", { | ||
| status: res?.status, | ||
| message: res?.data?.message || res?.data?.error || error.message | ||
| }); | ||
| // handle error messages, e.g.: | ||
| // if errorData.message includes "CAD is not enabled" | ||
| // if errorData.error includes "valid Chimoney user ID" | ||
| } | ||
| })(); | ||
| ``` | ||
|
|
||
| ### 🧪 Notes & Error Handling | ||
| #### Response Object Includes: | ||
| - status, message | ||
| - data.paymentLink / data.redeemLink | ||
| - data.chimoneys or data.payouts with chiRef, issueID, etc. | ||
|
|
||
|
|
||
| ### ⚠️ Common Errors | ||
| Here are a couple of issues you might hit (and how to fix them): | ||
|
|
||
| #### 1. ❌ "CAD is not enabled" | ||
| **Fix:** Change **currency** to "USD" | ||
|
|
||
| #### 2. ❌ "sender must be a valid Chimoney user ID" | ||
| **Fix:** Invalid **subAccount**, (remove the field if unused, or request for one through support). | ||
|
|
||
|
|
||
| **Wrap error handler to inspect `errorData.message` or `.error` and act accordingly.** | ||
|
|
||
| --- | ||
|
|
||
| ## 🔄 How It Works (Behind the Scenes) | ||
|
|
||
| 1. 🧾 You make a `POST` request to the `/payouts/interledger-wallet-address` endpoint | ||
| 2. 🔐 Chimoney authenticates your API key | ||
| 3. 💳 Chimoney deducts the amount from your wallet | ||
| 4. 🌐 The ILP wallet address receives the payout (in supported currency) | ||
| 5. 📦 A response is returned with `chiRef`, status, and optionally a `paymentLink` | ||
|
|
||
| --- | ||
|
|
||
| ## 🎉 You Did It | ||
| You just: | ||
|
|
||
| - Set up your environment | ||
| - Made a successful payout to an Interledger wallet | ||
| - Learned how to handle and debug errors | ||
|
|
||
|
|
||
| _🔗 Next up: Extend this into a backend job or admin panel!_ | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.