Next Commerce

Swish Admin API Guide

Swish is a fully integrated payment method through NEXT Payments, supported in the storefront checkout and through the Admin API.

Swish transactions send the customer through a hosted payment flow, with the resulting order information returned to your application. Before using Swish, make sure it is enabled for the NEXT Payments account and store. Swish is available for eligible Swedish checkout traffic in SEK.

API Payment Redirect Flow

Below is a high-level overview of the user flow when creating orders on the Admin API that utilize the payment method redirect flow.

Create Order on Admin API

When creating an order with the orders_create API method, specify payment_method=swish and provide a payment_return_url. The payment_return_url is your endpoint that receives a POST request containing the final order data.

Payment Details for Order with Swish
{
    "payment_method": "swish",
    "payment_details": {
        "payment_return_url": "<external checkout url>",
        "payment_gateway": "<gateway id>", // optional
        "payment_gateway_group": "<gateway group id>" // optional
    }
}

You can optionally provide a payment_gateway or payment_gateway_group to route the order through a specific eligible NEXT Payments configuration.

Redirect Customer to Swish

The order response provides a payment_complete_url. Redirect the customer to this URL to complete the payment with Swish.

Response with Payment Complete URL
{
    "reference_transaction_id": null,
    "payment_complete_url": "<unique checkout url>"
}

Receiving Order Data

After the customer has completed their payment, they will be redirected to your application with a POST request containing data in the response key comprising all of the order information as a string. See examples below.

Order data structure follows Admin Order API and is application/x-www-form-urlencoded in a variable called response. If the order data is an empty dictionary , it means payment collection was unsuccessful and the order was not created.

Example Parsing of Order Data
import json

def order_receiver_view(request):
    data = json.loads(request.POST.get("response"))
    ...
    return HttpResponse(status=201)

Upsells

One-click post-purchase upsells are not supported with Swish payments.

Recurring

Swish cannot be used as the payment method for subscription items.

On this page