A class for easy connection to the zarinpal port

Overview

Payment class with ZarinPal

A class to simplify payment operations and confirm payment of ZarrinPal payment gateway service ( به فارسی بخوانید )

Installation and use

Installation with Composer

composer require mhmmdq/zarinpal 

Easily add a class to your project using the command above

use

First, call the composer autoloader and call the class

<?php

include 'vendor/autoload.php';
use Mhmmdq\Zarinpal\Zarinpal;

Build an object and enter the required values

$merchant You will receive a code from ZarinPal

$amount Amount to be paid

$callback_url The place to return after the operation

$description Payment description

$metadata Get a presentation of everything you need after a successful payment

<?php
include  'vendor/autoload.php';

use Mhmmdq\Zarinpal\Zarinpal;

$merchant = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
$amount = 200000;
$callback_url = 'https://zarinpal.mhmmdq.ir/verify.php';
$description = 'توضیحات پرداخت';
$metadata = ['name' => 'mhmmdq'];

$zarinpal = new Zarinpal($merchant , $amount , $callback_url , $description , $metadata);

    

And at the end of the transfer to the payment gateway with method PayMentPortal()

$zarinpal = new Zarinpal($merchant , $amount , $callback_url , $description , $metadata);
$zarinpal->PayMentPortal();

If you do not want the transfer to be done automatically by the class, do the following

$zarinpal = new Zarinpal($merchant , $amount , $callback_url , $description , $metadata);
$zarinpal->PayMentPortal(false);
Payment confirmation

To confirm the payment, just do the following and then you will have a presentation of the result

<?php

include  'vendor/autoload.php';

use Mhmmdq\Zarinpal\Zarinpal;

$zarinpal = new Zarinpal('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' , 200000);

var_dump($zarinpal->PayMentVerify());

If the payment is successful, there will be a key return in the array as status with the value of success

Errors

You will receive all the errors before and after the payment operation as an array and the key name will be errors

Sample payment script

I will give a complete example soon

You might also like...
uaDetect – A multi-language port of Browserscope's user agent parser

uaDetect is a lightweight for detecting mobile devices. It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.

An improved version of the PHP port of KuzuhaScript

KuzuhaScriptPHP+ (くずはすくりぷとPHP+) An improved version of the PHP port of KuzuhaScript (くずはすくりぷと). To my knowledge, it works with PHP version 4.1.0 and a

A PHP port of Ruby's Liquid Templates

Liquid template engine for PHP Liquid is a PHP port of the Liquid template engine for Ruby, which was written by Tobias Lutke. Although there are many

My solution use PHP with a class for easy setup

My solution use PHP with a class for easy setup. It accepts requests with the get method just passing the username and password as well as the ip and http port of the Proxmox server. Just needing a web server.

Optimizes class loading performance by generating a single PHP file containing all of the autoloaded files.
Optimizes class loading performance by generating a single PHP file containing all of the autoloaded files.

Class Preloader for PHP This tool is used to generate a single PHP script containing all of the classes required for a specific use case. Using a sing

FuelPHP Framework - Class and Namespace alias library

Fuel Alias Library for lazy class aliasing. Install Via Composer $ composer require fuelphp/alias Usage Within FuelPHP class aliases are used to provi

A class to help convert bytes into other units (kb, mb, etc).

A class to help convert bytes into other units (kb, mb, etc). This package can be used to convert int|float values from bytes to KB, MB and GB as well

A small package to add computed properties to any PHP class. 🐘

Computed Properties This package provides a trait and attribute that can provide computed property support. Installation This package can be installed

COP4331 Class Project 1 - "ConnectUs" virtual contact manager/Rolodex

ConnectUs COP4331 Class Project 1 - "ConnectUs" virtual contact manager/Rolodex Team Members Orion (Project Manager) Eric (Database) Rafael (API/Backe

Owner
Mohammad Qasemi
Web designer and developer
Mohammad Qasemi
Easy to use utility functions for everyday PHP projects. This is a port of the Lodash JS library to PHP

Lodash-PHP Lodash-PHP is a port of the Lodash JS library to PHP. It is a set of easy to use utility functions for everyday PHP projects. Lodash-PHP tr

Lodash PHP 474 Dec 31, 2022
Allows the connection of Minecraft: JE clients to PocketMine servers. Made for PM4

JavaPlayer Allows the connection of Minecraft: JE clients to PocketMine servers. Made for PM4 MCJE VER: 1.18.2 Need implemented Chunks (convert proble

kanison konkla 30 Dec 7, 2022
🔒 a simple login screen done in php with connection to mysql

login.php What is a login system? login (derived from the English log in) or logon or signin, is the process to access a restricted computer system ma

SEBASTIAN JN 3 Aug 21, 2022
Exploiting and fixing security vulnerabilities of an old version of E-Class. Project implemented as part of the class YS13 Cyber-Security.

Open eClass 2.3 Development of XSS, CSRF, SQLi, RFI attacks/defences of an older,vulnerable version of eclass. Project implemented as part of the clas

Aristi_Papastavrou 11 Apr 23, 2022
A redacted PHP port of Underscore.js with additional functions and goodies – Available for Composer and Laravel

Underscore.php The PHP manipulation toolbelt First off : Underscore.php is not a PHP port of Underscore.js (well ok I mean it was at first). It's does

Emma Fabre 1.1k Dec 11, 2022
Port of the Java Content Repository (JCR) to PHP.

PHP Content Repository PHPCR This repository contains interfaces for the PHPCR standard. The JSR-283 specification defines an API for a Content Reposi

PHPCR 436 Dec 30, 2022
A simple, type-safe, zero dependency port of the javascript fetch WebApi for PHP.

A simple, type-safe, zero dependency port of the javascript fetch WebApi for PHP.

Matias Navarro Carter 105 Jan 4, 2023
This is a port of the original WireGuard UI bits as implemented by Netgate in pfSense 2.5.0 to a package suitable for rapid iteration and more frequent updating on future releases of pfSense.

This is a port of the original WireGuard*** UI bits as implemented by Netgate in pfSense 2.5.0 to a package suitable for sideloading and more frequent updating on future releases of pfSense. This also includes some improvments such as a proper status page (found under Status / WireGuard Status) and improved assigned interface handling.

R. Christian McDonald 195 Dec 23, 2022
Back the fun of reading - PHP Port for Arc90′s Readability

PHP Readability Library If you want to use an up-to-date version of this algorithm,check this newer project: https://github.com/andreskrey/readability

明城 517 Nov 18, 2022