Download the PHP package dizatech/zarinpal_ipg without Composer
On this page you can find all versions of the php package dizatech/zarinpal_ipg. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dizatech/zarinpal_ipg
More information about dizatech/zarinpal_ipg
Files in dizatech/zarinpal_ipg
Package zarinpal_ipg
Short Description A package for integrating Zarinpal payment gateway into web applications
License GPL-3.0-or-later
Informations about the package zarinpal_ipg
Payment Cycle
For a payment transaction we have to request a payment via web service. If our request is successful the IPG will return a token which we should use while redirecting customer to payment page. Customer will be redirected back to our desired URL(callback URL) from payment page via a GET request carrying data which may be used to check and verify customer's transaction using web service.
Request payment
For a payment transaction we should send a payment request to IPG and acquire a token. This may be accomplished by calling getToken method.
Instantiating an IPG object
for instantiating an IPG object we should call Dizatech\ZarinpalIpg\ZarinpalIpg constructor passing it an array of required arguments containing:
- merchantId: your payment gateway merchant id
Code sample:
getToken method
Arguments:
- amount: amount in Rials
- description: text to describe order/payment
- redirect_address: URL to which customer may be redirected after payment
Returns:
An object with the following properties:
- status:
successorerror - token: in case of a successful request contains the generated token which may be used while redirecting customer to payment page
- message: contains error message when
statusiserrorRedirecting customer to payment page
If
statusproperty of the result of callinggetTokenissuccesswe can redirect customer to payment page URL which is currentlyhttps://www.zarinpal.com/pg/StartPay. We have to redirect user to payment page via a GET request.
It is neccessary to save the acquired token token for further use
Code sample:
Payment verification and settle
After payment the customer will be redirected back to the callback URL provided in payment request phase via a GET request carrying all necessary data including:
- Authority: Payment token by which the user has been redirected to payment page
- Status: Payment status which should be
OKfor successful payments
If Status equals OK we can call the verifyRequest method to verify payment.
verifyRequest method
Arguments:
- amount: Original order amoun tused in payment request
- token: Authority parameter returned by IPG
Returns:
An object with the following properties:
- status:
successorerror - message: message describing the status
- ref_id: reference id in case of successful transaction
Code sample:
Getting success status in response means that the transction is successful and settled.