SumUpClient

Struct SumUpClient 

Source
pub struct SumUpClient { /* private fields */ }

Implementations§

Source§

impl SumUpClient

Source

pub async fn list_checkouts( &self, checkout_reference: Option<&str>, ) -> Result<Vec<Checkout>>

Lists created checkout resources according to the applied checkout_reference.

§Arguments
  • checkout_reference - Unique ID of the payment checkout specified by the client application.
§Examples
use sumup_rs::SumUpClient;

let client = SumUpClient::new("your-api-key".to_string(), true)?;

// List all checkouts
let checkouts = client.list_checkouts(None).await?;
println!("Found {} checkouts", checkouts.len());

// List checkouts with specific reference
let checkouts = client.list_checkouts(Some("order-123")).await?;
println!("Found {} checkouts with reference 'order-123'", checkouts.len());
Source

pub async fn list_checkouts_with_query( &self, query: &CheckoutListQuery, ) -> Result<Vec<Checkout>>

Lists created checkout resources with advanced query parameters.

§Arguments
  • query - Query parameters for filtering and pagination
§Examples
use sumup_rs::{SumUpClient, CheckoutListQuery};

let client = SumUpClient::new("your-api-key".to_string(), true)?;

// Create a query to filter checkouts
let query = CheckoutListQuery {
    checkout_reference: Some("order-123".to_string()),
    status: Some("PAID".to_string()),
    merchant_code: Some("merchant123".to_string()),
    customer_id: Some("customer456".to_string()),
    limit: Some(10),
    offset: Some(0),
};

let checkouts = client.list_checkouts_with_query(&query).await?;
println!("Found {} checkouts matching criteria", checkouts.len());
Source

pub async fn create_checkout( &self, body: &CreateCheckoutRequest, ) -> Result<Checkout>

Creates a new payment checkout resource.

§Arguments
  • body - The request body containing the details for the new checkout.
Source

pub async fn retrieve_checkout(&self, checkout_id: &str) -> Result<Checkout>

Retrieves an identified checkout resource.

§Arguments
  • checkout_id - The unique ID of the checkout resource.
Source

pub async fn process_checkout( &self, checkout_id: &str, body: &ProcessCheckoutRequest, ) -> Result<ProcessCheckoutResponse>

Processing a checkout will attempt to charge the provided payment instrument. This can result in immediate success or require a 3DS redirect.

§Arguments
  • checkout_id - The unique ID of the checkout resource to process.
  • body - The request body containing payment details.
Source

pub async fn deactivate_checkout( &self, checkout_id: &str, ) -> Result<DeletedCheckout>

Deactivates an identified checkout resource.

§Arguments
  • checkout_id - The unique ID of the checkout resource to deactivate.
Source

pub async fn get_available_payment_methods( &self, merchant_code: &str, amount: Option<f64>, currency: Option<&str>, ) -> Result<AvailablePaymentMethodsResponse>

Gets available payment methods for a merchant.

§Arguments
  • merchant_code - The merchant’s unique code.
  • amount - The transaction amount (optional).
  • currency - The transaction currency (optional).
Source§

impl SumUpClient

Source

pub async fn create_customer( &self, body: &CreateCustomerRequest, ) -> Result<Customer>

Creates a new saved customer resource.

§Arguments
  • body - The request body containing the customer_id and personal details.
Source

pub async fn retrieve_customer(&self, customer_id: &str) -> Result<Customer>

Retrieves an identified saved customer resource.

§Arguments
  • customer_id - The unique ID of the customer.
Source

pub async fn update_customer( &self, customer_id: &str, body: &UpdateCustomerRequest, ) -> Result<Customer>

Updates an identified saved customer resource’s personal details.

§Arguments
  • customer_id - The unique ID of the customer.
  • body - The customer details to update.
Source

pub async fn list_customer_payment_instruments( &self, customer_id: &str, ) -> Result<Vec<PaymentInstrument>>

Lists all payment instrument resources that are saved for an identified customer.

§Arguments
  • customer_id - The unique ID of the customer.
Source

pub async fn deactivate_customer_payment_instrument( &self, customer_id: &str, token: &str, ) -> Result<()>

Deactivates an identified card payment instrument resource for a customer. A successful deactivation returns a 204 No Content response.

§Arguments
  • customer_id - The unique ID of the customer.
  • token - The token of the payment instrument to deactivate.
Source§

impl SumUpClient

Source

pub async fn list_members( &self, merchant_code: &str, ) -> Result<MemberListResponse>

Lists all members for a specific merchant.

§Arguments
  • merchant_code - The unique merchant code identifier.
Source

pub async fn create_member( &self, merchant_code: &str, body: &CreateMemberRequest, ) -> Result<Member>

Creates a new member resource for a specific merchant.

§Arguments
  • merchant_code - The unique merchant code identifier.
  • body - The member details to create.
Source

pub async fn retrieve_member( &self, merchant_code: &str, member_id: &str, ) -> Result<Member>

Retrieves an identified member resource for a specific merchant.

§Arguments
  • merchant_code - The unique merchant code identifier.
  • member_id - The unique member identifier.
Source

pub async fn update_member( &self, merchant_code: &str, member_id: &str, body: &UpdateMemberRequest, ) -> Result<Member>

Updates an identified member resource for a specific merchant.

§Arguments
  • merchant_code - The unique merchant code identifier.
  • member_id - The unique member identifier.
  • body - The member details to update.
Source

pub async fn delete_member( &self, merchant_code: &str, member_id: &str, ) -> Result<()>

Deletes an identified member resource for a specific merchant.

§Arguments
  • merchant_code - The unique merchant code identifier.
  • member_id - The unique member identifier.
Source§

impl SumUpClient

Source

pub async fn list_memberships(&self) -> Result<Vec<Membership>>

Lists all memberships for the authenticated user.

Source§

impl SumUpClient

Source

pub async fn get_merchant_profile(&self) -> Result<MerchantProfileDetails>

Retrieves the authenticated merchant’s profile.

This endpoint returns the profile of the currently authenticated merchant. The merchant_code is automatically determined from the API key.

Source

pub async fn get_merchant(&self, merchant_code: &str) -> Result<Merchant>

Retrieves a specific merchant’s profile.

§Arguments
  • merchant_code - The unique merchant code identifier.
Source

pub async fn list_merchants(&self) -> Result<Vec<Membership>>

Lists all merchant accounts the authenticated user is a member of. This is the correct way to “list merchants” according to the API spec.

Note: This uses the memberships endpoint as the API doesn’t have a direct “list merchants” endpoint. The memberships contain merchant information.

Source§

impl SumUpClient

Source

pub async fn list_payouts( &self, _query: &PayoutListQuery, ) -> Result<PayoutListResponse>

👎Deprecated since 0.2.0: Use list_merchant_payouts instead. The /me/payouts endpoint does not exist.

Lists all payouts for the authenticated merchant.

§Arguments
  • query - Query parameters including required start_date and end_date

Note: This endpoint requires a merchant_code. Use list_merchant_payouts instead. The /v1.0/me/payouts endpoint does not exist in the SumUp API.

Source

pub async fn list_merchant_payouts( &self, merchant_code: &str, query: &PayoutListQuery, ) -> Result<PayoutListResponse>

Lists payouts for a specific merchant.

§Arguments
  • merchant_code - The unique merchant code identifier
  • query - Query parameters including required start_date and end_date
Source

pub async fn retrieve_payout(&self, payout_id: &str) -> Result<Payout>

Retrieves an identified payout resource.

§Arguments
  • payout_id - The unique payout identifier
Source

pub async fn retrieve_merchant_payout( &self, merchant_code: &str, payout_id: &str, ) -> Result<Payout>

Retrieves a payout for a specific merchant.

§Arguments
  • merchant_code - The unique merchant code identifier
  • payout_id - The unique payout identifier
Source§

impl SumUpClient

Source

pub async fn list_readers(&self) -> Result<ReaderListResponse>

👎Deprecated since 0.2.0: The /me/readers endpoint does not exist. Use list_merchant_readers instead.

Lists all readers for the authenticated merchant.

Note: The /v0.1/me/readers endpoint does not exist in the SumUp API. Use list_merchant_readers with a merchant_code instead.

Source

pub async fn list_merchant_readers( &self, merchant_code: &str, ) -> Result<ReaderListResponse>

Lists readers for a specific merchant.

§Arguments
  • merchant_code - The unique merchant code identifier
Source

pub async fn create_reader(&self, _body: &CreateReaderRequest) -> Result<Reader>

👎Deprecated since 0.2.0: The /me/readers endpoint does not exist. Use create_merchant_reader instead.

Creates a new reader resource.

§Arguments
  • body - The reader details to create

Note: The /v0.1/me/readers endpoint does not exist in the SumUp API. Use create_merchant_reader with a merchant_code instead.

Source

pub async fn create_merchant_reader( &self, merchant_code: &str, body: &CreateReaderRequest, ) -> Result<Reader>

Creates a reader for a specific merchant.

§Arguments
  • merchant_code - The unique merchant code identifier
  • body - The reader details to create
Source

pub async fn retrieve_reader(&self, _reader_id: &str) -> Result<Reader>

👎Deprecated since 0.2.0: The /me/readers/{reader_id} endpoint does not exist. Use retrieve_merchant_reader instead.

Retrieves an identified reader resource.

§Arguments
  • reader_id - The unique reader identifier

Note: The /v0.1/me/readers/{reader_id} endpoint does not exist in the SumUp API. Use retrieve_merchant_reader with a merchant_code instead.

Source

pub async fn retrieve_merchant_reader( &self, merchant_code: &str, reader_id: &str, ) -> Result<Reader>

Retrieves a reader for a specific merchant.

§Arguments
  • merchant_code - The unique merchant code identifier
  • reader_id - The unique reader identifier
Source

pub async fn update_reader( &self, _reader_id: &str, _body: &UpdateReaderRequest, ) -> Result<Reader>

👎Deprecated since 0.2.0: The /me/readers/{reader_id} endpoint does not exist. Use update_merchant_reader instead.

Updates an identified reader resource.

§Arguments
  • reader_id - The unique reader identifier
  • body - The reader details to update

Note: The /v0.1/me/readers/{reader_id} endpoint does not exist in the SumUp API. Use update_merchant_reader with a merchant_code instead.

Source

pub async fn update_merchant_reader( &self, merchant_code: &str, reader_id: &str, body: &UpdateReaderRequest, ) -> Result<Reader>

Updates a reader for a specific merchant.

§Arguments
  • merchant_code - The unique merchant code identifier
  • reader_id - The unique reader identifier
  • body - The reader details to update
Source

pub async fn delete_reader(&self, _reader_id: &str) -> Result<()>

👎Deprecated since 0.2.0: The /me/readers/{reader_id} endpoint does not exist. Use delete_merchant_reader instead.

Deletes an identified reader resource.

§Arguments
  • reader_id - The unique reader identifier

Note: The /v0.1/me/readers/{reader_id} endpoint does not exist in the SumUp API. Use delete_merchant_reader with a merchant_code instead.

Source

pub async fn delete_merchant_reader( &self, merchant_code: &str, reader_id: &str, ) -> Result<()>

Deletes a reader for a specific merchant.

§Arguments
  • merchant_code - The unique merchant code identifier
  • reader_id - The unique reader identifier
Source

pub async fn create_reader_checkout( &self, _reader_id: &str, _body: &CreateReaderCheckoutRequest, ) -> Result<ReaderCheckoutResponse>

👎Deprecated since 0.2.0: The /me/readers/{reader_id}/checkout endpoint does not exist. Use create_merchant_reader_checkout instead.

Creates a checkout for a specific reader (in-person payment).

§Arguments
  • reader_id - The unique reader identifier
  • body - The checkout request details

Note: The /v0.1/me/readers/{reader_id}/checkout endpoint does not exist in the SumUp API. Use create_merchant_reader_checkout with a merchant_code instead.

Source

pub async fn create_merchant_reader_checkout( &self, merchant_code: &str, reader_id: &str, body: &CreateReaderCheckoutRequest, ) -> Result<ReaderCheckoutResponse>

Creates a checkout for a specific reader and merchant (in-person payment).

§Arguments
  • merchant_code - The unique merchant code identifier
  • reader_id - The unique reader identifier
  • body - The checkout request details
Source

pub async fn terminate_reader_checkout( &self, _reader_id: &str, _checkout_id: &str, ) -> Result<()>

👎Deprecated since 0.2.0: The /me/readers/{reader_id}/checkout/{checkout_id} endpoint does not exist. Use terminate_merchant_reader_checkout instead.

Terminates a reader checkout.

§Arguments
  • reader_id - The unique reader identifier
  • checkout_id - The unique checkout identifier

Note: The /v0.1/me/readers/{reader_id}/checkout/{checkout_id} endpoint does not exist in the SumUp API. Use terminate_merchant_reader_checkout with a merchant_code instead.

Source

pub async fn terminate_merchant_reader_checkout( &self, merchant_code: &str, reader_id: &str, checkout_id: &str, ) -> Result<()>

Terminates a reader checkout for a specific merchant.

§Arguments
  • merchant_code - The unique merchant code identifier
  • reader_id - The unique reader identifier
  • checkout_id - The unique checkout identifier
Source§

impl SumUpClient

Source

pub async fn list_receipts( &self, _query: &ReceiptListQuery, ) -> Result<ReceiptListResponse>

👎Deprecated since 0.2.0: The /v1.1/receipts list endpoint does not exist. Use retrieve_receipt for individual receipts.

Lists all receipts for the authenticated merchant.

§Arguments
  • query - Query parameters including required mid

Note: The /v1.1/receipts list endpoint does not exist in the SumUp API. Only individual receipt retrieval is supported.

Source

pub async fn list_merchant_receipts( &self, _merchant_code: &str, _query: &ReceiptListQuery, ) -> Result<ReceiptListResponse>

👎Deprecated since 0.2.0: The merchant receipts list endpoint does not exist. Use retrieve_merchant_receipt for individual receipts.

Lists receipts for a specific merchant.

§Arguments
  • merchant_code - The unique merchant code identifier
  • query - Query parameters including required mid

Note: The /v1.1/merchants/{merchant_code}/receipts list endpoint does not exist in the SumUp API. Only individual receipt retrieval is supported.

Source

pub async fn retrieve_receipt( &self, receipt_id: &str, query: &ReceiptRetrieveQuery, ) -> Result<Receipt>

Retrieves an identified receipt resource.

§Arguments
  • receipt_id - The unique receipt identifier
  • query - Query parameters including required mid
Source

pub async fn retrieve_merchant_receipt( &self, merchant_code: &str, receipt_id: &str, query: &ReceiptRetrieveQuery, ) -> Result<Receipt>

Retrieves a receipt for a specific merchant.

§Arguments
  • merchant_code - The unique merchant code identifier
  • receipt_id - The unique receipt identifier
  • query - Query parameters including required mid
Source§

impl SumUpClient

Source

pub async fn list_roles(&self, merchant_code: &str) -> Result<RoleListResponse>

Lists all roles for a specific merchant.

§Arguments
  • merchant_code - The unique merchant code identifier.
Source

pub async fn create_role( &self, merchant_code: &str, body: &CreateRoleRequest, ) -> Result<Role>

Creates a new role resource for a specific merchant.

§Arguments
  • merchant_code - The unique merchant code identifier.
  • body - The role details to create.
Source

pub async fn retrieve_role( &self, merchant_code: &str, role_id: &str, ) -> Result<Role>

Retrieves an identified role resource for a specific merchant.

§Arguments
  • merchant_code - The unique merchant code identifier.
  • role_id - The unique role identifier.
Source

pub async fn update_role( &self, merchant_code: &str, role_id: &str, body: &UpdateRoleRequest, ) -> Result<Role>

Updates an identified role resource for a specific merchant.

§Arguments
  • merchant_code - The unique merchant code identifier.
  • role_id - The unique role identifier.
  • body - The role details to update.
Source

pub async fn delete_role( &self, merchant_code: &str, role_id: &str, ) -> Result<()>

Deletes an identified role resource for a specific merchant.

§Arguments
  • merchant_code - The unique merchant code identifier.
  • role_id - The unique role identifier.
Source§

impl SumUpClient

Source

pub async fn list_transactions_history( &self, merchant_code: &str, query: &TransactionHistoryQuery<'_>, ) -> Result<TransactionHistoryResponse>

Lists detailed history of all transactions associated with the merchant profile. Uses the modern v2.1 endpoint.

§Arguments
  • merchant_code - The merchant’s unique code.
  • query - A struct with query parameters for filtering and pagination.
Source

pub async fn retrieve_transaction_by_id( &self, merchant_code: &str, transaction_id: &str, ) -> Result<Transaction>

Retrieves the full details of an identified transaction. Uses the modern v2.1 endpoint.

§Arguments
  • merchant_code - The merchant’s unique code.
  • transaction_id - The transaction’s unique ID.
Source

pub async fn refund_transaction( &self, merchant_code: &str, transaction_id: &str, amount: Option<f64>, reason: &str, ) -> Result<Transaction>

Refunds a transaction.

§Arguments
  • merchant_code - The merchant’s unique code.
  • transaction_id - The transaction’s unique ID.
  • amount - The amount to refund (optional, defaults to full amount).
  • reason - The reason for the refund.
Source§

impl SumUpClient

Source

pub fn get_next_page_url_from_history( history: &TransactionHistoryResponse, ) -> Option<String>

Extracts the next page URL from a transaction history response. Returns None if there are no more pages.

§Arguments
  • history - The transaction history response to extract from
§Returns
  • Some(url) - The URL for the next page, if available
  • None - If there are no more pages
§Examples
use sumup_rs::{SumUpClient, TransactionHistoryQuery};

let client = SumUpClient::new("your-api-key".to_string(), true)?;
let query = TransactionHistoryQuery {
    limit: Some(10),
    order: Some("desc"),
    newest_time: None,
    oldest_time: None,
};
let history = client.list_transactions_history("merchant123", &query).await?;

if let Some(next_url) = SumUpClient::get_next_page_url_from_history(&history) {
    println!("Next page available at: {}", next_url);
} else {
    println!("No more pages available");
}
Source

pub fn get_previous_page_url_from_history( history: &TransactionHistoryResponse, ) -> Option<String>

Extracts the previous page URL from a transaction history response. Returns None if there is no previous page.

§Arguments
  • history - The transaction history response to extract from
§Returns
  • Some(url) - The URL for the previous page, if available
  • None - If there is no previous page
§Examples
use sumup_rs::{SumUpClient, TransactionHistoryQuery};

let client = SumUpClient::new("your-api-key".to_string(), true)?;
let query = TransactionHistoryQuery {
    limit: Some(10),
    order: Some("desc"),
    newest_time: None,
    oldest_time: None,
};
let history = client.list_transactions_history("merchant123", &query).await?;

if let Some(prev_url) = SumUpClient::get_previous_page_url_from_history(&history) {
    println!("Previous page available at: {}", prev_url);
} else {
    println!("No previous page available");
}
Source

pub fn has_next_page_from_history(history: &TransactionHistoryResponse) -> bool

Checks if there are more pages available in a transaction history response.

§Arguments
  • history - The transaction history response to check
§Returns
  • true - If there are more pages available
  • false - If this is the last page
§Examples
use sumup_rs::{SumUpClient, TransactionHistoryQuery};

let client = SumUpClient::new("your-api-key".to_string(), true)?;
let query = TransactionHistoryQuery {
    limit: Some(10),
    order: Some("desc"),
    newest_time: None,
    oldest_time: None,
};
let history = client.list_transactions_history("merchant123", &query).await?;

if SumUpClient::has_next_page_from_history(&history) {
    println!("More pages available");
} else {
    println!("This is the last page");
}
Source

pub async fn list_all_transactions_history( &self, merchant_code: &str, order: Option<&str>, max_pages: Option<usize>, ) -> Result<Vec<Transaction>>

Fetches all transactions for a merchant by automatically handling pagination. This is a convenience method that fetches all pages and combines the results.

§Arguments
  • merchant_code - The merchant’s unique code
  • order - Sort order (e.g., “asc”, “desc”)
  • max_pages - Maximum number of pages to fetch (None for unlimited)
§Returns
  • Vec<Transaction> - All transactions from all pages
§Examples
use sumup_rs::SumUpClient;

let client = SumUpClient::new("your-api-key".to_string(), true)?;

// Fetch all transactions (up to 5 pages to avoid overwhelming the API)
let all_transactions = client.list_all_transactions_history("merchant123", Some("desc"), Some(5)).await?;
println!("Fetched {} transactions", all_transactions.len());

// Fetch all transactions without page limit (use with caution)
let all_transactions = client.list_all_transactions_history("merchant123", Some("desc"), None).await?;
println!("Fetched {} transactions", all_transactions.len());
Source§

impl SumUpClient

Source

pub fn new(api_key: String, use_sandbox: bool) -> Result<Self>

Creates a new client for the SumUp API.

§Arguments
  • api_key - Your SumUp API key (or OAuth token).
  • use_sandbox - Set to true to use the sandbox environment.
Source

pub fn with_custom_url(api_key: String, base_url: String) -> Result<Self>

Creates a new client with a custom base URL.

§Arguments
  • api_key - Your SumUp API key (or OAuth token).
  • base_url - Custom base URL for the API.
Source

pub fn api_key(&self) -> &str

Get the current API key being used by the client.

Source

pub fn base_url(&self) -> &Url

Get the base URL being used by the client.

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,