Skip to content

Commit 6bca78e

Browse files
Merge pull request #107 from PaystackOSS/chore-transfer
chore: update transfer snippets
2 parents 99c832a + ae287ac commit 6bca78e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1330
-535
lines changed

dist/api/transfers/bulk/requests.js

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,29 @@ const sh = `#!/bin/sh
22
url="https://api.paystack.co/transfer/bulk"
33
authorization="Authorization: Bearer YOUR_SECRET_KEY"
44
content_type="Content-Type: application/json"
5-
data='{
6-
"currency": "NGN",
7-
"source": "balance",
8-
"transfers": [
9-
{
10-
"amount": 20000,
11-
"reference": "588YtfftReF355894J",
12-
"reason": "Why not?",
13-
"recipient": "RCP_2tn9clt23s7qr28"
14-
},
15-
{
16-
"amount": 30000,
17-
"reference": "YunoTReF35e0r4J",
18-
"reason": "Because I can",
19-
"recipient": "RCP_1a25w1h3n0xctjg"
20-
},
21-
{
22-
"amount": 40000,
23-
"reason": "Coming right up",
24-
"recipient": "RCP_aps2aibr69caua7"
25-
}
26-
]
5+
data='{
6+
"currency": "NGN",
7+
"source": "balance",
8+
"transfers": [
9+
{
10+
"amount": 20000,
11+
"reference": "ACV_2627bbfe-1a2a-4a1a-8d0e-9d2ee6c31496",
12+
"reason": "Bonus for the week",
13+
"recipient": "RCP_gd9vgag7n5lr5ix"
14+
},
15+
{
16+
"amount": 35000,
17+
"reference": "ACV_1bd0c1f8-78c2-463b-8bd4-ed9eeb36be50",
18+
"reason": "Bonus for the week",
19+
"recipient": "RCP_zpk2tgagu6lgb4g"
20+
},
21+
{
22+
"amount": 15000,
23+
"reference": "ACV_11bebfc3-18b3-40aa-a4df-c55068c93457",
24+
"reason": "Bonus for the week",
25+
"recipient": "RCP_dfznnod8rwxlwgn"
26+
}
27+
]
2728
}'
2829
2930
curl "$url" -H "$authorization" -H "$content_type" -d "$data" -X POST`
@@ -36,20 +37,21 @@ const params = JSON.stringify({
3637
"transfers": [
3738
{
3839
"amount": 20000,
39-
"reference": "588YtfftReF355894J",
40-
"reason": "Why not?",
41-
"recipient": "RCP_2tn9clt23s7qr28"
40+
"reference": "ACV_2627bbfe-1a2a-4a1a-8d0e-9d2ee6c31496",
41+
"reason": "Bonus for the week",
42+
"recipient": "RCP_gd9vgag7n5lr5ix"
4243
},
4344
{
44-
"amount": 30000,
45-
"reference": "YunoTReF35e0r4J",
46-
"reason": "Because I can",
47-
"recipient": "RCP_1a25w1h3n0xctjg"
45+
"amount": 35000,
46+
"reference": "ACV_1bd0c1f8-78c2-463b-8bd4-ed9eeb36be50",
47+
"reason": "Bonus for the week",
48+
"recipient": "RCP_zpk2tgagu6lgb4g"
4849
},
4950
{
50-
"amount": 40000,
51-
"reason": "Coming right up",
52-
"recipient": "RCP_aps2aibr69caua7"
51+
"amount": 15000,
52+
"reference": "ACV_11bebfc3-18b3-40aa-a4df-c55068c93457",
53+
"reason": "Bonus for the week",
54+
"recipient": "RCP_dfznnod8rwxlwgn"
5355
}
5456
]
5557
})
@@ -90,20 +92,21 @@ const php = `<?php
9092
'source' => "balance",
9193
'transfers' => [[
9294
"amount" => 20000,
93-
"reference" => "588YtfftReF355894J",
94-
"reason" => "Why not?",
95-
"recipient" => "RCP_2tn9clt23s7qr28"
95+
"reference" => "ACV_2627bbfe-1a2a-4a1a-8d0e-9d2ee6c31496",
96+
"reason" => "Bonus for the week",
97+
"recipient" => "RCP_gd9vgag7n5lr5ix"
9698
],
9799
[
98-
"amount" => 30000,
99-
"reference" => "YunoTReF35e0r4J",
100-
"reason" => "Because I can",
101-
"recipient" => "RCP_1a25w1h3n0xctjg"
100+
"amount" => 35000,
101+
"reference" => "ACV_1bd0c1f8-78c2-463b-8bd4-ed9eeb36be50",
102+
"reason" => "Bonus for the week",
103+
"recipient" => "RCP_zpk2tgagu6lgb4g"
102104
],
103105
[
104-
"amount" => 40000,
105-
"reason" => "Coming right up",
106-
"recipient" => "RCP_aps2aibr69caua7"
106+
"amount" => 15000,
107+
"reference" => "ACV_11bebfc3-18b3-40aa-a4df-c55068c93457",
108+
"reason" => "Bonus for the week",
109+
"recipient" => "RCP_dfznnod8rwxlwgn"
107110
]]
108111
];
109112

dist/api/transfers/bulk/response.json

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,46 @@
22
"200": {
33
"description": "200 Ok",
44
"data": {
5-
"status": true,
6-
"message": "3 transfers queued.",
7-
"data": [
8-
{
9-
"reference": "588YtfftReF355894J",
10-
"recipient": "RCP_2tn9clt23s7qr28",
11-
"amount": 20000,
12-
"transfer_code": "TRF_ful4rvpbiuaph4fo",
13-
"currency": "NGN",
14-
"status": "received"
15-
},
16-
{
17-
"reference": "YunoTReF35e0r4J",
18-
"recipient": "RCP_1a25w1h3n0xctjg",
19-
"amount": 30000,
20-
"transfer_code": "TRF_0lztrf3rox1rpbw1",
21-
"currency": "NGN",
22-
"status": "received"
23-
},
24-
{
25-
"reference": "nm7kjk9gb-l5i4lr9wq3",
26-
"recipient": "RCP_aps2aibr69caua7",
27-
"amount": 40000,
28-
"transfer_code": "TRF_hsk59k6loek7vlut",
29-
"currency": "NGN",
30-
"status": "received"
31-
}
32-
]
33-
}
5+
"status": true,
6+
"message": "3 transfers queued.",
7+
"data": [
8+
{
9+
"reference": "ACV_2627bbfe-1a2a-4a1a-8d0e-9d2ee6c31496",
10+
"recipient": "RCP_gd9vgag7n5lr5ix",
11+
"amount": 20000,
12+
"transfer_code": "TRF_o0mv5dc2lv4t2wdb",
13+
"currency": "NGN",
14+
"status": "success"
15+
},
16+
{
17+
"reference": "ACV_1bd0c1f8-78c2-463b-8bd4-ed9eeb36be50",
18+
"recipient": "RCP_zpk2tgagu6lgb4g",
19+
"amount": 35000,
20+
"transfer_code": "TRF_tlvxomz43gjso2py",
21+
"currency": "NGN",
22+
"status": "success"
23+
},
24+
{
25+
"reference": "ACV_11bebfc3-18b3-40aa-a4df-c55068c93457",
26+
"recipient": "RCP_dfznnod8rwxlwgn",
27+
"amount": 15000,
28+
"transfer_code": "TRF_yt2y2gcd3dmli8av",
29+
"currency": "NGN",
30+
"status": "success"
31+
}
32+
]
33+
}
3434
},
3535
"404": {
3636
"description": "404 Not Found",
3737
"data": {
38-
"status": false,
39-
"message": "The customer specified has no saved authorizations"
40-
}
38+
"status": false,
39+
"message": "Duplicate reference(s) found: ACV_11bebfc3-18b3-40aa-a4df-c55068c93457,ACV_1bd0c1f8-78c2-463b-8bd4-ed9eeb36be50,ACV_2627bbfe-1a2a-4a1a-8d0e-9d2ee6c31496",
40+
"meta": {
41+
"nextStep": "Try again later"
42+
},
43+
"type": "api_error",
44+
"code": "unknown"
45+
}
4146
}
4247
}

dist/api/transfers/initiate/requests.js

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,23 @@ url="https://api.paystack.co/transfer"
33
authorization="Authorization: Bearer YOUR_SECRET_KEY"
44
content_type="Content-Type: application/json"
55
data='{
6-
"source": "balance",
7-
"reason": "Calm down",
8-
"amount":3794800,
9-
"recipient": "RCP_gx2wn530m0i3w3m"
6+
"source": "balance",
7+
"reason": "Bonus for the week",
8+
"amount": 100000,
9+
"recipient": "RCP_gd9vgag7n5lr5ix",
10+
"reference": "ACV_9ee55786-2323-4760-98e2-6380c9cb3f68"
1011
}'
1112
1213
curl "$url" -H "$authorization" -H "$content_type" -d "$data" -X POST`
1314

1415
const js = `const https = require('https')
1516
1617
const params = JSON.stringify({
17-
"source": "balance",
18-
"reason": "Calm down",
19-
"amount":3794800,
20-
"recipient": "RCP_gx2wn530m0i3w3m"
18+
"source": "balance",
19+
"reason": "Bonus for the week",
20+
"amount": 100000,
21+
"recipient": "RCP_gd9vgag7n5lr5ix",
22+
"reference": "ACV_9ee55786-2323-4760-98e2-6380c9cb3f68"
2123
})
2224
2325
const options = {
@@ -49,35 +51,36 @@ req.write(params)
4951
req.end()`
5052

5153
const php = `<?php
52-
$url = "https://api.paystack.co/transfer";
53-
54-
$fields = [
55-
"source" => "balance",
56-
"reason" => "Calm down",
57-
"amount" => 3794800,
58-
"recipient" => "RCP_gx2wn530m0i3w3m"
59-
];
60-
61-
$fields_string = http_build_query($fields);
62-
63-
//open connection
64-
$ch = curl_init();
65-
66-
//set the url, number of POST vars, POST data
67-
curl_setopt($ch,CURLOPT_URL, $url);
68-
curl_setopt($ch,CURLOPT_POST, true);
69-
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
70-
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
71-
"Authorization: Bearer SECRET_KEY",
72-
"Cache-Control: no-cache",
73-
));
74-
75-
//So that curl_exec returns the contents of the cURL; rather than echoing it
76-
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
77-
78-
//execute post
79-
$result = curl_exec($ch);
80-
echo $result;
54+
$url = "https://api.paystack.co/transfer";
55+
56+
$fields = [
57+
"source" => "balance",
58+
"reason" => "Bonus for the week",
59+
"amount" => 100000,
60+
"recipient" => "RCP_gd9vgag7n5lr5ix",
61+
"reference" => "ACV_9ee55786-2323-4760-98e2-6380c9cb3f68"
62+
];
63+
64+
$fields_string = http_build_query($fields);
65+
66+
//open connection
67+
$ch = curl_init();
68+
69+
//set the url, number of POST vars, POST data
70+
curl_setopt($ch, CURLOPT_URL, $url);
71+
curl_setopt($ch, CURLOPT_POST, true);
72+
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
73+
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
74+
"Authorization: Bearer SECRET_KEY",
75+
"Cache-Control: no-cache",
76+
));
77+
78+
//So that curl_exec returns the contents of the cURL; rather than echoing it
79+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
80+
81+
//execute post
82+
$result = curl_exec($ch);
83+
echo $result;
8184
?>`
8285

8386
export {sh, js, php}
Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,43 @@
11
{
2-
"200": {
3-
"description": "200 Ok",
4-
"data": {
5-
"status": true,
6-
"message": "Transfer requires OTP to continue",
7-
"data": {
8-
"integration": 100073,
9-
"domain": "test",
10-
"amount": 3794800,
11-
"currency": "NGN",
12-
"source": "balance",
13-
"reason": "Calm down",
14-
"recipient": 28,
15-
"status": "otp",
16-
"transfer_code": "TRF_1ptvuv321ahaa7q",
17-
"id": 14,
18-
"createdAt": "2017-02-03T17:21:54.508Z",
19-
"updatedAt": "2017-02-03T17:21:54.508Z"
20-
}
21-
}
22-
},
23-
"404": {
24-
"description": "404 Not Found",
25-
"data": {
26-
"status": false,
27-
"message": "The customer specified has no saved authorizations"
28-
}
29-
}
30-
}
2+
"200": {
3+
"description": "200 Ok",
4+
"data": {
5+
"status": true,
6+
"message": "Transfer has been queued",
7+
"data": {
8+
"transfersessionid": [],
9+
"transfertrials": [],
10+
"domain": "test",
11+
"amount": 100000,
12+
"currency": "NGN",
13+
"reference": "ACV_9ee55786-2323-4760-98e2-6380c9cb3f68",
14+
"source": "balance",
15+
"source_details": null,
16+
"reason": "Bonus for the week",
17+
"status": "success",
18+
"failures": null,
19+
"transfer_code": "TRF_v5tip3zx8nna9o78",
20+
"titan_code": null,
21+
"transferred_at": null,
22+
"id": 860703114,
23+
"integration": 463433,
24+
"request": 1068439313,
25+
"recipient": 56824902,
26+
"createdAt": "2025-08-04T10:32:40.000Z",
27+
"updatedAt": "2025-08-04T10:32:40.000Z"
28+
}
29+
}
30+
},
31+
"400": {
32+
"description": "400 Bad Request",
33+
"data": {
34+
"status": false,
35+
"message": "Recipient specified is invalid",
36+
"meta": {
37+
"nextStep": "Provide a valid recipient. Ensure you are passing the recipient code in the recipient param"
38+
},
39+
"type": "validation_error",
40+
"code": "invalid_transfer_recipient"
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)