PHP code example of xplicit-dev / mamopay

1. Go to this page and download the library: Download xplicit-dev/mamopay library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xplicit-dev / mamopay example snippets


use MamoPay\Api\MamoClient;


$client = (new MamoClient('API_KEY'));

$client = (new MamoClient('API_KEY',true));

// $client->class()->function() to access the API

//Example

$client->links()->get($linkId);

use MamoPay\Api\MamoClient;

$client = (new MamoClient('API_KEY'));
$params = ['card_id' => $card_id, 'amount' => $amount, 'currency' => $currency];
$response = $client->httpClient->sendRequest('end_point',$params,HttpClient::METHOD_POST);

$params = ['is_widget' => true , 'save_card'=>true];

$response = $client->links()->create($title,$amount,$returnUrl,$params);

$id = $response->id;

$payment_url = $response->payment_url;

$client->links()->all();

$client->links()->update($linkID,$params);

$client->links()->delete($linkID);

$client->links()->get($linkID);

$charge = $client->transaction()->create($card_id,$amount);

$chargeID = $charge->id;

$client->transaction()->get($chargeID);

$client->transaction()->all();

$client->transaction()->refund($chargeId,$amount);

$client->subscription()->all($subscriptionId);

$client->subscription()->get($subscriptionId);

$client->subscription()->unSubscribe($subscriptionId,$subscriberId);

$client->subscription()->cancelRecurring($subscriptionId);

$client->payout()->all();

$client->payout()->issue($account_no, $amount, $first_name, $last_name = '', $reason = '', $transfer_method = 'BANK_ACCOUNT');


use MamoPay\Api\Objects\Disbursement;

$client = (new MamoClient());

$disbursement[0] = (new Disbursement())->set([
'account' => 'AE080200000123223333121',
'amount' => 10,
'first_name_or_business_name' => 'John',
'last_name' => 'Doe',
]);

$disbursement[1] = (new Disbursement())->set([
'account' => 'AE080200000123223333121',
'amount' => 20.5,
'first_name_or_business_name' => 'John',
'last_name' => 'Doe',
'reason' => 'refund for lorem ipsum',
]);

$disbursements = $client->payout()->issueMultiple($disbursement);

$client->webhook()->create($uri,$events,'authentication header');

use MamoPay\Api\Events\WebhookEvent;



$response = $client->webhook()->create("http://example.com",WebhookEvent::ALL_EVENT_TYPES,'authentication header');

$response = $client->webhook()->create("http://example.com",[WebhookEvent::CHARGE_CARD_VERIFIED,WebhookEvent::CHARGE_SUCCEEDED]);

$webhookId = $response->id;

$client->webhook()->all();

$client->webhook()->update($webhookId,"http://example.com",WebhookEvent::ALL_EVENT_TYPES,'authentication header');

$client->webhook()->delete($webhookId);

$client->recipient()->all();

$recipient = (new RecipientInfo())->set([
    'recipient_type' => RecipientInfo::RECIPIENT_TYPE_INDIVIDUAL,
    'first_name' => 'John',
    'last_name' => 'Doe',
    'email' => '[email protected]',
    'relationship' => RecipientInfo::RELATIONSHIP_CUSTOMER,
    'reason' => 'Payment for services',
    'eid_number' => '784-XXXX-XXXXXXX-0',
    'address' => (new Address())->set([
        'address_line1' => '123 Main Street',
        'address_line2' => 'Apt 4B',
        'city' => 'Dubai',
        'state' => 'AE',
        'country' => 'AE'
    ]),
    'bank' => (new Bank())->set([
        'iban' => 'AE080200000123223333121',
        'account_number' => '123223333121',
        'name' => 'ABC Bank',
        'bic_code' => 'ABCDUAE123',
        'address' => 'XYZ Bank Tower, Dubai',
        'country' => 'AE'
    ])
]);

$client->recipient()->create($recipient)

this will return a \MamoPay\Api\Objects\RecipientInfo object

$recipient = (new RecipientInfo())->set([
    'recipient_type' => RecipientInfo::RECIPIENT_TYPE_INDIVIDUAL,
    'first_name' => 'John',
    'last_name' => 'Doe',
    'email' => '[email protected]',
    'relationship' => RecipientInfo::RELATIONSHIP_CUSTOMER,
    'reason' => 'Payment for services',
    'eid_number' => '784-XXXX-XXXXXXX-0',
    'address' => (new Address())->set([
        'address_line1' => '123 Main Street',
        'address_line2' => 'Apt 4B',
        'city' => 'Dubai',
        'state' => 'AE',
        'country' => 'AE'
    ]),
    'bank' => (new Bank())->set([
        'iban' => 'AE080200000123223333121',
        'account_number' => '123223333121',
        'name' => 'ABC Bank',
        'bic_code' => 'ABCDUAE123',
        'address' => 'XYZ Bank Tower, Dubai',
        'country' => 'AE'
    ])
]);

$client->recipient()->update($recipientID,$recipient);

this will return a \MamoPay\Api\Objects\RecipientInfo object

recipientID is the recipient identifier returned when creating a recipient.


$client->recipient()->get($recipientID)


$client->recipient()->delete($recipientID);

 $client->card()->create(float $amount, string $email, string $booking_id='', string $verification_email = '', array $params = []);