Giter VIP home page Giter VIP logo

bkash-php's Introduction

bKash PHP Library

The bKash PHP library is a convenient way to integrate the bKash payment gateway into your PHP applications. It provides methods for creating and verifying payments. With this library, you can offer your users a seamless and secure way to make payments using the bKash platform.

Table of Contents

Installation

You can easily install the bKash PHP library via Composer:

composer require rtraselbd/bkash-php

Usage

To get started with the bKash PHP library, follow these steps:

  1. Initialize the bKash Object: Create an instance of the bKash class by providing your bKash API credentials in an array.

     use RT\bKash\bKash;
    
     require 'vendor/autoload.php';
    
     $credential = [
        'username'      => 'your-bKash-username',
        'password'      => 'your-bKash-password',
        'app_key'       => 'your-app-key',
        'app_secret'    => 'your-app-secret',
     ];
     $bKash = new bKash($credential);
  2. Create a Payment Request: Use the createPayment method to create a payment request. Provide the required payment request data, including the amount, success URL, and brand name.

    $requestData = [
        'amount'        => 10,
        'success_url'   => 'https://your-website.com/success.php',
        'brand_name'    => 'YourBrandName',
    ];
    
    try {
        $bKashURL = $bKash->createPayment($requestData);
        // Redirect the user to the bKash payment URL
        header('Location: ' . $bKashURL);
    } catch (Exception $e) {
        // Handle any exceptions or errors here
        $error = $e->getMessage();
    }
  3. Verify a Payment: To verify a payment, retrieve the paymentID from the query parameters and use the verifyPayment method.

    $paymentID = $_GET['paymentID'];
    
    try {
        $response = $bKash->verifyPayment($paymentID);
    } catch (Exception $e) {
        // Handle any exceptions or errors here
        $error = $e->getMessage();
    }

License

This library is open-source and licensed under the MIT License. You are free to use and modify it in accordance with the terms of the license.

Feel free to contribute, report issues, or suggest improvements! Your feedback and contributions are highly appreciated.

bkash-php's People

Contributors

rtraselbd avatar

Watchers

 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.