Sumup.Checkouts (Sumup v1.0.0)

Copy Markdown View Source

Checkouts: create a payment intent, then process it with a card, saved token, or an alternative payment method (Boleto, iDEAL, Bancontact, Blik, Google Pay, Apple Pay). API version v0.1 (v0.2 for Apple Pay sessions).

A process/3 call can come back three ways:

  • {:ok, %Sumup.Checkout{status: :paid}} — synchronous success
  • {:ok, %Sumup.Checkout{next_step: %{...}}} — an async bank-redirect APM (iDEAL, Bancontact, Blik...) that needs the payer to be redirected to next_step.url before the checkout completes; poll get/2 or listen for the corresponding webhook afterwards
  • {:error, %Sumup.Error{}} — validation or processing failure

Summary

Functions

Creates a checkout.

Creates an Apple Pay merchant validation session for a checkout (API version v0.2). context and target come from Apple's onvalidatemerchant callback in-browser.

Deactivates (cancels) a pending checkout.

Finds checkouts by your own checkout_reference.

Retrieves a checkout by id.

Lists the payment methods available to a merchant, optionally narrowed down by an amount/currency pair (some methods have amount limits).

Processes (pays) a checkout with the given payment details.

Functions

create(config, params)

@spec create(Sumup.Config.t(), keyword() | map()) ::
  {:ok, Sumup.Checkout.t()} | {:error, Sumup.Error.t()}

Creates a checkout.

  • :checkout_reference (String.t/0) - Required. Your own idempotency reference for this checkout.

  • :amount - Required. Major-unit amount, e.g. 10.50.

  • :currency - Required. ISO 4217 currency code SumUp settles in.

  • :merchant_code (String.t/0) - Required. Your SumUp merchant code.

  • :description (String.t/0) - Shown to the payer.

  • :return_url (String.t/0) - Server-side callback for async APM completion.

  • :redirect_url (String.t/0) - Where to send the payer's browser after a hosted/APM flow completes.

  • :customer_id (String.t/0) - Associates the checkout with an existing Sumup.Customer.

  • :purpose - "CHECKOUT" (default) or "SETUP_RECURRING_PAYMENT" to only tokenize a payment method.

  • :valid_until (String.t/0) - ISO 8601 timestamp after which the checkout expires.

  • :hosted_checkout (map/0) - %{enabled: true} to get back a hosted_checkout_url for a SumUp-hosted payment page.

create_apple_pay_session(config, checkout_id, context, target)

@spec create_apple_pay_session(Sumup.Config.t(), String.t(), String.t(), String.t()) ::
  {:ok, map()} | {:error, Sumup.Error.t()}

Creates an Apple Pay merchant validation session for a checkout (API version v0.2). context and target come from Apple's onvalidatemerchant callback in-browser.

deactivate(config, checkout_id)

@spec deactivate(Sumup.Config.t(), String.t()) ::
  {:ok, Sumup.Checkout.t()} | {:error, Sumup.Error.t()}

Deactivates (cancels) a pending checkout.

find_by_reference(config, checkout_reference)

@spec find_by_reference(Sumup.Config.t(), String.t()) ::
  {:ok, [Sumup.Checkout.t()]} | {:error, Sumup.Error.t()}

Finds checkouts by your own checkout_reference.

get(config, checkout_id)

@spec get(Sumup.Config.t(), String.t()) ::
  {:ok, Sumup.Checkout.t()} | {:error, Sumup.Error.t()}

Retrieves a checkout by id.

list_payment_methods(config, merchant_code, opts \\ [])

@spec list_payment_methods(Sumup.Config.t(), String.t(), keyword()) ::
  {:ok, [map()]} | {:error, Sumup.Error.t()}

Lists the payment methods available to a merchant, optionally narrowed down by an amount/currency pair (some methods have amount limits).

process(config, checkout_id, params)

@spec process(Sumup.Config.t(), String.t(), keyword() | map()) ::
  {:ok, Sumup.Checkout.t()} | {:error, Sumup.Error.t()}

Processes (pays) a checkout with the given payment details.

  • :payment_type - Required. One of ["card", "boleto", "ideal", "blik", "bancontact", "google_pay", "apple_pay"].

  • :token (String.t/0) - A saved Sumup.PaymentInstrument token, instead of raw card details.

  • :customer_id (String.t/0) - Required alongside token for some saved-instrument charges.

  • :installments (integer/0) - Number of installments, where supported.

  • :card (map/0) - %{name:, number:, expiry_month:, expiry_year:, cvv:, type:, zip_code:} for raw card payments (expiry_month as a zero-padded string, e.g. "09").

  • :google_pay (map/0) - Opaque Google Pay token payload.

  • :apple_pay (map/0) - Opaque Apple Pay token payload.

  • :mandate (map/0) - %{type: "recurrent", user_agent:, user_ip:} for recurring/saved-token charges.

  • :personal_details (map/0) - %{first_name:, last_name:, email:, phone:, birth_date:, tax_id:, address:}, required by several APMs (Boleto, iDEAL, ...).