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 PHPFpxBankResource. - FpxDirect
Debit - FPX Direct Debit constants and helpers (port of PHP
FpxDirectDebit). - FpxDirect
Debit Enrolment Request - Builder for
crate::Bayarcash::create_fpx_direct_debit_enrollment. - FpxDirect
Debit Maintenance Request - Builder for
crate::Bayarcash::create_fpx_direct_debit_maintenance. - FpxDirect
Debit Termination Request - Builder for
crate::Bayarcash::create_fpx_direct_debit_termination. - Mandate
- A mandate (from
get_fpx_direct_debit). Port of PHPFpxDirectDebitResource. - Mandate
Application - A mandate application result (from enrolment / maintenance / termination).
Port of PHP
FpxDirectDebitApplicationResource. - Manual
Bank Transfer Request - Builder for
crate::Bayarcash::create_manual_bank_transfer. - Payment
Intent - A payment intent (from
create_payment_intent/get_payment_intent/cancel_payment_intent). Port of PHPPaymentIntentResource. - Payment
Intent Request - Builder for
crate::Bayarcash::create_payment_intent. - Portal
- A portal (from
get_portals). Port of PHPPortalResource. - Transaction
- A transaction (from
get_transactionand the v3 transaction queries). Port of PHPTransactionResource. - Transaction
Filters - Filters for
crate::Bayarcash::get_all_transactions(v3 only). - Transaction
List - Paginated transaction list returned by
get_all_transactions. - Validation
Errors - Validation payload extracted from a
422 Unprocessable Entityresponse.
Enums§
- ApiVersion
- The Bayarcash API version.
- Error
- All errors surfaced by the SDK.
- Manual
Bank Transfer Response - The varied result shapes of a manual bank transfer creation, mirroring the
PHP
processManualTransferResponsereturn values. - Payment
Channel - A payment channel selection: either a single channel id or several.
Traits§
- Callback
Data - 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.