This laravel package will help you utilize the Quickpay API Client, without knowing too much about the endpoints. It provides a fluent api for using the API. See examples below.
Consider supporting me by sponsoring my work
- You can install the package via composer:
composer require netbums/laravel-quickpay
- Publish the config file with:
php artisan vendor:publish
Search for "quickpay", and publish both the config and Netbums\Quickpay\QuickpayServiceProvider
This is the contents of the published config file:
// config/quickpay.php
return [
'api_key' => env('QUICKPAY_API_KEY'),
'login' => env('QUICKPAY_LOGIN'),
'password' => env('QUICKPAY_PASSWORD'),
'merchant_id' => env('QUICKPAY_MERCHANT_ID'),
];
- Add the environment variables to your
.env
file:
QUICKPAY_API_KEY=
And alternatively, you can add the following environment variables to your .env
file instead of the QUICKPAY_API_KEY
:
QUICKPAY_LOGIN=
QUICKPAY_PASSWORD=
QUICKPAY_MERCHANT_ID=
use \Netbums\Quickpay\Facades\Quickpay;
$payments = Quickpay::payments()->all();
Getting a single payment by id
use \Netbums\Quickpay\Facades\Quickpay;
$payment = Quickpay::payments()->find($paymentId);
First create a basket with items, and then create a payment with the basket and a unique order id.
use \Netbums\Quickpay\DataObjects\Basket;
use \Netbums\Quickpay\DataObjects\BasketItem;
use \Netbums\Quickpay\DataObjects\Payment;
use \Netbums\Quickpay\Facades\Quickpay;
$basket = new Basket(
items: [
new BasketItem(
qty: 1,
item_name: 'Test item',
item_no: 'sku-1234',
item_price: 100, // in smallest currency unit
vat_rate: 0.25, // 25%
)
]
);
$paymentData = new Payment(
currency: 'DKK',
order_id: '1234',
basket: $basket,
);
$createdPayment = Quickpay::payments()->create(
payment: $paymentData
);
After a payment is created you can create a payment link for it, and redirect the user to the payment link.
use \Netbums\Quickpay\Facades\Quickpay;
use \Netbums\Quickpay\DataObjects\PaymentLink;
$paymentLinkData = new PaymentLink(
id: $createdPayment['id'],
amount: 100
);
$paymentLink = Quickpay::payments()->createLink($paymentLinkData);
This will return a URL, that you can redirect the user to.
Capture a payment. This will capture the amount of the payment specified.
use \Netbums\Quickpay\Facades\Quickpay;
$payment = Quickpay::payments()->capture(
id: $paymentId,
amount: 100, // in smallest currency unit
);
Refund a payment. This will refund the amount of the payment specified.
use \Netbums\Quickpay\Facades\Quickpay;
$payment = Quickpay::payments()->refund(
id: $paymentId,
amount: 100, // in smallest currency unit
);
Authorize a payment. This will reserve the amount on the card, but not capture it.
use \Netbums\Quickpay\Facades\Quickpay;
$payment = Quickpay::payments()->authorize(
id: $paymentId,
amount: 100, // in smallest currency unit
);
Renew the authorization of a payment. This will reserve the amount on the card, but not capture it.
use \Netbums\Quickpay\Facades\Quickpay;
$payment = Quickpay::payments()->renew(
id: $paymentId,
);
Cancel a payment. This will cancel the payment, and release the reserved amount on the card.
use \Netbums\Quickpay\Facades\Quickpay;
$payment = Quickpay::payments()->cancel(
id: $paymentId,
);
Create a payment link for a payment. Optional parameters are: language
, continue_url
, cancel_url
, callback_url
:
use \Netbums\Quickpay\Facades\Quickpay;
use \Netbums\Quickpay\DataObjects\PaymentLink;
$paymentLinkData = new PaymentLink(
id: $paymentId,
amount: 100, // in smallest currency unit
language: 'da',
continue_url: 'https://example.com/continue',
cancel_url: 'https://example.com/cancel',
callback_url: 'https://example.com/callback',
);
$paymentLink = Quickpay::payments()->createPaymentLink(
paymentLink: $paymentLinkData,
);
use \Netbums\Quickpay\Facades\Quickpay;
$session = Quickpay::payments()->session(
id: $paymentId,
amount: 100, // in smallest currency unit
);
Create a fraud report for a payment. Optional parameters are: description
:
use \Netbums\Quickpay\Facades\Quickpay;
$fraudReport = Quickpay::payments()->createFraudReport(
id: $paymentId,
description: 'Fraudulent payment',
);
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.