mobiverse/appsnmobile-payment

This is a Laravel package for the Apps N Mobile payment service

v0.1.14 2022-04-26 14:30 UTC

This package is auto-updated.

Last update: 2024-11-26 20:28:30 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

###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.