Search by

droplopay / droplopay-php

droplopay

Official PHP SDK for DroploPay payment gateway (bKash, Nagad, Rocket, bank).

Package info

github.com/droplopay/droplopay-php

Homepage

pkg:composer/droplopay/droplopay-php

Statistics

Installs: 2

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-11-28 05:39 UTC

This package is auto-updated.

Last update: 2026-11-28 05:47:13 UTC


README

Accept bKash, Nagad, Rocket, Upay, bank transfer and more in any PHP website with DroploPay. Payments are verified automatically by SMS.

Installation

With Composer

composer require droplopay/droplopay-php

Without Composer: download src/DroploPay.php and include it:

require 'DroploPay.php';

1. Create a payment

use DroploPay\DroploPay;
use DroploPay\DroploPayException;

$dp = new DroploPay('https://yourname.droplo.online', 'YOUR_API_KEY');

try {
    $res = $dp->createCharge([
        'full_name'    => 'John Doe',
        'email'        => 'john@example.com',
        'amount'       => 500,
        'metadata'     => ['order_id' => 1001],
        'redirect_url' => 'https://yoursite.com/success.php',
        'cancel_url'   => 'https://yoursite.com/cancel.php',
        'webhook_url'  => 'https://yoursite.com/webhook.php',
        'return_type'  => 'GET',
    ]);
    header('Location: ' . $res['payment_url']);
    exit;
} catch (DroploPayException $e) {
    echo 'Error: ' . $e->getMessage();
}

2. Verify the payment (success page & webhook)

$invoiceId = DroploPay::invoiceIdFromRequest();

if ($invoiceId) {
    $payment = $dp->verifyPayment($invoiceId);

    if ($payment['status'] === 'COMPLETED') {
        $orderId = $payment['metadata']['order_id'];
        // ✅ Check the amount matches your order, then mark it as paid
    }
}

⚠️ Always call verifyPayment(). Never mark an order as paid just because someone opened your success URL.

Methods

Method Description
createCharge(array $data) Creates a payment, returns payment_url
verifyPayment(string $invoiceId) Returns status, amount, method, transaction ID, metadata
isPaid(string $invoiceId) true only if COMPLETED
DroploPay::invoiceIdFromRequest() Reads invoice_id from a webhook or redirect

Get your API key

Panel → Developers → API Keys (needs payment:checkout and payment:verify).

Ready-made plugins

Support

License

MIT