Download the PHP package amdadulhaq/bd-payment-laravel without Composer

On this page you can find all versions of the php package amdadulhaq/bd-payment-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package bd-payment-laravel

BD Payment for Laravel

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

Accept payments from Laravel via Bangladeshi gateways (bKash, Nagad, Upay, SSLCommerz) or a manual personal-number driver, all behind one driver-based API.

Contents

Requirements

Installation

The service provider and Payment facade are auto-discovered. Publish the config file:

Configuration

Set the default driver and credentials in your .env:

manual needs no merchant account at all — set a personal/agent number and start collecting payments immediately, reviewing each transaction ID by hand.

Or, for bKash:

Or, for Nagad:

Or, for Upay:

Or, for SSLCommerz:

See config/payment.php for every driver's options. PAYMENT_DRIVER defaults to manual, so nothing breaks in local/testing environments without gateway credentials.

Which driver do I need?

Driver Merchant account needed? Redirects the payer? Server-to-server webhook? Refunds?
manual No — just a personal/agent number No — shows instructions No No
bkash Yes — bKash Tokenized Checkout credentials Yes No (poll/query instead) Yes
nagad Yes — Nagad Merchant API credentials + RSA keys Yes No (poll/query instead) No
upay Yes — Upay merchant credentials Yes No (poll/query instead) No
sslcommerz Yes — SSLCommerz store credentials Yes Yes — real signed IPN Yes

Start with manual if you don't have a merchant account yet — the rest of your app (checkout flow, plan activation, tests) works identically once you switch PAYMENT_DRIVER later, since every driver returns the same PaymentResponse shape.

Accepting a payment

After the payer returns from the gateway (or, for manual, once they report their transaction ID):

Check a payment's status any time without mutating anything:

Refund a completed payment (not every gateway/driver supports this):

Use a specific driver, or a driver other than the default, for one call — same as Storage::disk():

Handling webhooks / IPN

Some gateways notify your server directly instead of (or in addition to) redirecting the payer's browser back. Point that URL at a route in your app and hand the request straight to the driver:

Every driver verifies the notification before trusting it — never on the payload alone:

A forged or tampered payload throws AmdadulHaq\BdPayment\Exceptions\PaymentException rather than returning a fake "success".

API reference

PaymentRequest

Everything a driver might need to start a payment — pass what applies, ignore the rest (e.g. the manual driver ignores every URL field).

Property Type Notes
amount float Required.
invoiceNumber string Required. Your own unique reference — becomes merchantInvoiceNumber (bKash), orderId (Nagad), or tran_id (SSLCommerz).
currency string Defaults to 'BDT'.
customerName, customerEmail, customerPhone, customerAddress ?string Used by SSLCommerz's required customer fields; bKash uses customerPhone as the payer reference.
successUrl, failUrl, cancelUrl ?string Where the payer's browser returns to after paying, on redirect-based drivers.
ipnUrl ?string SSLCommerz-specific: where its server posts the signed IPN.
metadata array<string, mixed> Driver-specific extras — e.g. SSLCommerz reads metadata['product_name'] / metadata['product_category'].

PaymentResponse

What every driver method returns, so calling code never branches on which gateway answered.

Property Type Meaning
status PaymentStatus Normalized status — see below.
invoiceNumber string Echoes back the invoice/order/transaction reference.
gatewayPaymentId ?string The gateway's own payment/session/reference ID — save this, you'll need it for verify()/query()/refund().
transactionId ?string The final settlement transaction ID (bKash trxID, Nagad issuerPaymentRefNo, SSLCommerz bank_tran_id), once available.
amount ?float The confirmed amount, when the gateway reports one.
redirectUrl ?string Where to send the payer next (redirect-based drivers only).
message ?string Human-readable status/instructions (e.g. the manual driver's payment instructions).
raw array<string, mixed> The untouched gateway response — keep this for auditing/debugging, don't build logic on it directly.

PaymentStatus

Case Meaning
Initiated Payment started, payer hasn't completed it yet.
Pending Payer has acted (e.g. submitted a manual transaction ID) but nothing is confirmed yet.
Completed Money has settled — $status->isSuccessful() is true.
Failed Payment did not succeed.
Cancelled Payer backed out.
Refunded A completed payment was refunded.

$status->isFinal() is true for every case except Initiated/Pending.

Adding your own gateway

Register a custom driver:

Any driver just needs to implement AmdadulHaq\BdPayment\Contracts\PaymentDriver:

Testing

Use Payment::fake() to swap the real gateway with an in-memory fake and assert on what would have been charged, without dispatching anything or hitting the network:

Troubleshooting

bKash: "Failed to grant an access token." Double-check BKASH_USERNAME/BKASH_PASSWORD (your Tokenized Checkout portal credentials, not your personal bKash PIN) and that BKASH_BASE_URL matches your environment — the sandbox and production base URLs are different hosts, not just different credentials.

Nagad: "Invalid merchant private key." / "Invalid Nagad public key." Both keys must be full PEM strings, including the -----BEGIN ... KEY----- / -----END ... KEY----- lines. When storing a multi-line key in .env, wrap it in quotes and use \n for line breaks, or load it from a file path instead (e.g. NAGAD_MERCHANT_PRIVATE_KEY=file:///path/to/key.pem combined with your own file_get_contents() in a custom service provider binding) rather than pasting it raw into .env.

SSLCommerz: handleWebhook() throws "IPN signature verification failed." Make sure the route receiving the IPN excludes Laravel's CSRF middleware (SSLCommerz's server can't obtain a CSRF token) and that you're passing the entire raw POST payload — $request->all() — to handleWebhook(), not a filtered subset, since the signature covers specific fields named in verify_key.

"Nothing happens" in local development PAYMENT_DRIVER defaults to manual, which never hits the network. If you're expecting a real gateway call, confirm .env actually sets PAYMENT_DRIVER to bkash/nagad/sslcommerz and that you ran php artisan config:clear after changing it (cached config wins over .env).

Running the package's own test suite

License

MIT. See LICENSE.md.


All versions of bd-payment-laravel with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2|^8.3|^8.4|^8.5
illuminate/http Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package amdadulhaq/bd-payment-laravel contains the following files

Loading the files please wait ...