This site requires javascript to be enabled.

Trustly

Results for

Results for Searching

Integration

Before you begin

To follow along with this guide, please ensure that you have the following ready:

Using MyCheckout hosted payment pages

  1. Make a POST /v1/{merchantId}/hostedcheckouts API call.
  2. Create the order object containing the following properties:
  • amountOfMoney, including amount and currencyCode
  • customer, including merchantCustomerId, billingAddress, and contactDetails
  • billingAddress including countryCode 
  • contactDetails including emailAddress 
  • references

Additionally, you can add hostedCheckoutSpecificInput object, featuring variant and locale properties:

  • variant - the created styling of the checkout page tailored to your consumer's preferences
  • locale - the language, that will be used for your hosted checkout page

The below example allows the consumer to select a payment product on our hosted payment page and be redirected to the next page, where they select the bank with which they want to pay.

POST HOSTEDCHECKOUTS REQUEST

    {
	"order": {
		"amountOfMoney": {
			"currencyCode": "EUR",
			"amount": "100"
		},
		"customer": {
			"merchantCustomerId": "1234",
			"billingAddress": {
				"countryCode": "NL"
			}
		},
		"hostedCheckoutSpecificInput": {
			"variant": "testVariant",
			"locale": "en_GB"
		}
	}
}
POST HOSTEDCHECKOUTS RESPONSE

{
   "RETURNMAC" : "8b86bada-ebf8-4ad2-ac64-e5956a141690",
   "hostedCheckoutId" : "06571c62-b6e1-71ff-900d-dda9bb899e64",
   "merchantReference" : "references",
   "partialRedirectUrl" : "pay1.preprod.checkout.worldline-solutions.com/checkout/9991-0fb6755f00ac4064b85ca105bde20d0a:06605658-14a6-71ff-93d1-f43298dbb339:06d234ee7dae4930ba4c6331ac231aa3"
}

From the response, the important properties are:

  • hostedCheckoutId – can be used in subsequent API calls to retrieve the transaction details, such as GET/v1/{merchantId}/hostedcheckouts/{hostedCheckoutId}
  • partialRedirectUrl – is used to create the URL to which the customer needs to be redirected. By default, we configure every account with the subdomain payment, so you can always connect https://payment. with the partialRedirectUrl, for example:

https://payment.pay1.preprod.checkout.worldline-solutions.com/checkout/9991-0fb6755f00ac4064b85ca105bde20d0a:06605658-14a6-71ff-93d1-f43298dbb339:06d234ee7dae4930ba4c6331ac231aa3

For more information on customizing the MyCheckout hosted payment pages, please refer to our detailed guide.

The hostedCheckoutId is only valid for 2 hours, please ensure to store the createdPaymentOutput.payment.id from the GET /v1/{merchantId}/hostedcheckouts/{hostedCheckoutId} response to be able to retrieve data after 2 hours have elapsed via the GET /v1/{merchantId}/payments/{paymentId} API call. Alternatively, we can also optionally send a webhook event that will contain it.

Using your own checkout page

You can build a direct integration using our SDKs (or integrate our API from scratch). Depending on your integration needs, there are several options available.

Client encryption

Our Client API allows you to perform various actions. All you need is to be able to create a session via the POST/v1/{merchantId}/sessions API call, which will grant you access to the Client API. It's highly recommended that you use our Client SDKs.

We also have reference implementations showing how to use these SDKs on GitHub

Non-encrypted data

If you wish to do a direct server-to-server API call, go for this option. The difference with the other options mentioned before is that you don't need to submit the encryptedCustomerInput property. After the consumer selects the payment product, you need to perform the following:

  1. Make a POST /v1/{merchantId}/payments API call.
  2. Create the order object containing the following properties:
  • amountOfMoney, including amount and currencyCode
  • customer, including merchantCustomerId, billingAddress and contactDetails
  • billingAddress, including countryCode
  • contractDetails, including emailAddress
  • references
  1. Create redirectPaymentMethodSpecificInput object containing the following properties:
  • paymentProductId
  • paymentProduct806SpecificInput, including integrationType
  • redirectionData, including returnUrl
POST PAYMENTS REQUEST

    {
  "order": {
    "amountOfMoney": {
      "currencyCode": "EUR",
      "amount": "100"
    },
    "customer": {
      "merchantCustomerId": "1234",
      "personalInformation": {
        "name": {
          "firstName": "Johan",
          "surname": "Cruijff"
        }
      },
      "billingAddress": {
        "countryCode": "NL"
      },
      "contactDetails": {
        "emailAddress": "test@test.com"
      }
    }
  },
  "redirectPaymentMethodSpecificInput": {
    "paymentProductId": "806",
    "paymentProduct806SpecificInput": {
      "integrationType": "link"
    },
    "redirectionData": {
      "returnUrl": "https://www.example.com"
    }
  }
}

Customer redirection

If you use POST /v1/{merchantId}/payments API call, you also need to take care of the customer redirection (in the case of POST /v1/{merchantId}/hostedcheckouts, we handle it ourselves). We'll return a merchantAction object. While there are several different actionType values, for Trustly transactions, we consistently return the actionType value as REDIRECT.

Along with this, a redirectData object is included, containing a redirectURL. You'll need to direct your consumer to this URL to complete their payment.

Be aware that the merchantAction is only returned in the response to POST /v1/{merchantId}/payments and looks like this:

POST PAYMENTS RESPONSE

    {
   "creationOutput" : {
      "additionalReference" : "00000880050000041139",
      "externalReference" : "000008800500000411390000100001"
   },
   "merchantAction" : {
      "actionType" : "REDIRECT",
      "redirectData" : {
         "RETURNMAC" : "775a1acc74584ab48a9d5b86abd30af5",
         "redirectURL" : "https://orb.gc.sandbox.gi.worldline-solutions.com/orb/orb?ACTION=DO_START&REF=000008800500000411390000100001&MAC=3c9bec1c84e54a48916a48f9b243ec46"
      },
      "showData" : [ ]
   },
   "payment" : {
      "id" : "000008800500000411390000100001",
      "paymentOutput" : {
         "amountOfMoney" : {
            "amount" : 100,
            "currencyCode" : "EUR"
         },
         "references" : {
            "paymentReference" : "170108503200"
         },
         "paymentMethod" : "redirect",
         "redirectPaymentMethodSpecificOutput" : {
            "paymentProductId" : 806
         }
      },
      "status" : "REDIRECTED",
      "statusOutput" : {
         "isCancellable" : true,
         "isRetriable" : false,
         "statusCategory" : "PENDING_PAYMENT",
         "statusCode" : 20,
         "statusCodeChangeDateTime" : "20231207161608",
         "isAuthorized" : false,
         "isRefundable" : false
      }
   }
}

The merchantAction is omitted from the GET /v1/{merchantId}/payments/{paymentId} API call and will return a response like this:

GET PAYMENTS RESPONSE

    {
   "id" : "000008800510000122030000100001",
   "hostedCheckoutSpecificOutput" : {
      "hostedCheckoutId" : "06571bcb-b4e1-71ff-ba29-c5fc950f0864",
      "variant" : "138"
   },
   "paymentOutput" : {
      "amountOfMoney" : {
         "amount" : 100,
         "currencyCode" : "EUR"
      },
      "references" : {
         "merchantReference" : "qiciS",
         "paymentReference" : "T88500048N8A"
      },
      "paymentMethod" : "redirect",
      "redirectPaymentMethodSpecificOutput" : {
         "paymentProductId" : 806,
         "bankAccountIban" : {
            "accountHolderName" : "Iman Prijs",
            "iban" : "************311251"
         },
         "paymentProduct806SpecificOutput" : {
            "billingAddress" : {
               "city" : "Cuijk",
               "street" : "Toermalijnlaan 106",
               "zip" : "5431 ZK"
            },
            "customerAccount" : {
               "accountLastDigits" : "311251",
               "bankName" : "Rabobank",
               "clearinghouse" : "NETHERLANDS"
            }
         }
      }
   },
   "status" : "CAPTURED",
   "statusOutput" : {
      "isCancellable" : false,
      "isRetriable" : false,
      "statusCategory" : "COMPLETED",
      "statusCode" : 900,
      "statusCodeChangeDateTime" : "20231207134500",
      "isAuthorized" : true,
      "isRefundable" : false
   }
}

Cancellations

To cancel payment, you need to send cancellation with POST /v1/{merchantId}/payments/{paymentId}/cancel API call. The request doesn't have a body. The cancellation can only be performed when the status is PENDING_APPROVAL and statusOutput.isCancellable is true.

Refund

To start a refund process, you should use the API call POST /v1/{merchantId}/payments/{paymentId}/refund. This action is only applicable if the payment status is PAID. If you wish to refund the full order amount, you can do so by sending a request using the same API call, but with an empty body. 

A basic refund payload only requires the amountOfMoney object specifying the amount and currencyCode:

GET PAYMENTS RESPONSE

    {
    "amountOfMoney": {
        "amount": 25,
        "currencyCode": "SEK"
    }
}

You have the option to refund a part of the funds as well. For this, it's necessary to include a payload with the amountOfMoney object, where you specify the amount and the currencyCode. Additionally, if you want to view the details of your refund, you can use the API call GET /v1/{merchantId}/refunds/{refundId}.

Pre-authorization for refunds

The pre-authorization feature allows you to choose when to capture refunds. This option is possible with the configured REFUNDACCEPTNEEDEDINDICATOR, that was set for you during the boarding process. Thus, when you send a POST/v1/{merchantId}/payments/{paymentId}/refund API call, you'll receive a response like this:

POST PAYMENTS REFUND RESPONSE

    {
   "id" : "00000880051000012387000-100001",
   "refundOutput" : {
      "amountOfMoney" : {
         "amount" : 100,
         "currencyCode" : "DKK"
      },
      "references" : {
         "paymentReference" : "T8850004DV2A"
      },
      "paymentMethod" : "redirect",
      "eWalletRefundMethodSpecificOutput" : {
         "refundProductId" : 806,
         "totalAmountPaid" : 100,
         "totalAmountRefunded" : 0
      }
   },
   "status" : "PENDING_APPROVAL",
   "statusOutput" : {
      "isCancellable" : true,
      "statusCategory" : "PENDING_MERCHANT",
      "statusCode" : 600,
      "statusCodeChangeDateTime" : "20231220150231"
   }
}

To authorize us to proceed with the capture, you must send your approval using POST /v1/{merchantId}/refunds/{refundId}/approve. The same API call can also be used to adjust the capture amount. To set a specific amount, submit the amount property in your API call, ensuring it's less than the initially authorized amount. The structure for the payload should be as follows:

POST REFUNDS REQUEST

    {
    "amount": 50
}

To initiate a cancellation, you need to send a request using the API call POST /v1/{merchantId}/refunds/{refundId}/cancel. Note that this request does not require a body.

Next Process flows