PHP SDK
IntaSend Payment PHP SDK for Laravel and other framework

How to install and use IntaSend PHP SDK

1
composer require intasend/intasend-php
Copied!

How to use (Code examples)

Obtain your API token and Publishable key from your account i.e under Settings - API Keys panel.
1
# Remember to switch of test when going live by set it to False
2
3
# Wallets Management
4
use IntaSend\IntaSendPHP\Wallet;
5
6
$credentials = [
7
'token'=>'<YOUR-TOKEN-HERE>',
8
'publishable_key'=>'<YOUR-PUBLISHABLE_KEY-HERE>',
9
'private_key'=><<<EOD
10
<YOUR-PRIVATE_KEY>
11
EOD,
12
'test'=>true,
13
];
14
15
$wallet = new Wallet();
16
$wallet->init($credentials);
17
18
$response = $wallet->retrieve()
19
print_r(response);
20
21
$response = $wallet->details('<wallet_id>')
22
print_r(response);
23
24
$response = $wallet->transactions('<wallet_id>')
25
print_r(response);
26
27
$response = $wallet->create("<currency>")
28
print_r(response);
29
30
# Fund specific wallet
31
$response = $wallet->fund(<phone_number>, <email>, <amount>, <method>, <currency>, $api_ref>, <name>)
32
print_r(response);
33
34
# Wallet to wallet transfers
35
$response = $wallet->intra_transfer(<origin_wallet_id>, <destination_wallet_id>, <amount>, <narrative>)
36
print_r(response);
37
38
# Chargebacks Management
39
40
use IntaSend\IntaSendPHP\Chagebacks;
41
42
$credentials = [
43
'token'=>'<YOUR-TOKEN-HERE>',
44
'publishable_key'=>'<YOUR-PUBLISHABLE_KEY-HERE>',
45
'private_key'=><<<EOD
46
<YOUR-PRIVATE_KEY>
47
EOD,
48
'test'=>true,
49
];
50
$chagebacks = new Chagebacks();
51
$hagebacks->init($credentials);
52
53
$response = $chagebacks->retrieve()
54
print_r(response);
55
56
$response = $chagebacks->details(<chagebacks_id>)
57
print_r(response);
58
59
$response = $chagebacks->create(<invoice_id>, <amount>, <reason>);
60
print_r(response);
61
62
# Send money
63
64
use IntaSend\IntaSendPHP\Transfer;
65
66
$credentials = [
67
'token'=>'<YOUR-TOKEN-HERE>',
68
'publishable_key'=>'<YOUR-PUBLISHABLE_KEY-HERE>',
69
'private_key'=><<<EOD
70
<YOUR-PRIVATE_KEY>
71
EOD,
72
'test'=>true,
73
];
74
75
$transactions = [
76
['account'=>'254723890353','amount'=>'20'],
77
['account'=>'254723890260','amount'=>'15']
78
];
79
80
$transfer = new Transfer();
81
$transfer->init($credentials);
82
83
## device_id - Note device id is the PSD2 device id from the dashboard - https://developers.intasend.com/apis/extra-payment-authentication
84
$response=$transfer->mpesa('<DEVICE-ID>', "KES",$transactions);
85
//call approve() method for approving last transaction
86
$response = $transfer->approve($response);
87
print_r($response);
88
89
# Create payment link
90
use IntaSend\IntaSendPHP\PaymentLink;
91
92
$credentials=[
93
'token'=>'<YOUR-TOKEN-HERE>',
94
'publishable_key'=>'<YOUR-PUBLISHABLE_KEY-HERE>',
95
'private_key'=><<<EOD
96
<YOUR-PRIVATE_KEY>
97
EOD,
98
'test'=>true,
99
];
100
101
$paymentLink = new PaymentLink();
102
$paymentLink->init($credentials);
103
104
$response = $paymentLink->create(<title>, <currency>, <amount>,<mobile_tarrif>, <card_tarrif>, <is_active>);
105
print_r(response);
106
107
$response = $paymentLink->retrieve()
108
print_r(response);
109
110
$response = $paymentLink->details(<link_id>)
111
print_r(response);
112
113
# Payment Collection(M-Pesa)
114
use IntaSend\IntaSendPHP\Collection;
Copied!
Last modified 2d ago