mobiverse / appsnmobile-payment
This is a Laravel package for the Apps N Mobile payment service
Fund package maintenance!
Mobiverse
Requires
- php: ^8.0|^8.1
- illuminate/contracts: ^9.0
- ramsey/uuid: ^4.2
- spatie/laravel-package-tools: ^1.9.2
Requires (Dev)
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- spatie/laravel-ray: ^1.26
README
###Note: This is work in progress.
This package consumes the AppsnMobile payment APIs therefore you would require an account with ApsnMobile to use it.
Installation
You can install the package via composer:
composer require mobiverse/appsnmobile-payment
You can publish and run the migrations with:
php artisan vendor:publish --provider="Mobiverse\AppsnmobilePayment\AppsnmobilePaymentServiceProvider" --tag="appsnmobile-payment-migrations" php artisan migrate
You can publish the config file with:
php artisan vendor:publish --provider="Mobiverse\AppsnmobilePayment\AppsnmobilePaymentServiceProvider" --tag="appsnmobile-payment-config"
This is the contents of the published config file:
return [ 'baseurl' => env('MOMO_BASEURL', ''), 'callback_url'=>env('MOMO_CALLBACK_URL',''), 'debit_transaction_prefix'=>env('MOMO_DEBIT_TRANSACTION_PREFIX',''), 'credit_transaction_prefix'=>env('MOMO_CREDIT_TRANSACTION_PREFIX',''), 'debit_callback_url'=>env('MOMO_DEBIT_CALLBACK_URL',''), 'credit_callback_url'=>env('MOMO_CREDIT_CALLBACK_URL',''), 'auth'=>[ 'basic'=>[ 'user'=>env('MOMO_BASICAUTH_USR',''), 'pass'=>env('MOMO_BASICAUTH_PWD','') ] ], 'purchase'=>[ 'balance'=>[ 'reference'=>env('MOMO_PURCHASE_BALANCE_REFERENCE','') ] ] ];
Usage
$momo_transaction = [ 'msisdn' => '0244377919', 'network' => MomoTransaction::VODAFONE, 'amount' => 0.10, 'payment_request_id' => 1, 'transaction_id' => $transaction_id ]; \Mobiverse\AppsnmobilePayment\AppsnmobilePaymentFacade::executeDebitRequest($momo_transaction);
In the controller of your callback url add the following action:
public function debitCallback(\Mobiverse\AppsnmobilePayment\IAppsnmobilePayment $momoPaymentService, Request $request){ $momoPaymentService->processDebitCallback($request->all()); return response(); }
Implement listeners for the PaymentSucceeded, PaymentFailed and PaymentPending events. eg.
PaymentSucceeded::class => [ SendReceipt::class, ], PaymentFailed::class => [ FailedPaymentNotification::class, ], PaymentPending::class => [ PaymentPaymentNotification::class, ]
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.