PHP code example of apility / vipps

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

    

apility / vipps example snippets




use Vipps\Vipps;
use Vipps\Config;
use Vipps\Ecommerce\Payment;

// The given values are just for illustration
Vipps::setConfig(Config::create([
  'endpoint' => 'https://apitest.vipps.no',
  'clientId' => '12345678-1234-5678-1234-56781234',
  'clientSecret' => 'A1bcdEFGHijkL2MNOpQrsTUVW34=',
  'merchantSerialNumber' => 10000,
  'accessTokenSubscriptionKey' => '123456789abcdef123456789abcdef12',
  'ecommerceSubscriptionKey' => '123456789abcdef123456789abcdef12',
  'callbackPrefix' => 'https://domain.tld/callback',
  'fallBack' => 'https://domain.tld/fallback'
]));

$payment = Payment::create([
  'customerInfo' => [
    'mobileNumber' => '12345678'
  ],
  'transaction' => [
    'amount' => 1337 //1337.00 NOK,
    'transactionText' => 'Hello World!'
  ]
]);

$payment->charge();

header('Location: ' . $payment->url);
die();