Skip to main content

PaymentAdapter

Trait PaymentAdapter 

Source
pub trait PaymentAdapter: Send + Sync {
    // Required methods
    fn authorize(
        &self,
        request: &PaymentAuthorizeRequest,
    ) -> Result<PaymentAuthorization, PaymentError>;
    fn capture(
        &self,
        authorization_id: &str,
        amount_units: u64,
        currency: &str,
        reference: &str,
    ) -> Result<PaymentResult, PaymentError>;
    fn release(
        &self,
        authorization_id: &str,
        reference: &str,
    ) -> Result<PaymentResult, PaymentError>;
    fn refund(
        &self,
        transaction_id: &str,
        amount_units: u64,
        currency: &str,
        reference: &str,
    ) -> Result<PaymentResult, PaymentError>;
}
Expand description

Trait for executing payments against an external rail.

Required Methods§

Source

fn authorize( &self, request: &PaymentAuthorizeRequest, ) -> Result<PaymentAuthorization, PaymentError>

Authorize or prepay up to amount_units before the tool executes.

Source

fn capture( &self, authorization_id: &str, amount_units: u64, currency: &str, reference: &str, ) -> Result<PaymentResult, PaymentError>

Finalize payment for the actual cost after tool execution.

Source

fn release( &self, authorization_id: &str, reference: &str, ) -> Result<PaymentResult, PaymentError>

Release an unused authorization hold.

Source

fn refund( &self, transaction_id: &str, amount_units: u64, currency: &str, reference: &str, ) -> Result<PaymentResult, PaymentError>

Refund a previously executed payment.

Implementors§