Download the PHP package sebdesign/laravel-viva-payments without Composer

On this page you can find all versions of the php package sebdesign/laravel-viva-payments. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-viva-payments

Viva Payments for Laravel

Latest Version on Packagist Build Status Quality Score Scrutinizer Coverage

VivaPayments logo

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

Check out the official Viva Wallet Developer Portal for detailed instructions on the APIs and more: https://developer.vivawallet.com

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

Setup

Installation

Install the package through Composer.

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

Viva Payments for Laravel Guzzle Laravel
^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

Service Provider

The package will automatically register its service provider.

Configuration

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

The api_key and merchant_id can be found in the Settings > 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 > API Access section of your profile.

The 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: https://developer.vivawallet.com/getting-started/find-your-account-credentials/client-smart-checkout-credentials/

The environment can be either production or demo.

Smart Checkout

Read more about the Smart Checkout process on the Developer portal: https://developer.vivawallet.com/smart-checkout/

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

The amount requested in cents is required. All the other parameters are optional. Check out the request body schema.

Redirect to Smart Checkout

Verify payment

Full example

Handling Webhooks

Viva Payments supports Webhooks, and this package offers a controller which verifies and handles incoming notification events.

Read more about the Webhooks on the Developer Portal: https://developer.vivawallet.com/webhooks-for-payments/

Define the route

In your routes/web.php define the following route for each webhook you have in your profile, replacing the URI(s) and your controller(s) accordingly.

Exclude from CSRF protection

Don't forget to add your webhook URI(s) to the $except array on your VerifyCsrfToken middleware.

Handle webhook events

To handle any request from Viva Wallet, you may listen to the WebhookEvent. According to the EventTypeId, you can handle any event.

The EventData property contains an object with the actual notification. The class of the object depends on the notification type:

Event Class
Transaction Payment Created TransactionPaymentCreated
Transaction Failed TransactionFailed
All other events stdClass

In addition, the TransactionPaymentCreated and TransactionFailed events are dispatched. You can listen to these specific events instead of listening to the WebhookEvent.

Payment API reference

All methods accept a $guzzleOptions array argument as their last parameter. This argument is entirely optional, and it allows you to specify additional request options to the Guzzle client.

Orders

Create a payment order

See: https://developer.vivawallet.com/api-reference-guide/payment-api/#tag/Payments/paths/~1api~1orders~1{orderCode}/get

Get the redirect URL

See: https://developer.vivawallet.com/smart-checkout/smart-checkout-integration/#step-2-redirect-the-customer-to-smart-checkout-to-pay-the-payment-order

Transactions

Retrieve a transaction

See: https://developer.vivawallet.com/apis-for-payments/payment-api/#tag/Transactions/paths/~1checkout~1v2~1transactions~1{transactionId}/get

Create a recurring transaction

See: https://developer.vivawallet.com/api-reference-guide/payment-api/#tag/Transactions/paths/~1api~1transactions~1{Id}/post

OAuth

Request access token

See: https://developer.vivawallet.com/authentication/#step-2-request-access-token

You don't need to call this method, because the client requests the access token automatically when needed. However, you can specify the client credentials at runtime if you want.

If you need to request access tokens manually, you can use the requestToken method. This method returns the token as an AccessToken object.

Use an existing access token

If you are storing the token somewhere, e.g. in your database or in the cache, you can set the access token string on the client to be used as a Bearer token.

Cards

Create card token

See: https://developer.vivawallet.com/apis-for-payments/payment-api/#tag/Transactions/paths/~1acquiring~1v1~1cards~1tokens/post

Webhooks

Get an authorization code

See: https://developer.vivawallet.com/webhooks-for-payments/#generate-a-webhook-verification-key

ISV Payment API Reference

The ISV Payment API methods are available through the Viva::isv() service.

Orders

Create a payment order

See: https://developer.vivawallet.com/isv-partner-program/payment-isv-api/#tag/Payments/paths/~1checkout~1v2~1isv~1orders/post

Transactions

Retrieve a transaction

See: https://developer.vivawallet.com/isv-partner-program/payment-isv-api/#tag/Retrieve-Transactions/paths/~1checkout~1v2~1isv~1transactions~1{transactionId}?merchantId={merchantId}/get

Create a recurring transaction

See: https://developer.vivawallet.com/isv-partner-program/payment-isv-api/#tag/Recurring-Payments/paths/~1api~1transactions~1{id}/post

Exceptions

When the VivaPayments API returns an error, a Sebdesign\VivaPayments\VivaException is thrown.

For any other HTTP error a GuzzleHttp\Exception\ClientException is thrown.

Tests

Unit tests are triggered by running phpunit --group unit.

To run functional tests you have to include a .env file in the root folder, containing the credentials (VIVA_API_KEY, VIVA_MERCHANT_ID, VIVA_CLIENT_ID, VIVA_CLIENT_SECRET), in order to hit the VivaPayments demo API. Then run phpunit --group functional to trigger the tests.


All versions of laravel-viva-payments with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
guzzlehttp/guzzle Version ^7.2
illuminate/config Version ^9.0 | ^10.0 | ^11.0
illuminate/routing Version ^9.0 | ^10.0 | ^11.0
illuminate/support Version ^9.0 | ^10.0 | ^11.0
spatie/laravel-data Version ^2.0 | ^3.0 | ^4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sebdesign/laravel-viva-payments contains the following files

Loading the files please wait ....