1. Go to this page and download the library: Download mmockelyn/payment 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/ */
return
[
'form' =>
[
/*
* The class or classes that you want to put on the submit button
* of the payment form
*/
'submitButtonClass' => 'test'
],
'europabank' =>
[
'clientSecret' => getenv('EUROPABANK_CLIENT_SECRET'),
'serverSecret' => getenv('EUROPABANK_SERVER_SECRET'),
/*
* MPI Account number
*/
'uid' => getenv('EUROPABANK_UID'),
/*
* The url to where the payment will take place
*/
'mpiUrl' => '',
/*
* The name of the route where Europabank will redirect to
* after the payment has been made
*
*/
'paymentLandingPageRoute' => 'verifyPayment',
/*
* Optional url of the css which must be applied on the payment form
*/
'formCss'=> '',
/*
* Url of the template which will be applied on Europabank pages
*/
'template'=> '',
/*
* Optional title of the payment form
*/
'formTitle' => '',
/*
* Optional e-mail address of the merchant
*/
'merchantEmail' => '',
/*
* Optional e-mail address to use as sender for the second chance
* or payment link e-mail
*/
'secondChanceEmailSender' => '',
]
];
use Spatie\Payment\PaymentGateway;
class CheckoutConfirmOrderController extends BaseController {
/**
* @var PaymentGateway
*/
protected $paymentGateway;
public function __construct(.. PaymentGateway $paymentGateway ...)
{
...
$this->paymentGateway = $paymentGateway;
...
}
public function showOrderDetails()
{
$order = $this->orderRepo->getCurrentOrder();
$paymentGateway = $this->paymentGateway->setOrder($order);
return View::make('front.checkout.confirmOrder')->with(compact('order', 'paymentGateway'));
}
interface PayableOrder {
/**
* @return string
*/
public function getPaymentOrderId();
/**
* @return double
*/
public function getPaymentAmount();
/**
* @return string
*/
public function getPaymentDescription();
/**
* @return string
*/
public function getCustomerEmail();
/**
* @return string
*/
public function getCustomerLanguage();
}
....
use Spatie\Payment\PayableOrder;
class Order extends Eloquent implements PayableOrder
{
...
/**
* @return string
*/
public function getPaymentOrderId()
{
return $this->id;
}
/**
* Should be in eurocents for most payments providers
* @return double
*/
public function getPaymentAmount()
{
return $this->getTotal() * 100;
}
/**
* @return string
*/
public function getPaymentDescription()
{
return 'Order ' . $this->id;
}
/**
* @return string
*/
public function getCustomerEmail()
{
return $this->email;
}
/**
* @return string
*/
public function getCustomerLanguage()
{
return App::getLocale();
}
}
use Spatie\Payment\PaymentGateway;
class CheckoutPaymentVerificationController extends BaseController {
protected $paymentGateway;
public function __construct(PaymentGateway $paymentGateway)
{
$this->paymentGateway = $paymentGateway;
}
...
public function verifyPayment()
{
$this->paymentGateway->validateGatewayResponse(Checkout::getCurrentOrderId());
}
use Spatie\Payment\PaymentGateway;
class CheckoutPaymentVerificationController extends BaseController {
protected $paymentGateway;
public function __construct(PaymentGateway $paymentGateway)
{
$this->paymentGateway = $paymentGateway;
}
public function verifyPayment()
{
$this->paymentGateway->validateGatewayResponse(Checkout::getCurrentOrderId());
switch($this->paymentGateway->getPaymentResult())
{
case PaymentGateway::PAYMENT_RESULT_OK:
//take necessary actions to mark order as confirmed
break;
case PaymentGateway::PAYMENT_RESULT_CANCELLED_BY_CARDHOLDER:
//take necessary actions to mark order as failed
break;
case PaymentGateway::PAYMENT_RESULT_DECLINED:
//take necessary actions to mark order as failed
break;
case PaymentGateway::PAYMENT_RESULT_FAILED:
//take necessary actions to mark order as failed
break;
case PaymentGateway::PAYMENT_TIMED_OUT:
//take necessary actions to mark order as failed
break;
default:
throw new Exception('Unknown payment gateway answer');
break;
}
}
}
php artisan config:publish spatie/payment
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.