Struct mpesa::services::B2bBuilder
source · pub struct B2bBuilder<'mpesa, Env: ApiEnvironment> { /* private fields */ }
Expand description
B2B transaction builder struct
Implementations§
source§impl<'mpesa, Env: ApiEnvironment> B2bBuilder<'mpesa, Env>
impl<'mpesa, Env: ApiEnvironment> B2bBuilder<'mpesa, Env>
sourcepub fn new(
client: &'mpesa Mpesa<Env>,
initiator_name: &'mpesa str
) -> B2bBuilder<'mpesa, Env>
pub fn new( client: &'mpesa Mpesa<Env>, initiator_name: &'mpesa str ) -> B2bBuilder<'mpesa, Env>
Creates a new B2B builder
Requires an initiator_name
, the credential/ username used to authenticate the transaction request
sourcepub fn command_id(self, command_id: CommandId) -> B2bBuilder<'mpesa, Env>
pub fn command_id(self, command_id: CommandId) -> B2bBuilder<'mpesa, Env>
Adds the CommandId
. Defaults to CommandId::BusinessToBusinessTransfer
if not explicitly provided.
Errors
If invalid CommandId
is provided
sourcepub fn party_a(self, party_a: &'mpesa str) -> B2bBuilder<'mpesa, Env>
pub fn party_a(self, party_a: &'mpesa str) -> B2bBuilder<'mpesa, Env>
Adds Party A
which is a required field
Party A
should be a paybill number.
Errors
If Party A
is invalid or not provided
sourcepub fn party_b(self, party_b: &'mpesa str) -> B2bBuilder<'mpesa, Env>
pub fn party_b(self, party_b: &'mpesa str) -> B2bBuilder<'mpesa, Env>
Adds Party B
which is a required field
Party B
should be a mobile number.
Errors
If Party B
is invalid or not provided
sourcepub fn parties(
self,
party_a: &'mpesa str,
party_b: &'mpesa str
) -> B2bBuilder<'mpesa, Env>
👎Deprecated
pub fn parties( self, party_a: &'mpesa str, party_b: &'mpesa str ) -> B2bBuilder<'mpesa, Env>
Adds Party A
and Party B
. Both are required fields
Party A
should be a paybill number while Party B
should be a mobile number.
Errors
If either Party A
or Party B
is invalid or not provided
sourcepub fn timeout_url(self, timeout_url: &'mpesa str) -> B2bBuilder<'mpesa, Env>
pub fn timeout_url(self, timeout_url: &'mpesa str) -> B2bBuilder<'mpesa, Env>
Error
If QueueTimeoutUrl
is invalid or not provided
sourcepub fn result_url(self, result_url: &'mpesa str) -> B2bBuilder<'mpesa, Env>
pub fn result_url(self, result_url: &'mpesa str) -> B2bBuilder<'mpesa, Env>
Error
If ResultUrl
is invalid or not provided
sourcepub fn urls(
self,
timeout_url: &'mpesa str,
result_url: &'mpesa str
) -> B2bBuilder<'mpesa, Env>
👎Deprecated
pub fn urls( self, timeout_url: &'mpesa str, result_url: &'mpesa str ) -> B2bBuilder<'mpesa, Env>
Adds QueueTimeoutUrl
and ResultUrl
. This is a required field
Error
If either QueueTimeoutUrl
and ResultUrl
is invalid or not provided
sourcepub fn sender_id(self, sender_id: IdentifierTypes) -> B2bBuilder<'mpesa, Env>
pub fn sender_id(self, sender_id: IdentifierTypes) -> B2bBuilder<'mpesa, Env>
Adds sender_id
. Will default to IdentifierTypes::ShortCode
if not explicitly provided
sourcepub fn receiver_id(
self,
receiver_id: IdentifierTypes
) -> B2bBuilder<'mpesa, Env>
pub fn receiver_id( self, receiver_id: IdentifierTypes ) -> B2bBuilder<'mpesa, Env>
Adds receiver_id
. Will default to IdentifierTypes::ShortCode
if not explicitly provided
sourcepub fn account_ref(self, account_ref: &'mpesa str) -> B2bBuilder<'mpesa, Env>
pub fn account_ref(self, account_ref: &'mpesa str) -> B2bBuilder<'mpesa, Env>
Adds account_ref
. This field is required
sourcepub fn amount<Number: Into<f64>>(
self,
amount: Number
) -> B2bBuilder<'mpesa, Env>
pub fn amount<Number: Into<f64>>( self, amount: Number ) -> B2bBuilder<'mpesa, Env>
Adds an amount
to the request
This is a required field
sourcepub fn remarks(self, remarks: &'mpesa str) -> B2bBuilder<'mpesa, Env>
pub fn remarks(self, remarks: &'mpesa str) -> B2bBuilder<'mpesa, Env>
Adds remarks
. This field is optional, will default to “None” if not explicitly passed
sourcepub async fn send(self) -> MpesaResult<B2bResponse>
pub async fn send(self) -> MpesaResult<B2bResponse>
B2B API
Sends b2b payment request.
This API enables Business to Business (B2B) transactions between a business and another business. Use of this API requires a valid and verified B2B M-Pesa short code for the business initiating the transaction and the both businesses involved in the transaction See more here
A successful request returns a B2bResponse
type
Errors
Returns a MpesaError
on failure