Download the PHP package bayarcash/php-sdk without Composer

On this page you can find all versions of the php package bayarcash/php-sdk. 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 php-sdk

Bayarcash Payment Gateway PHP SDK

Latest Stable Version Total Downloads Downloads (legacy) PHP Version Require License

The Bayarcash SDK provides an expressive interface for interacting with Bayarcash's Payment Gateway API. It supports both API v2 (default) and v3, with additional features available in v3.

Table of Contents

Requirements

Installation

Install via Composer:

Note: This package was previously published as webimpian/bayarcash-php-sdk. Existing installations using the old name continue to work, but new integrations should use bayarcash/php-sdk.

You will need two credentials from your Bayarcash console:

Getting Started

Plain PHP

Laravel

The service provider is auto-discovered. Add your credentials to .env:

Then resolve the SDK from the container:

To publish the config file:

Configuration

Call useSandbox() / setApiVersion() before making requests. Omit useSandbox() in production to hit the live gateway.

Quick Start: Accept a Payment

A complete FPX payment flow, from creating the payment to verifying the result:

After payment, Bayarcash calls your callback_url (server-to-server) and redirects the payer to your return_url. Verify both — see Handling Callbacks.

Payment Channels

Pass one of these constants (or an array of them) as payment_channel:

Payment Intents

Create a payment intent, then retrieve or cancel it later.

Request fields:

Field Required Description
portal_key ✅ Your portal key.
order_number ✅ Your reference. Max 30 chars.
amount ✅ String with up to 2 decimals, e.g. '10.00'. Range 1.00–30000.00 (min differs for some channels).
payer_name ✅ Max 150 chars.
payer_email ✅ Valid email, max 250 chars.
payment_channel ➖ A Bayarcash::* channel id, or an array of ids. If omitted, the payer chooses on the Bayarcash page.
payer_telephone_number ➖ Required for e-wallet / DuitNow channels. Max 20 chars.
return_url ➖ Where the payer's browser is redirected after payment.
callback_url ➖ Server-to-server notification URL.
metadata ➖ Any extra data you want echoed back.
checksum ➖ Recommended. See below.

Checksum

The checksum protects the request from tampering. Generate it after building the request and append it as checksum:

The checksum is computed from payment_channel, order_number, amount, payer_name, and payer_email.

Idempotency (v3)

Pass a unique key (UUID v4) as the second argument to make a create safe to retry — a timed-out request can be re-sent with the same key without creating a duplicate intent:

Keys are scoped per portal and expire after 24 hours.

Payer identity verification (v3)

For a single FPX (Bayarcash::FPX) or FPX B2B (Bayarcash::FPX_B2B) intent, set verify_identity and add the payer's bank account number (fpx_eaccount_number) and ID — NRIC, passport, or business registration number (fpx_ebuyer_id):

The result comes back on the transaction as payerIdentityVerified (true/false/null) and fpxExtraInfo (account_type, account_number_verified, buyer_id_verified).

Retrieve or cancel (v3)

Handling Callbacks

Bayarcash sends two kinds of notification. Always verify them with your API secret key before trusting the data.

Notification How it arrives Read it from
callback_url (transaction) Server-to-server POST (form-encoded) $_POST / $request->all()
return_url (payer redirect) Browser redirect — POST on v2, GET query on v3 $_POST / $_GET / $request->all()

Each verifier returns true only when the checksum matches. See FPX Direct Debit for mandate-specific callback verifiers.

Payment & Transaction Status

Transaction status is an integer code. Use the Fpx helper instead of hardcoding numbers:

Transactions

The following query helpers require API v3 and throw an exception on v2:

DuitNow QR

Render a DuitNow QR on your own page instead of redirecting the payer to Bayarcash. Requires a single DuitNow QR channel and API v3.

1. Generate the QR while creating the intent (one step):

2. Poll the payment status while the payer scans:

3. Regenerate a fresh QR for an existing intent (e.g. after the previous one expired):

Both $intent->duitnowQr and regenerateDuitNowQr() return a DuitNowQrResource:

Property Description
qrImage PNG data URI — drop straight into an <img>.
qrString Raw QR payload, if you render it yourself.
qrExpiresAt When the QR expires.
transactionId Use it to poll the status.
pollUrl Full status URL, if you prefer to poll it directly.

Webhooks to your callback_url are the primary notification path — polling is only a fallback. Respect next_poll_after_ms between polls and stop once the QR expires.

FPX Direct Debit

FPX Direct Debit lets you set up a recurring mandate and later maintain or terminate it. Constants live on the FpxDirectDebit class:

1. Enrolment

2. Maintenance

Update an existing mandate (identified by its mandate id):

3. Termination

Retrieving mandates & verifying mandate callbacks

Manual Bank Transfer

Submit a manual (offline) bank transfer with proof of payment:

Update the status of an existing transfer:

Portals & FPX Banks

Error Handling

Failed API calls throw typed exceptions. Catch them to handle errors gracefully:

Exception HTTP Meaning
ValidationException 422 Invalid data. Call ->errors() for details.
FailedActionException 400 Request failed. ->getMessage() has the reason.
NotFoundException 404 Resource not found.
RateLimitExceededException 429 Rate limited. ->rateLimitResetsAt holds the reset time.
TimeoutException — Thrown by the optional retry() helper after a timeout.

Response Objects

API methods return typed resource objects. Common properties:

PaymentIntentResource (from createPaymentIntent / getPaymentIntent)

TransactionResource (from getTransaction / transaction queries)

Any missing field is null. Convert a resource (including nested resources) to an array:

Security Recommendations

  1. Always send a checksum with payment and mandate requests.
  2. Verify every callback with the provided verification methods before acting on it.
  3. Store and check transaction ids to prevent duplicate processing.
  4. Use HTTPS for your return_url and callback_url.
  5. Keep your API token and secret key out of source control.

API Documentation

For full API details, see the Official Bayarcash API Documentation.

Support

For support questions, contact Bayarcash support or open an issue in this repository.

Changelog

See CHANGELOG.md for the version history.

License

Open-sourced software licensed under the MIT license.


All versions of php-sdk with dependencies

PHP Build Version
Package Version
Requires guzzlehttp/guzzle Version ^7.0
php Version ^7.4|^8.0
ext-json Version *
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 bayarcash/php-sdk contains the following files

Loading the files please wait ...