Skip to main content

Crate bayarcash

Crate bayarcash 

Source
Expand description

§Bayarcash Rust SDK

An idiomatic, async Rust client for the Bayarcash payment gateway — a feature-parity port of the official Bayarcash PHP SDK. It supports API v2 (default) and v3, and is byte-compatible with the gateway for checksum generation and callback verification.

§Quick start

use bayarcash::{Bayarcash, PaymentIntentRequest};

let client = Bayarcash::new("YOUR_API_TOKEN").use_sandbox();
let secret = "YOUR_API_SECRET_KEY";

let request = PaymentIntentRequest::new(
        "your_portal_key",
        "INV-1001",
        "10.00",
        "Ahmad bin Abdullah",
        "ahmad@example.com",
    )
    .payment_channel(Bayarcash::FPX)
    .return_url("https://your-site.com/payment/return")
    .callback_url("https://your-site.com/payment/callback")
    .signed(secret); // append the checksum

let intent = client.create_payment_intent(&request).await?;
// redirect the payer to `intent.url`

§Verifying callbacks

use bayarcash::Bayarcash;
use std::collections::HashMap;

let client = Bayarcash::new("token");
let callback: HashMap<String, String> = HashMap::new(); // e.g. $_POST / request.all()
if client.verify_transaction_callback_data(&callback, "YOUR_API_SECRET_KEY") {
    // data is authentic — safe to process
}

Modules§

channels
Payment-channel identifiers.
checksum
HMAC-SHA256 checksum generation.
duitnow
DuitNow channels.

Structs§

Bayarcash
The Bayarcash API client.
Fpx
FPX transaction status codes and labels (port of PHP Fpx).
FpxBank
An FPX bank (from fpx_banks_list). Port of PHP FpxBankResource.
FpxDirectDebit
FPX Direct Debit constants and helpers (port of PHP FpxDirectDebit).
FpxDirectDebitEnrolmentRequest
Builder for crate::Bayarcash::create_fpx_direct_debit_enrollment.
FpxDirectDebitMaintenanceRequest
Builder for crate::Bayarcash::create_fpx_direct_debit_maintenance.
FpxDirectDebitTerminationRequest
Builder for crate::Bayarcash::create_fpx_direct_debit_termination.
Mandate
A mandate (from get_fpx_direct_debit). Port of PHP FpxDirectDebitResource.
MandateApplication
A mandate application result (from enrolment / maintenance / termination). Port of PHP FpxDirectDebitApplicationResource.
ManualBankTransferRequest
Builder for crate::Bayarcash::create_manual_bank_transfer.
PaymentIntent
A payment intent (from create_payment_intent / get_payment_intent / cancel_payment_intent). Port of PHP PaymentIntentResource.
PaymentIntentRequest
Builder for crate::Bayarcash::create_payment_intent.
Portal
A portal (from get_portals). Port of PHP PortalResource.
Transaction
A transaction (from get_transaction and the v3 transaction queries). Port of PHP TransactionResource.
TransactionFilters
Filters for crate::Bayarcash::get_all_transactions (v3 only).
TransactionList
Paginated transaction list returned by get_all_transactions.
ValidationErrors
Validation payload extracted from a 422 Unprocessable Entity response.

Enums§

ApiVersion
The Bayarcash API version.
Error
All errors surfaced by the SDK.
ManualBankTransferResponse
The varied result shapes of a manual bank transfer creation, mirroring the PHP processManualTransferResponse return values.
PaymentChannel
A payment channel selection: either a single channel id or several.

Traits§

CallbackData
Read individual fields out of a callback payload.

Functions§

verify_direct_debit_authorization_callback_data
Verify a direct-debit authorization callback (includes application_type).
verify_direct_debit_bank_approval_callback_data
Verify a direct-debit bank-approval callback.
verify_direct_debit_transaction_callback_data
Verify a direct-debit transaction callback.
verify_pre_transaction_callback_data
Verify a pre-transaction callback.
verify_return_url_callback_data
Verify a return-URL callback (payer browser redirect).
verify_transaction_callback_data
Verify a transaction callback (delivered to your callback_url).

Type Aliases§

Result
Convenience result type used throughout the crate.