1. Go to this page and download the library: Download netipar/simplepay 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/ */
netipar / simplepay example snippets
use Netipar\SimplePay\Facades\SimplePay;
use Netipar\SimplePay\Enums\Currency;
use Netipar\SimplePay\Enums\PaymentMethod;
use Netipar\SimplePay\Dto\PaymentRequest;
use Netipar\SimplePay\Dto\Address;
$response = SimplePay::payment()->start(new PaymentRequest(
currency: Currency::HUF,
total: 2500,
orderRef: 'ORDER-123',
customerEmail: '[email protected]',
language: 'HU',
url: route('simplepay.back'),
methods: [PaymentMethod::CARD],
invoice: new Address(
name: 'John Doe',
country: 'hu',
city: 'Budapest',
zip: '1111',
address: 'Main Street 1',
),
));
return redirect($response->paymentUrl);
// In EventServiceProvider or via Event::listen()
use Netipar\SimplePay\Events\PaymentSucceeded;
use Netipar\SimplePay\Events\PaymentFailed;
protected $listen = [
PaymentSucceeded::class => [HandlePaymentSuccess::class],
PaymentFailed::class => [HandlePaymentFailure::class],
];
$event->ipnMessage->orderRef; // Your order reference
$event->ipnMessage->transactionId; // SimplePay transaction ID
$event->ipnMessage->status; // PaymentStatus enum
$event->ipnMessage->paymentMethod; // PaymentMethod enum
$event->ipnMessage->cardMask; // Masked card number
use Netipar\SimplePay\Contracts\BackUrlResponse;
use App\Http\Responses\SimplePayBackResponse;
// AppServiceProvider::register()
$this->app->singleton(BackUrlResponse::class, SimplePayBackResponse::class);
use Netipar\SimplePay\Contracts\BackUrlResponse;
use Netipar\SimplePay\Dto\BackResponse;
use Netipar\SimplePay\Enums\BackEvent;
class SimplePayBackResponse implements BackUrlResponse
{
public function toResponse(Request $request, BackResponse $back): Response
{
return match ($back->event) {
BackEvent::Success => redirect()->route('payment.success', $back->orderRef),
BackEvent::Fail => redirect()->route('payment.failed'),
BackEvent::Cancel => redirect()->route('checkout'),
BackEvent::Timeout => redirect()->route('payment.timeout'),
};
}
}