Comment on page
Integration Guide
The purpose of this guide is to help developers quickly get started with the integration of the Cashramp API. This guide should be used with the rest of the API documentation.
To get started, create an account for your business over at https://cashramp.co/commerce. You'll need to submit some bio-data about yourself and your business, after which you'll get access to the Cashramp Developer dashboard.
- Click the "Generate Keys" button to generate your first Cashramp API keys.
- You'll receive a Public Key, Private Key, and a Webhook Token. Save your Private Key and Webhook Token somewhere safe and secret (ideally in your production application's environment variables).
- If your production application's webhook endpoint is set up, you can connect it at this point.
If you completed the first two steps, you're ready to make your first API call. Let's try a simple query to retrieve the countries you need when initiating a payment.
1
const axios = require('axios');
2
3
const api = axios.create({
4
baseURL: 'https://api.useaccrue.com/cashramp/api/graphql',
5
headers: { 'Authorization': `Bearer ${process.env.CASHRAMP_API_SECRET_KEY}` } });
6
7
async function _makeRequest(action, payload) {
8
try {
9
const response = await api.post("", payload);
10
if (response.status == 200) {
11
if (response.data.errors) {
12
return { success: false, error: response.data.errors[0].message };
13
} else {
14
return { success: true, result: response.data.data[action] };
15
}
16
}
17
} catch (err) {
18
return { success: false, error: err.message }
19
}
20
}
21
22
function getCountries() {
23
const query = `
24
query {
25
countries {
26
id
27
code
28
name
29
}
30
}
31
`;
32
33
// `countries` here matches the `countries` field in the query above.
34
return _makeRequest("countries", { query });
35
}
- To initiate a hosted payment, you can use these mutations:
- Once you initiate a payment request, you'll receive a link to a hosted payment page. You must redirect your user to the URL so they can complete the payment. At this point, the status of the payment request will be
created
. - As soon as the user is assigned an agent to process the deposit, the status of the payment request will be changed to
picked_up
.- You will receive a webhook notification about this change if you've set up a webhook endpoint as outlined in Step 2 above.
- As soon as a payment request is completed, its status will be changed to
completed
.- You will receive a webhook notification about this change if you've set up a webhook endpoint as outlined in Step 2 above.
When you receive a webhook notification that a payment has been
completed
or canceled
, it is recommended that you double-check by fetching the payment and confirming the status. If the status matches, you can release value to your customer as your internal business logic outlines. - Your Cashramp balance should also reflect the successful conclusion of the payment request.
Last modified 1mo ago