Giter Club home page Giter Club logo

floosak-payment's Introduction

floosak-payment

img.png

laravel package for floosak payment getway

Floosak payment api after update to (p2mcl)

install the package composer require alsharie/floosak-payment

You can publish using the following command

php artisan vendor:publish --provider="Alsharie\FloosakPayment\FloosakServiceProvider"

When published, the config/floosak.php config file contains:

return [
    'auth' => [
        'phone' => env('FLOOSAK_MERCHANT_PHONE'),
        'short_code' => env('FLOOSAK_MERCHANT_SHORT_CODE'),
        'wallet_id' => env('FLOOSAK_MERCHANT_WALLET_ID'),
        'key' => env('FLOOSAK_MERCHANT_KEY'),
    ],
    'url' => [
        'base' => env('FLOOSAK_BASE_URL', 'https://staging.fintech-expert.net'),
    ]
];

If you don't have the request_id and key you must do the following:

1. get request Id

 $floosak = new Floosak();
 $response = $floosak->requestKey();

 if ($response->isSuccess()) {
    $request_id = $response->getRequestId();
    ....
    ....
 } 
        

2. verify request Id

after getting the response YOU MUST store key,request_id in config/floosak.php or in your .env

$floosak = new Floosak();
$response = $floosak
    ->setOtp(/*otp*/)
    ->setRequestId(/*requestId*/) 
    ->verifyKey();

if ($response->isSuccess()) {
    $key= $response->getKey();
    $wallet_id= $response->getWalletId();
    //todo:: store $key and $wallet_id
    
} else {

    return $response->body();
}  

To purchase using Floosak payment

1. Purchase

 $floosak = new Floosak();
 $response = $floosak
     ->setRequestId(/*ref_id*/) // random number you generate most 
     ->setAmount(/*amount*/)
     ->setCustomerPhone(/*phone*/)
     ->setPurpose(/*purpose*/)
     ->purchase();

 if ($response->isSuccess()) {
    $purchase_id = $response->getPurchaseId();
    ....
    ....
 } 
        

2. Confirm purchase

 $floosak = new Floosak();
 $response = $floosak
      ->setPurchaseId(/*purchase_id*/) // you get it from the response of the above request `purchase()`
      ->setOtp(/*user_otp*/)
      ->confirmPurchase();
 if ($response->isSuccess()) {
    $tran_id = $response->getTransactionId();
    ....
    ....
 } 
        

Refund

 $floosak = new Floosak();
 $response = $floosak
     ->setRequestId(/*ref_id*/) // the random number you generated  
     ->setTransactionId(/*tran_id*/)
     ->setAmount(/*amount*/) // amount to refund
     ->refund();

 if ($response->isSuccess()) {
     return $response->getBalance();
 }

you can get the full response body using $response->body() for all requests

floosak-payment's People

Contributors

alsharie avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.