pub async fn create_payment(
        &self,
        request: &CreatePaymentRequest,
    ) -> Result<CreatePaymentResponse, Error> {
        let url = format!("{}/payments", self.environment.api_url());
        let mut response = self.send_post_request_2(&url, request).await?;

        let status = response.status();
        match status {
            StatusCode::CREATED => {
                let body = response.json().compat().await?;
                Ok(CreatePaymentResponse::Processed(body))
            }
            StatusCode::ACCEPTED => {
                let body = response.json().compat().await?;
                Ok(CreatePaymentResponse::Pending(body))
            }
            StatusCode::UNAUTHORIZED => Err(Error::Unauthorized),
            StatusCode::UNPROCESSABLE_ENTITY => {
                let body = response.json().compat().await?;
                Err(Error::InvalidData(body))
            }
            StatusCode::TOO_MANY_REQUESTS => Err(Error::TooManyRequests),
            code => {
                let body = response.text().compat().await?;
                Err(Error::Unknown(code, body))
            }
        }
    }
/// Request a payment or payout
///
/// To accept payments from cards, digital wallets and many alternative
/// payment methods, specify the source.type field, along with the
/// source-specific data.
///
/// To pay out to a card, specify the destination of your payout using the
/// destination.type field, along with the destination-specific data.
///
/// To verify the success of the payment, check the approved field in the
/// response.
///
/// [`POST /payments`](https://api-reference.checkout.com/#operation/requestAPaymentOrPayout)
Request a payment or payout
To accept payments from cards, digital wallets and many alternative
payment methods, specify the source.type field, along with the
source-specific data.

To pay out to a card, specify the destination of your payout using the
destination.type field, along with the destination-specific data.

To verify the success of the payment, check the approved field in the
response.

[`POST /payments`]
Request a payment or payout To accept payments from cards digital wallets and many alternative payment methods specify the source . type field along with the source - specific data . To pay out to a card specify the destination of your payout using the destination . type field along with the destination - specific data . To verify the success of the payment check the approved field in the response . [ ` POST / payments ` ]
pub async fn create_payment(
        &self,
        request: &CreatePaymentRequest,
    ) -> Result<CreatePaymentResponse, Error> {
        let url = format!("{}/payments", self.environment.api_url());
        let mut response = self.send_post_request_2(&url, request).await?;
        let status = response.status();
        match status {
            StatusCode::CREATED => {
                let body = response.json().compat().await?;
                Ok(CreatePaymentResponse::Processed(body))
            }
            StatusCode::ACCEPTED => {
                let body = response.json().compat().await?;
                Ok(CreatePaymentResponse::Pending(body))
            }
            StatusCode::UNAUTHORIZED => Err(Error::Unauthorized),
            StatusCode::UNPROCESSABLE_ENTITY => {
                let body = response.json().compat().await?;
                Err(Error::InvalidData(body))
            }
            StatusCode::TOO_MANY_REQUESTS => Err(Error::TooManyRequests),
            code => {
                let body = response.text().compat().await?;
                Err(Error::Unknown(code, body))
            }
        }
    }
pub async fn create_payment ( & self , request : & CreatePaymentRequest , ) -> Result < CreatePaymentResponse , Error > { let url = format ! ( " " self environment api_url ( ) ) ; let mut response = self . send_post_request_2 ( & url , request ) . await ? ; let status = response . status ( ) ; match status { StatusCode :: CREATED => { let body = response . json ( ) . compat ( ) . await ? ; Ok ( CreatePaymentResponse :: Processed ( body ) ) } StatusCode :: ACCEPTED => { let body = response . json ( ) . compat ( ) . await ? ; Ok ( CreatePaymentResponse :: Pending ( body ) ) } StatusCode :: UNAUTHORIZED => Err ( Error :: Unauthorized ) , StatusCode :: UNPROCESSABLE_ENTITY => { let body = response . json ( ) . compat ( ) . await ? ; Err ( Error :: InvalidData ( body ) ) } StatusCode :: TOO_MANY_REQUESTS => Err ( Error :: TooManyRequests ) , code => { let body = response . text ( ) . compat ( ) . await ? ; Err ( Error :: Unknown ( code , body ) ) } } }
Request a payment or payout
To accept payments from cards, digital wallets and many alternative
payment methods, specify the source.type field, along with the
source-specific data.
Request a payment or payout To accept payments from cards digital wallets and many alternative payment methods specify the source . type field along with the source - specific data .
&self
request
&CreatePaymentRequest
&self
request
&CreatePaymentRequest