1. Go to this page and download the library: Download kwhorne/wirement-vipps 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/ */
kwhorne / wirement-vipps example snippets
use Wirement\Vipps\Services\PaymentService;
// Create a payment using the service
$paymentService = new PaymentService();
$paymentUrl = $paymentService->generatePaymentLink(
10000, // Amount in øre (100 NOK)
'order-123' // Invoice/Order number
);
// Redirect user to payment URL
return redirect()->to($paymentUrl);
use Wirement\Vipps\Services\PaymentService;
$orderlines = [
[
'id' => '1',
'name' => 'Product name',
'quantity' => 1,
'price' => 100, // Price in NOK
'vat' => 0.25, // 25% VAT
],
];
$paymentService = new PaymentService();
$paymentUrl = $paymentService->generatePaymentLink(
10000, // Amount in øre
'order-123', // Invoice number
$orderlines // Optional order lines
);
use Livewire\Component;
use Wirement\Vipps\Services\PaymentService;
class PaymentComponent extends Component
{
public function createPayment()
{
$paymentService = new PaymentService();
$paymentUrl = $paymentService->generatePaymentLink(
5000, // 50 NOK in øre
'order-' . time() // Invoice number
);
return redirect()->to($paymentUrl);
}
}
use Filament\Resources\Resource;
use Wirement\Vipps\Services\PaymentService;
// In your Filament resource
Tables\Actions\Action::make('create_payment')
->label('Create Vipps Payment')
->action(function ($record) {
$paymentService = new PaymentService();
$paymentUrl = $paymentService->generatePaymentLink(
$record->total * 100, // Convert to øre
(string) $record->id // Invoice number
);
$record->update(['vipps_url' => $paymentUrl]);
})