PHP code example of dark4ce / mobilpay

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

    

dark4ce / mobilpay example snippets


...
Adrianbarbos\Mobilpay\MobilpayServiceProvider::class,
...

...
'Omnipay' => Omnipay\Omnipay::class,
'Mobilpay'	=> Adrianbarbos\Mobilpay\Mobilpay::class,
...

// controller function

Mobilpay::setOrderId(1)
        ->setAmount('10.00')
        ->setDetails('Some details')
        ->purchase();

// controller function

$response = Mobilpay::response();

$data = $response->getData(); //array

switch($response->getMessage())
{
    case 'confirmed_pending': // transaction is pending review. After this is done, a new IPN request will be sent with either confirmation or cancellation

        //update DB, SET status = "pending"

        break;
    case 'paid_pending': // transaction is pending review. After this is done, a new IPN request will be sent with either confirmation or cancellation

        //update DB, SET status = "pending"

        break;
    case 'paid': // transaction is pending authorization. After this is done, a new IPN request will be sent with either confirmation or cancellation

        //update DB, SET status = "open/preauthorized"

        break;
    case 'confirmed': // transaction is finalized, the money have been captured from the customer's account

        //update DB, SET status = "confirmed/captured"

        break;
    case 'canceled': // transaction is canceled

        //update DB, SET status = "canceled"

        break;
    case 'credit': // transaction has been refunded

        //update DB, SET status = "refunded"

        break;
}	                

/**
 * @param $value string
 * @return $this
 */

public function setOrderId($value)

/**
 * @param $value string
 * @return $this
 */

public function setAmount($value)

/**
 * @param $value string
 * @return $this
 */

public function setCurrency($value)

/**
 * @param $value string
 * @return $this
 */

public function setDetails($value)

/**
 * @param $value string
 * @return $this
 */

public function setConfirmUrl($value)

/**
 * @param $value string
 * @return $this
 */

public function setReturnUrl($value)

/**
 * @param $value boolean
 * @return $this
 */

public function setTestMode($value)

/**
 * @param $value array
 * @return $this
 */

public function setAdditionalParams($value)

php artisan vendor:publish --provider="Adrianbarbos\Mobilpay\MobilpayServiceProvider"