Git Product home page Git Product logo

php-vipps's Introduction

VIPPS by DNB

Packagist Packagist Coveralls Travis

Vipps is a Norwegian payment application designed for smartphones developed by DNB. Vipps was released May 30, 2015 and by reaching 1 million users November 5, 2015 - Vipps is Norways largest payment application. Although Vipps is developed by DNB it is an application open for customers from any Norwegian bank and 40% of the users are non-dnb customers.

source: Wikipedia

Prerequisities

In order to use VIPPS API you must apply for access to test environment. VIPPS expects you to deliver CSR file - Certificate Signing Request - (you can read more about the procedure on API documentation pages) and they will provide back signed certificate for merchant. Procedure usually takes 5-7 days. It is necessary to have signed certificate in order to access API (get through DNB firewalls).

Next step is to generate .pem certificate which consists of .crt file delivered by DNB PKI Team and private .key file you have generated along with CSR request file:

$ cat ./vipps.crt ./vipps.key > ./vipps.pem

That's it. Add .pem cert to each request you make against VIPPS servers.

Quick start

Add VIPPS to your project with Composer.

$ composer require zaporylie/vipps:^0.4

Create payment

$httpClient = new Http\Adapter\Guzzle6\Client(new \GuzzleHttp\Client([
    // Add certificate.
    'cert' => $settings['cert'],
]));
$vipps = new \Vipps\Vipps($httpClient);
// Set Vipps client.
$vipps->setMerchantID($merchant_id)->setMerchantSerialNumber($merchant_serial_number)->setToken($merchant_token);
// Get payment resource.
$payment = $vipps->payments();
// Set Order ID.
$payment->setOrderID($unique_order_id);
// Get transaction status.
$payment->create($phone_number, $amount_in_ore, $callback);

In case of any error ::create() method will throw an exception.

Get payment details

$httpClient = new Http\Adapter\Guzzle6\Client(new \GuzzleHttp\Client([
    // Add certificate.
    'cert' => $settings['cert'],
]));
$vipps = new \Vipps\Vipps($httpClient);
// Set Vipps client.
$vipps->setMerchantID($merchant_id)->setMerchantSerialNumber($merchant_serial_number)->setToken($merchant_token);
// Get payment resource.
$payment = $vipps->payments();
// Set Order ID.
$payment->setOrderID($unique_order_id);
// Get transaction current status.
$status = $payment->getStatus();
// Get transaction details including capture/refund history.
$details = $payment->getDetails();

Using production server

$httpClient = new Http\Adapter\Guzzle6\Client(new \GuzzleHttp\Client([
    // Add certificate.
    'cert' => $settings['cert'],
]));
$vipps = new \Vipps\Vipps($httpClient, new \Vipps\Connection\Live());

Troubleshooting

Some OSX users may experience problem with .pem files (internal OSX issue). If you're having troubles with pem files you can try generate .p12 file instead:

$ openssl pkcs12 -export -in ./vipps.crt -inkey ./vipps.pem -out ./vipps.p12
// System will ask for custom password for the file.

source

Next create Guzzle client and add certificate:

$httpClient = new Http\Adapter\Guzzle6\Client(new \GuzzleHttp\Client([
    // Add certificate.
    'cert' => [
      __DIR__ . '/vipps.p12', // Path to .p12 file.
      'password', // Pasword to .p12 file
    ]
]));

From now you can use client as usual.

Stability

zaporylie/vipps package has pre-releases only as VIPPS API development has not been finalized just yet. As soon as DNB decide to release stable version of their API this package will get its first stable release too.

References

Author

php-vipps's People

Contributors

zaporylie avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.