Skip to content

Latest commit

 

History

History
132 lines (98 loc) · 3.11 KB

File metadata and controls

132 lines (98 loc) · 3.11 KB
description IntaSend Payment PHP SDK for Laravel and other framework

PHP SDK

How to install and use IntaSend PHP SDK

composer require intasend/intasend-php

How to use (Code examples)

Obtain your API token and Publishable key from your account i.e under Settings - API Keys panel.

# Remember to switch of test when going live by set it to False

# Wallets Management
use IntaSend\IntaSendPHP\Wallet;

$credentials = [
    'token'=>'<YOUR-TOKEN-HERE>',
    'publishable_key'=>'<YOUR-PUBLISHABLE_KEY-HERE>',
    'private_key'=><<<EOD
    <YOUR-PRIVATE_KEY>
    EOD,
    'test'=>true,
];

$wallet = new Wallet();
$wallet->init($credentials);

$response = $wallet->retrieve()
print_r(response);

$response = $wallet->details('<wallet_id>')
print_r(response);

$response = $wallet->transactions('<wallet_id>')
print_r(response);

$response = $wallet->create("<currency>")
print_r(response);

# Fund specific wallet
$response = $wallet->fund(<phone_number>, <email>, <amount>, <method>, <currency>, $api_ref>, <name>)
print_r(response);

# Wallet to wallet transfers
$response = $wallet->intra_transfer(<origin_wallet_id>, <destination_wallet_id>, <amount>, <narrative>)
print_r(response);

# Chargebacks Management

use IntaSend\IntaSendPHP\Chagebacks;

$credentials = [
    'token'=>'<YOUR-TOKEN-HERE>',
    'publishable_key'=>'<YOUR-PUBLISHABLE_KEY-HERE>',
    'private_key'=><<<EOD
    <YOUR-PRIVATE_KEY>
    EOD,
    'test'=>true,
];
$chagebacks = new Chagebacks();
$hagebacks->init($credentials);

$response = $chagebacks->retrieve()
print_r(response);

$response = $chagebacks->details(<chagebacks_id>)
print_r(response);

$response = $chagebacks->create(<invoice_id>, <amount>, <reason>);
print_r(response);

# Send money

use IntaSend\IntaSendPHP\Transfer;

$credentials = [
    'token'=>'<YOUR-TOKEN-HERE>',
    'publishable_key'=>'<YOUR-PUBLISHABLE_KEY-HERE>',
    'private_key'=><<<EOD
    <YOUR-PRIVATE_KEY>
    EOD,
    'test'=>true,
];

$transactions = [
    ['account'=>'254723890353','amount'=>'20'],
    ['account'=>'254723890260','amount'=>'15']
];

$transfer = new Transfer();
$transfer->init($credentials);

## device_id - Note device id is the PSD2 device id from the dashboard - https://developers.intasend.com/apis/extra-payment-authentication
$response=$transfer->mpesa('<DEVICE-ID>', "KES",$transactions);
//call approve() method for approving last transaction
$response = $transfer->approve($response);
print_r($response);

# Create payment link
use IntaSend\IntaSendPHP\PaymentLink;

$credentials=[
    'token'=>'<YOUR-TOKEN-HERE>',
    'publishable_key'=>'<YOUR-PUBLISHABLE_KEY-HERE>',
    'private_key'=><<<EOD
    <YOUR-PRIVATE_KEY>
    EOD,
    'test'=>true,
];

$paymentLink = new PaymentLink();
$paymentLink->init($credentials);

$response = $paymentLink->create(<title>, <currency>, <amount>,<mobile_tarrif>, <card_tarrif>, <is_active>);
print_r(response);

$response = $paymentLink->retrieve()
print_r(response);

$response = $paymentLink->details(<link_id>)
print_r(response);

# Payment Collection(M-Pesa)
use IntaSend\IntaSendPHP\Collection;