1. Go to this page and download the library: Download vandarpay/cashier 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/ */
use Vandar\Cashier\Models\Payment;
Route::get('/initiate-payment', function(Request $request) {
// Amounts are in IRR
// For more values, see Payment or https://vandarpay.github.io/docs/ipg/#step-1
$payment = Payment::create(['amount' => 10000]);
return redirect($payment->url);
});
Route::get('/initiate-payment', function(Request $request){
$user = auth()->user(); // Added as a separate variable for clarity
// Amounts are in IRR
// For more values, see Payment or https://vandarpay.github.io/docs/ipg/#step-1
$payment = $user->payments()->create(['amount' => 10000]);
return redirect($payment->url); // See documentation for info on payload and callback
});
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddMobileNumbersColumnToUsersTable extends Migration
{
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->string('mobile_number')->nullable();
});
}
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('mobile_number');
});
}
}
Route::get('/initiate-mandate', function(){
$user = auth()->user();
if(! $user->hasValidMandate()){ // You may use the hasValidMandate method if your design
$status = $withdrawal->cancel(); // Returns 'CANCELED' on success, any other status (DONE, PENDING, INIT, FAILED) on failure.
$settlement = Settlement::create(['amount' => 5000, 'iban' => 'IR000000000000000000000000']) // amount is in Toman
$settlement->cancel(); // Returns `CANCELED` on success.
try {
...
} catch (\Vandar\Cashier\Exceptions\ResponseException $exception) {
dump($exception->context()) // Dumps all the information passed into Guzzle, including headers and configuration
dump($exception->getUrl()) // Dumps the url the request was sent to
dump($exception->getPayload()) // Dumps the payload that was sent to Vandar APIs
dump($exception->getResponse()) // Dumps the response object returned by Guzzle
dump($exception->getResponse()->json()) // Returns an associative array of json response.
dump($exception->errors()) // Useful especially in InvalidPayloadException, returns the "errors" key in the json response
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.