PHPackages                             sebdesign/laravel-viva-payments - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. sebdesign/laravel-viva-payments

ActiveLibrary[Payment Processing](/categories/payments)

sebdesign/laravel-viva-payments
===============================

A Laravel package for integrating the Viva Payments gateway

v6.4.0(1w ago)4851.0k↓15.3%22[7 issues](https://github.com/sebdesign/laravel-viva-payments/issues)[1 PRs](https://github.com/sebdesign/laravel-viva-payments/pulls)MITPHPPHP ^8.1CI passing

Since Apr 25Pushed 1w ago6 watchersCompare

[ Source](https://github.com/sebdesign/laravel-viva-payments)[ Packagist](https://packagist.org/packages/sebdesign/laravel-viva-payments)[ Docs](https://github.com/sebdesign/laravel-viva-payments)[ RSS](/packages/sebdesign-laravel-viva-payments/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (10)Dependencies (44)Versions (66)Used By (0)

Viva Payments for Laravel
=========================

[](#viva-payments-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/7b3fe98acf390800b48994c9b81ee6de7fdb920df9a92b5f0d995e0a65fc5d61/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73656264657369676e2f6c61726176656c2d766976612d7061796d656e74732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sebdesign/laravel-viva-payments)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/dc0c69a0eabf75625306275dacf4072fceb29ad68ca1a8996d7ee171da9ba5c3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73656264657369676e2f6c61726176656c2d766976612d7061796d656e74732f74657374732e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265)](https://github.com/sebdesign/laravel-viva-payments/actions)[![Quality Score](https://camo.githubusercontent.com/8f0fdb641916bc2d3a5b58976de9096c8cf15a34e6f607e41f1314cde1d796eb/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f73656264657369676e2f6c61726176656c2d766976612d7061796d656e74732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/sebdesign/laravel-viva-payments)[![Scrutinizer Coverage](https://camo.githubusercontent.com/222b7dd205cefc6324250923fda186f343d3b0ffd53a2a36d99259aaec3f651a/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f73656264657369676e2f6c61726176656c2d766976612d7061796d656e74732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/sebdesign/laravel-viva-payments)

[![VivaPayments logo](https://camo.githubusercontent.com/062a784c53cacc24840e6836da3b5a452e713bb3c7d102bd49da1194f1e5c314/68747470733a2f2f696d616765732e707269736d69632e696f2f76697661646f74636f6d2f5a356f34575a627173744a39395f71335f31323030783633305f4c6f676f312e706e67 "Viva.com logo")](https://www.viva.com/)

This package provides an interface for the Viva.com Payment API. It handles the **Smart Checkout** integration, the **ISV Payment API**, and **Webhooks**.

Check out the official Viva.com Developer Portal for detailed instructions on the APIs and more:

**Note:** This project is not a official package, and I'm not affiliated with Viva.com in any way.

Setup
-----

[](#setup)

#### Installation

[](#installation)

Install the package through Composer.

This package requires PHP 8.1 and Laravel 10 or higher, and uses Guzzle 7.0 to make API calls. Use the appropriate version according to your dependencies.

Viva Payments for LaravelGuzzleLaravel^6.2^7.0^10.0^6.0^7.0^9.0^5.2^7.0^9.0^5.1^7.0^8.0^5.0^6.0|^7.0^7.0^4.3^6.0|^7.0^7.0~4.1~6.0~7.0~4.0~6.0~6.0~3.0~6.0~5.5~2.0~6.0~5.0~1.0~5.0~5.0```
composer require sebdesign/laravel-viva-payments

```

#### Service Provider

[](#service-provider)

The package will automatically register its service provider.

#### Configuration

[](#configuration)

Add the following array in your `config/services.php`.

```
'viva' => [
    'api_key' => env('VIVA_API_KEY'),
    'merchant_id' => env('VIVA_MERCHANT_ID'),
    'environment' => env('VIVA_ENVIRONMENT', 'production'),
    'client_id' => env('VIVA_CLIENT_ID'),
    'client_secret' => env('VIVA_CLIENT_SECRET'),
    'isv_client_id' => env('VIVA_ISV_CLIENT_ID'),
    'isv_client_secret' => env('VIVA_ISV_CLIENT_SECRET'),
    'isv_partner_id' => env('VIVA_ISV_PARTNER_ID'),
    'isv_partner_api_key' => env('VIVA_ISV_PARTNER_API_KEY'),
    'source_code' => env('VIVA_SOURCE_CODE'),
],
```

The `api_key` and `merchant_id` can be found in the *Settings &gt; API Access* section of your profile.

The `client_id` and `client_secret` are needed for the *Smart Checkout*. You can generate the *Smart Checkout Credentials* in the *Settings &gt; API Access* section of your profile.

The `isv_client_id`, `isv_client_secret`, `isv_partner_id` and `isv_partner_api_key` are required for using the **ISV Payment API** with Basic authentication.

> Read more about API authentication on the Developer Portal:

The `environment` can be either `production` or `demo`.

Smart Checkout
--------------

[](#smart-checkout)

> Read more about the Smart Checkout process on the Developer portal:

The `\Sebdesign\VivaPayments\Facades\Viva` facade provides all the methods needed to interact with the Smart Checkout integration.

The following guide will walk you through the necessary steps:

#### Create the payment order

[](#create-the-payment-order)

The amount requested in cents is required. All the other parameters are optional. Check out the [request body schema](https://developer.vivawallet.com/apis-for-payments/payment-api/#tag/Payments/paths/~1checkout~1v2~1orders/post).

```
use Sebdesign\VivaPayments\Facades\Viva;

$orderCode = Viva::orders()->create(
    order: new CreatePaymentOrder(amount: 1000),
);
```

#### Redirect to Smart Checkout

[](#redirect-to-smart-checkout)

```
use Sebdesign\VivaPayments\Facades\Viva;

$redirectUrl = Viva::orders()->redirectUrl(
    ref: $orderCode,
    color: '0000ff',
    paymentMethod: 23,
);

return redirect()->away(path: $redirectUrl);
```

#### Verify payment

[](#verify-payment)

```
use Sebdesign\VivaPayments\Facades\Viva;

$response = Viva::transactions()->retrieve(transactionId: request('t'));
```

### Full example

[](#full-example)

```
