11
2- [ <img src =" https://github-ads.s3.eu-central-1.amazonaws.com/support-ukraine.svg?t=1 " />] ( https://supportukrainenow.org )
3-
4- # Implementation of viva wallet's API for laravel projects
2+ # Viva Wallet's API for Laravel applications
53
4+ ![ PHP Version] ( https://img.shields.io/packagist/php-v/deyjandi/laravel-viva-wallet )
5+ ![ Laravel Version] ( https://img.shields.io/badge/laravel-%3E%3D8-red )
66[ ![ Latest Version on Packagist] ( https://img.shields.io/packagist/v/deyjandi/laravel-viva-wallet.svg?style=flat-square )] ( https://packagist.org/packages/deyjandi/laravel-viva-wallet )
77[ ![ GitHub Tests Action Status] ( https://img.shields.io/github/workflow/status/deyjandi/laravel-viva-wallet/run-tests?label=tests )] ( https://github.com/deyjandi/laravel-viva-wallet/actions?query=workflow%3Arun-tests+branch%3Amain )
88[ ![ GitHub Code Style Action Status] ( https://img.shields.io/github/workflow/status/deyjandi/laravel-viva-wallet/Check%20&%20fix%20styling?label=code%20style )] ( https://github.com/deyjandi/laravel-viva-wallet/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amain )
99[ ![ Total Downloads] ( https://img.shields.io/packagist/dt/deyjandi/laravel-viva-wallet.svg?style=flat-square )] ( https://packagist.org/packages/deyjandi/laravel-viva-wallet )
1010
1111This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
1212
13- ## Support us
14-
15- [ <img src =" https://github-ads.s3.eu-central-1.amazonaws.com/laravel-viva-wallet.jpg?t=1 " width =" 419px " />] ( https://spatie.be/github-ad-click/laravel-viva-wallet )
16-
17- We invest a lot of resources into creating [ best in class open source packages] ( https://spatie.be/open-source ) . You can support us by [ buying one of our paid products] ( https://spatie.be/open-source/support-us ) .
18-
19- We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [ our contact page] ( https://spatie.be/about-us ) . We publish all received postcards on [ our virtual postcard wall] ( https://spatie.be/open-source/postcards ) .
2013
21- ## Installation
14+ ## Installation steps
2215
23- You can install the package via composer:
16+ ### 1. install the package via composer:
2417
2518``` bash
2619composer require deyjandi/laravel-viva-wallet
2720```
2821
29- You can publish and run the migrations with:
22+ ### 2. Publish the ` config ` file with:
3023
3124``` bash
32- php artisan vendor:publish --tag=" laravel-viva-wallet-migrations"
33- php artisan migrate
25+ php artisan vendor:publish --tag=" viva-wallet-config"
3426```
3527
36- You can publish the config file with:
37-
28+ ### 3. Add at minimum the following to the ` .env ` file
3829``` bash
39- php artisan vendor:publish --tag=" laravel-viva-wallet-config"
30+ VIVA_WALLET_MERCHANT_ID=< your-merchant-id>
31+ VIVA_WALLET_API_KEY=< your-api-id>
32+ VIVA_WALLET_CLIENT_ID=< your-smart-checkout-client-id>
33+ VIVA_WALLET_CLIENT_SECRET=< your-smart-checkout-secret>
4034```
35+ You can refer to the ` ./config/viva-wallet-config.php ` for additional configuration options
36+
37+ ## Usage
4138
42- This is the contents of the published config file:
39+
40+ ### Create a Payment Order using the default configuration:
4341
4442``` php
45- return [
46- ];
43+ ...
44+
45+ use Deyjandi\VivaWallet\Facades\VivaWallet;
46+ use Deyjandi\VivaWallet\Payment;
47+
48+ ...
49+
50+ $payment = new Payment($amount = 1000);
51+
52+ $checkoutUrl = VivaWallet::createPaymentOrder($payment);
53+
54+ ...
4755```
4856
49- Optionally, you can publish the views using
57+ ### Create a Payment Order specifying every configurable option:
5058
51- ``` bash
52- php artisan vendor:publish --tag=" laravel-viva-wallet-views"
59+ ``` php
60+ ...
61+
62+ use Deyjandi\VivaWallet\Enums\RequestLang;
63+ use Deyjandi\VivaWallet\Enums\PaymentMethod;
64+ use Deyjandi\VivaWallet\Facades\VivaWallet;
65+ use Deyjandi\VivaWallet\Customer;
66+ use Deyjandi\VivaWallet\Payment;
67+
68+ ...
69+
70+ $customer = new Customer(
71+ 72+ $fullName = 'John Doe',
73+ $phone = '+306987654321',
74+ $countryCode = 'GR',
75+ $requestLang = RequestLang::Greek,
76+ );
77+
78+ $payment = new Payment();
79+
80+ $payment
81+ ->setAmount(2500)
82+ ->setCustomerTrns('short description of the items/services being purchased')
83+ ->setCustomer($customer)
84+ ->setPaymentTimeout(3600)
85+ ->setPreauth(false)
86+ ->setAllowRecurring(true)
87+ ->setMaxInstallments(3)
88+ ->setPaymentNotification(true)
89+ ->setTipAmount(250)
90+ ->setDisableExactAmount(false)
91+ ->setDisableCash(true)
92+ ->setDisableWallet(false)
93+ ->setSourceCode(1234)
94+ ->setMerchantTrns('customer order reference number')
95+ ->setTags(['tag-1', 'tag-2'])
96+ ->setBrandColor('009688')
97+ ->setPreselectedPaymentMethod(PaymentMethod::PayPal);
98+
99+ $checkoutUrl = VivaWallet::createPaymentOrder($payment);
100+
101+ ...
53102```
54103
55- ## Usage
104+
105+ ### Retrieve transaction:
56106
57107``` php
58- $vivaWallet = new Deyjandi\VivaWallet();
59- echo $vivaWallet->echoPhrase('Hello, Deyjandi!');
108+ ...
109+
110+ use Deyjandi\VivaWallet\Facades\VivaWallet;
111+
112+ ...
113+
114+ $transaction = VivaWallet::retrieveTransaction($transactionId);
115+
116+ ```
117+
118+ ### Request a webhook verification key:
119+
120+ ``` zsh
121+ php artisan viva-wallet:webhook-key
60122```
123+ #### the webhook verification key is stored to the ` .env ` file automatically
124+
61125
62126## Testing
63127
@@ -80,7 +144,6 @@ Please review [our security policy](../../security/policy) on how to report secu
80144## Credits
81145
82146- [ Pavlos Kafritsas] ( https://github.com/Deyjandi )
83- - [ All Contributors] ( ../../contributors )
84147
85148## License
86149
0 commit comments