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§
Authorize or prepay up to amount_units before the tool executes.
Sourcefn capture(
&self,
authorization_id: &str,
amount_units: u64,
currency: &str,
reference: &str,
) -> Result<PaymentResult, PaymentError>
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.
Sourcefn release(
&self,
authorization_id: &str,
reference: &str,
) -> Result<PaymentResult, PaymentError>
fn release( &self, authorization_id: &str, reference: &str, ) -> Result<PaymentResult, PaymentError>
Release an unused authorization hold.
Sourcefn refund(
&self,
transaction_id: &str,
amount_units: u64,
currency: &str,
reference: &str,
) -> Result<PaymentResult, PaymentError>
fn refund( &self, transaction_id: &str, amount_units: u64, currency: &str, reference: &str, ) -> Result<PaymentResult, PaymentError>
Refund a previously executed payment.