PHP code example of kamalsroor / moyasarapi

1. Go to this page and download the library: Download kamalsroor/moyasarapi 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/ */

    

kamalsroor / moyasarapi example snippets


         kamalsroor\MoyasarApi\MoyasarProvider::class,
 
        'Moyasar'   => kamalsroor\MoyasarApi\MoyasarFaced::class,
 
return [
	 'Test_Secret_Key'=>'Add Your Secret Key  Here :)',
	 'Test_Publishable_Key'=>'Add Your Test Publishable Key Here',

	 'Live_Secret_Key'=>'Add Your Live Secret Key Here',
	 'Live_Publishable_Key'=>'Add Your Live Publishable Key Here ',
];

 
Moyasar::setApiKey(config('moyasar.Test_Secret_Key'));
 
Moyasar::InvCreate('10000','pay me');

Moyasar::InvFetch("your id invoice ");
// this method get array like this if success paid https://moyasar.com/docs/api/?php#payments
// https://moyasar.com/docs/api/?php#invoices
// if can be the payments array not empty and source .. check message key is successed to check invoice paid or not 
 
// const class type
/*
Moyasar::CREDIT_CARD
Moyasar::CURRENCY
Moyasar::DESCRIPTION
Moyasar::SOURCE
Moyasar::SADAD
Moyasar::AMOUNT

*/
$card = [
 	    "type" => Moyasar::CREDIT_CARD,
	    "name" => "Abdulaziz Nasser",
	    "number" => "4111111111111111",
	    "cvc" => 331,
	    "month" => 12,
	    "year" => 2017
 	 	];
    //                        price   cardinfo  description   currency    
 	 return Moyasar::PayCreate("10000"  ,$card,  "bag payment", "SAR");
   // check status array to successed

// get all invoices paid 
return Moyasar::PayAll();

 
// Client Class By Moyasar
kamalsroor\MoyasarApi\MoyasarFaced\Moyasar\Client
// Invoice Class By Moyasar
kamalsroor\MoyasarApi\MoyasarFaced\Moyasar\Invoice
// Payment Class By Moyasar
kamalsroor\MoyasarApi\MoyasarFaced\Moyasar\Payment
// HttpRequestNotFound Class By Moyasar
kamalsroor\MoyasarApi\MoyasarFaced\Moyasar\HttpRequestNotFound
// ============ OR You Can Add In aliases Array =============== //
'Client'             =>kamalsroor\MoyasarApi\MoyasarFaced\Moyasar\Client::class,
'Invoice'            =>kamalsroor\MoyasarApi\MoyasarFaced\Moyasar\Invoice::class,
'Payment'            =>kamalsroor\MoyasarApi\MoyasarFaced\Moyasar\Payment::class,
'HttpRequestNotFound'=>kamalsroor\MoyasarApi\MoyasarFaced\Moyasar\HttpRequestNotFound::class,
 config/app.php 
app.php
 
php artisan vendor:publish