-
Notifications
You must be signed in to change notification settings - Fork 17
Documentation 1.x
You must pass client_id obtained from Vipps Developer Portal in order to make requests to Vipps API.
// Create Vipps client;
$client = new \zaporylie\Vipps\Client('xxxx');
// Initiate Vipps App with a previously initiatet client;
$app = new \zaporylie\Vipps\Vipps($client);
Http client will be determined automatically, but if your application uses more than one client and you want to
choose which one will be used for Vipps calls you can pass instantiated adaptor object to \zaporylie\Vipps\Client
constructor.
// Initiate guzzle client in debug mode.
$httpClient = new Http\Adapter\Guzzle6\Client(new GuzzleHttp\Client(['debug' => TRUE]));
// Create Vipps client;
$client = new \zaporylie\Vipps\Client('xxxxxxxxxxxxxxxxxxxxxxxx', [
'http_client' => $httpClient,
]);
// Initiate Vipps App with a previously initiatet client;
$app = new \zaporylie\Vipps\Vipps($client);
In following examples $app
is an instance of \zaporylie\Vipps\Vipps
.
$auth = $app->authorization('<access_subscription_key>');
$auth->getToken('<client_secret>');
By default Token will be stored in-memory storage. You can modify default behaviour by providing custom TokenStorage which implements TokenStorageInterface
to \zaporylie\Vipps\Client()
.
// Get payment API - pass product's subcription key obtainted from Developer Portal.
// @see \zaporylie\Vipps\Vipps::payment()
$payment = $app->payment('<subscription_key>', '<merchant_serial_number>');
// Initiate new payment.
// @see \zaporylie\Vipps\Api\Payment::initiatePayment()
$payment_details = $payment->initiatePayment('<unique-order-id>', '<vipps-user-mobile-phone-number>', '<amount-in-ore>', '<payment-description>', '<callback-url>');
::initiatePayment()
method takes parameters:
- unique order id
- user's mobile phone number
- transaction amount in ore
- payment description
- callback url - to this URL Vipps will push information about finalized or canceled payment
- Ref. Order ID (optional)
If everything goes smooth, ::initiatePayment()
method returns an instance of \zaporylie\Vipps\Model\Payment\ResponseInitiatePayment
method.
If API throws an error, \zaporylie\Vipps\Exceptions\VippsException
is thrown.
// Get payment API.
$payment = $app->payment('<subscription_key>', '<merchant_serial_number>');
// Get order status (basic informations about payment).
$status = $payment->getStatus('<order_id>');
// Get transaction details including capture/refund history.
$details = $payment->getDetails('<order_id>');
By default all requests are made against Vipps Test Environment. If you want to use production environment you must pass endpoint option to Vipps client.
$client = new \zaporylie\Vipps\Client('xxxxxxxxxxxxxxxxxxxxxxxx', [
'endpoint' => 'live',
]);