coretrekstein / vippsomnipay
Vipps driver for the Omnipay payment processing library
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Language:HTML
Requires
- omnipay/common: ~3.0
- php-http/guzzle6-adapter: ^1.1
Requires (Dev)
- omnipay/tests: ~3.0
- squizlabs/php_codesniffer: ~3.0
This package is auto-updated.
Last update: 2024-04-09 20:02:47 UTC
README
Install
composer require coretrekstein/vippsomnipay
Simple html form for mobile number and amount
<form method="get"> <input type="hidden" name="action" value="purchase"> <label>Telefonnummer</label> <input type="tel" name="phone" value="91236172"><br> <label>Beløp (i ører)</label> <input type="number" name="amount"><br> <button>Betal med Vipps</button> </form>
Initialize gateway, authorize, purchase and redirect to Vipps
use CoreTrekStein\VippsOmnipay; $gateway = new VippsOmnipay\Gateway(); $gateway->initialize(array( 'baseUrl' => '', 'clientId' => '', 'clientSecret' => '', 'ocpSubscription' => '', 'merchantSerialNumber' => '' )); $gateway->authorize()); $card = new CreditCard(array( 'number' => $_GET['phone'] )); $transaction = $gateway->purchase(array( 'amount' => $_GET['amount'], 'currency' => 'NOK', 'card' => $card, )); $response = $transaction->send(); header("Location: " . $response->getData()['url']);
Vipps sends a post request to website
$params = array( 'access_token' => $_GET['access_token'], 'order_id' => $_GET['order_id'], 'transactionReference' => $_GET['order_id'] ); $response = $gateway->capture($params)->send(); echo json_encode(array());
Validate the payment
$response = $gateway->completePurchase()->send();