Struct mpesa::services::C2bRegisterBuilder
source · pub struct C2bRegisterBuilder<'mpesa, Env: ApiEnvironment> { /* private fields */ }Expand description
C2B Register builder
Implementations§
source§impl<'mpesa, Env: ApiEnvironment> C2bRegisterBuilder<'mpesa, Env>
impl<'mpesa, Env: ApiEnvironment> C2bRegisterBuilder<'mpesa, Env>
sourcepub fn new(client: &'mpesa Mpesa<Env>) -> C2bRegisterBuilder<'mpesa, Env>
pub fn new(client: &'mpesa Mpesa<Env>) -> C2bRegisterBuilder<'mpesa, Env>
Creates a new C2B Builder
sourcepub fn validation_url(
self,
validation_url: &'mpesa str
) -> C2bRegisterBuilder<'mpesa, Env>
pub fn validation_url( self, validation_url: &'mpesa str ) -> C2bRegisterBuilder<'mpesa, Env>
Adds ValidationURL for the client. This is a required field
Error
If ValidationURL is invalid or not provided
sourcepub fn confirmation_url(
self,
confirmation_url: &'mpesa str
) -> C2bRegisterBuilder<'mpesa, Env>
pub fn confirmation_url( self, confirmation_url: &'mpesa str ) -> C2bRegisterBuilder<'mpesa, Env>
Adds ConfirmationUrl for the client. This is a required field
Error
If ConfirmationUrl is invalid or not provided
sourcepub fn response_type(
self,
response_type: ResponseType
) -> C2bRegisterBuilder<'mpesa, Env>
pub fn response_type( self, response_type: ResponseType ) -> C2bRegisterBuilder<'mpesa, Env>
Adds ResponseType for timeout. Will default to ResponseType::Complete if not explicitly provided
sourcepub fn short_code(
self,
short_code: &'mpesa str
) -> C2bRegisterBuilder<'mpesa, Env>
pub fn short_code( self, short_code: &'mpesa str ) -> C2bRegisterBuilder<'mpesa, Env>
Adds ShortCode for the organization. This is a required field.
Error
If ShortCode is invalid or not provided
sourcepub async fn send(self) -> MpesaResult<C2bRegisterResponse>
pub async fn send(self) -> MpesaResult<C2bRegisterResponse>
C2B Register API
Registers the the 3rd party’s confirmation and validation URLs to M-Pesa
Registering maps these URLs to the 3rd party shortcode. Whenever M-Pesa receives a transaction on the shortcode, M-Pesa triggers a validation request against the validation URL and the 3rd party system responds to M-Pesa with a validation response (either a success or an error code). See more here
The response expected is the success code the 3rd party
A successful request returns a C2bRegisterResponse type
Errors
Returns a MpesaError on failure