Make a payment with a card entered by a customer
In this guide, you will learn how to make a single payment with a payment card entered by a customer without associating it with a specific customer saved for the merchant user's account. This type of payment is most useful for quick processing of payment checkouts in which you don't store and manage any account data for your customers.
You will go through the following steps:
When you complete these steps, you will have processed a payment with a payment card entered by a customer.
Before you begin
Here are the things that you need in order to complete the steps in this guide:
- You have a merchant account with SumUp and have already filled in your account details.
- For a test account reach out to our support team through this contact form.
- You have registered your client application with SumUp.
- You have a valid access token obtained via one of the supported OAuth2 authorization flow, the Authorization code flow or Client credentials flow.
Steps
1. Create a checkout
To create a new checkout resource, make a POST request to the https://api.sumup.com/v0.1/checkouts
endpoint.
The request body should be a JSON object with the following minimum details:
Attribute name | Description |
---|---|
checkout_reference | A unique string identifying the payment in your system. It must be unique for your application. |
amount | The amount for which the payment is made. |
currency | The three-letter ISO4217 code of the currency in which the payment is made. The value must match the currency registered for the merchant user to whom the payment is made (as specified in pay_to_email ). |
pay_to_email | The email address of the registered merchant user to whom the payment is made. |
Following is a sample request for creating a new checkout resource:
curl -X POST \
https://api.sumup.com/v0.1/checkouts \
-H 'Authorization: Bearer $SUMUP_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"checkout_reference": "CO746453",
"amount": 10,
"currency": "EUR",
"pay_to_email": "[email protected]",
"description": "Sample one-time payment"
}'
ctx := context.Background()
client := sumup.NewClient().WithAuth(os.Getenv("SUMUP_API_KEY"))
checkout, err := client.Checkouts.Create(ctx, sumup.CreateCheckoutBody{
Amount: 19,
CheckoutReference: "CO746453",
Currency: "EUR",
MerchantCode: "MK0001",
})
$checkoutsService = $sumup->getCheckoutService();
$response = $checkoutsService->create(10, 'EUR', 'CO746453', '[email protected]', 'Sample one-time payment');
$checkoutId = $response->getBody()->id;
The response contains a JSON body with the details of the created checkout resource. What you need to note in the response is the identifier of the resource - you will need it for all operations that you perform with the resource, such as completing it in the next step.
The resource identifier is returned in the id
attribute, or f14425c6-8bc1-4d02-957c-47573f762828
in the sample response below. The status
attribute shows that the payment for this resource is pending and will be processed when you complete the checkout with the payment instrument details.
{
"checkout_reference": "CO746453",
"amount": 10,
"currency": "EUR",
"pay_to_email": "[email protected]",
"description": "Sample one-time payment",
"id": "f14425c6-8bc1-4d02-957c-47573f762828",
"status": "PENDING",
"date": "2018-09-28T13:47:01.832Z",
"transactions": []
}
2. Complete a checkout
To complete the checkout and trigger the payment, make a PUT request to the https://api.sumup.com/v0.1/checkouts/{id}
endpoint, where the value of the {id}
path parameter is the identifier of the checkout resource.
The request body should be a JSON object with the payment type (card
) and the payment card details. For more information about the request, see the API Reference.
Following is a sample request for completing the checkout from Step 1:
curl -X PUT \
https://api.sumup.com/v0.1/checkouts/f14425c6-8bc1-4d02-957c-47573f762828 \
-H 'Authorization: Bearer $SUMUP_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"payment_type": "card",
"card": {
"name": "Boaty McBoatface",
"number": "4200000000000042",
"expiry_month": "12",
"expiry_year": "23",
"cvv": "123"
}
}
ctx := context.Background()
client := sumup.NewClient().WithAuth(os.Getenv("SUMUP_API_KEY"))
checkoutSuccess, err := client.Checkouts.Process(ctx, "f14425c6-8bc1-4d02-957c-47573f762828", sumup.ProcessCheckoutBody{
Card: &sumup.Card{
Cvv: "123",
ExpiryMonth: "12",
ExpiryYear: "23",
Name: "Boaty McBoatface",
Number: "4200000000000042",
},
PaymentType: sumup.ProcessCheckoutBodyPaymentTypeCard,
})
The response contains a JSON body with the details of the processed checkout resource in which the attributes related to the payment outcome are populated:
{
"checkout_reference": "CO746453",
"amount": 10.0,
"currency": "EUR",
"pay_to_email": "[email protected]",
"description": "Sample one-time payment",
"id": "f14425c6-8bc1-4d02-957c-47573f762828",
"status": "PAID",
"date": "2018-09-28T13:47:01.832Z",
"transaction_code": "TFDCP3FLQ7",
"transaction_id": "19aa3cca-89f6-42d2-b462-463b0b53e959",
"transactions": [
{
"id": "19aa3cca-89f6-42d2-b462-463b0b53e959",
"transaction_code": "TFDCP3FLQ7",
"merchant_code": "ME7RMQN3",
"amount": 10.0,
"vat_amount": 0.0,
"tip_amount": 0.0,
"currency": "EUR",
"timestamp": "2018-09-28T13:48:28.768Z",
"status": "SUCCESSFUL",
"payment_type": "ECOM",
"entry_mode": "CUSTOMER_ENTRY",
"installments_count": 1,
"auth_code": "585388",
"internal_id": 24118507
}
]
}
Result
You have made a payment with a payment card entered by a customer without associating it with a specific customer saved for a merchant user's account. If the payment is successful, the funds will be transferred to the merchant user according to the configured account settings.