Introduction

Initiates a new withdrawal returning the url where the end-user can complete the process.

You can find more information about how to display the Trustly URL here.

A typical withdrawal flow is:

  1. The merchant makes an API-call to Withdraw method and load the URL in an iframe for the end-user.
  2. The end-user selects the amount to withdraw and provides his/her bank account details.
  3. Trustly sends a debit notification to the merchant's system to deduct the specified withdrawal amount from the end-user's balance in the merchant's system. If the debit notification failed, the withdrawal is aborted and the end-user informed.
  4. If manual approval is required, Trustly does nothing with the withdrawal request until it has been approved or denied with ApproveWithdrawal / DenyWithdrawal .
  5. When approved, Trustly process the withdrawal request. If the withdrawal is denied, Trustly will send a credit notification and the withdrawal will not be processed.
  6. Please note that in case of a successful Withdrawal, no additional notification will be sent to the merchant's NotificationURL after the Withdrawal has been approved. But if the Withdrawal fails, a credit notification will be sent (see more details below under "Failed Withdrawals").

Request parameters

Parameter nameDescriptionRequiredTypeExample
UsernameThe username.YesTextjoe
PasswordThe password.YesTextsecret
NotificationURLThe URL to which notifications for this payment should be sent to. This URL should be hard to guess and not contain a ? ("question mark").YesTexthttps://www.joe.com/Trustly/
Notify/a2b63j23d
EndUserIDID, username, hash or anything uniquely identifying the end-user requesting the withdrawal. Preferably the same ID/username as used in the merchant's own backoffice in order to simplify for the merchant's support department.YesText123123
MessageIDYour unique ID for the withdrawal.YesText12345678
CurrencyThe currency of the end-user's account in the merchant's system.YesChar(3)SEK
AttributesOptional attributes for this method.YesHash{ "Locale": "sv_SE" }

The parameter Attributes is a hash of attributes. New attributes may be added in future versions of the API but existing attributes will never be removed.

Attributes

Attribute nameDescriptionRequiredTypeExample
FirstnameThe end-user's first name. Some banks require the recipients name.YesTextSteve
LastnameThe end-user's last name. Some banks require the recipients name.YesTextSmith
CountryThe ISO 3166-1-alpha-2 code of the end-user's country. This will be used for preselecting the correct country for the end-user in the iframe. Note: This will only have an effect for new end-users. If an end-user has done a previous order (with the same EndUserID), the country that was last used will be pre-selected.YesChar(2)SE
LocaleThe end-users localization preference in the format [language[_territory]]. Language is the ISO 639-1 code and territory the ISO 3166-1-alpha-2 code. This will be used to pre-select the language in the trustly iframe.YesTexten_US
ShopperStatementThe text to show on the end-user's bank statement after Trustly's own 10 digit reference (which always will be displayed first). The reference must let the end user identify the merchant based on this value. So the ShopperStatement should contain either your brand name, website name, or company name.If possible, try to keep this text as short as possible to maximise the chance that the full reference will fit into the reference field on the customer's bank since some banks allow only a limited number of characters. If the full ShopperStatement does not fit into the reference it will be truncated from the end.YesTextMyBrand.com
EmailThe email address of the end user.NoText[email protected]
DateOfBirthThe date of birth of the end user.NoText1990-01-20
SuggestedAmountSets a fixed withdrawal amount which cannot be changed by the end-user in the Trustly iframe. If this attribute is not sent, the end-user will be asked to select the withdrawal amount in the Trustly iframe. Do not use in combination with SuggestedMinAmount and SuggestedMaxAmount. Use dot (.) as decimal separator.NoText100.00
SuggestedMinAmountThe minimum amount the end-user is allowed to withdraw in the currency specified by Currency. Only digits. Use dot (.) as decimal separator.NoText5.00
SuggestedMaxAmountThe maximum amount the end-user is allowed to withdraw in the currency specified by Currency. Only digits. Use dot (.) as decimal separator.NoText500.00
IPThe IP-address of the end-user.NoText83.140.44.184
SuccessURLThe URL to which the end-user should be redirected after a successful withdrawal. Do not put any logic on that page since it's not guaranteed that the end-user will in fact visit it.NoTexthttps://trustly.com/
thank_you.html
FailURLThe URL to which the end-user should be redirected after a failed withdrawal. Do not put any logic on that page since it's not guaranteed that the end-user will in fact visit it.NoTexthttps://trustly.com/
payment_error.html
TemplateURLThe TemplateURL should be used if you want to design your own payment page but have it hosted on Trustly's side. The URL of your template page should be provided in this attribute in every Deposit API call.NoTexthttps://example.org/
withdraw_trustly.html
URLTargetThe html target/framename of the SuccessURL. Only _top, _self and _parent are suported.NoText_top
MobilePhoneThe mobile phone number to the end-user in international format. This is used for KYC and AML routines.NoText+46709876543
NationalIdentification
Number
The end-user's social security number / personal number / birth number / etc. Useful for some banks for identifying transactions and KYC/AML. If a Swedish personid ("personnummer") is provided, it will be pre-filled when the user logs in to their bank.NoText790131-1234
UnchangeableNational
IdentificationNumber
This attribute disables the possibility to change/type in national identification number when logging in to a Swedish bank. If this attribute is sent, the attribute NationalIdentificationNumber needs to be correctly included in the request. Note: This is only available for Swedish banks.NoNumeric1
AddressCountryThe ISO 3166-1-alpha-2 code of the address country. Required attribute for merchants who are sending physical goods to customers.NoChar(2)SE
AddressPostalcodePostal code of the end user.NoTextSE-11253
AddressCityCity of the end user.NoTextStockholm
AddressLine1Street address of the end user.NoTextMain street 1
AddressLine2Additional address information of the end user.NoTextApartment 123, 2 stairs up
AddressThe entire address of the end user. This attribute should only be used if you are unable to provide the address information in the 5 separate attributes above (AddressCountry, AddressPostalCode, AddressCity, AddressLine1 and AddressLine2).NoTextBirgerstreet 14, SE-11411 Stockholm, Sweden
URLSchemeIf you are using Trustly from within your native iOS app, this attribute should be sent so that we can redirect the users back to your app in case an external app is used for authentication (for example Mobile Bank ID in Sweden). The URLScheme can also be registered in Trustly's backend. Please reach out to your Trustly contact if you want us to configure a fixed URLScheme.NoTextyourCustomURLScheme://
ExternalReferenceThe ExternalReference is a reference set by the merchant for any purpose and does not need to be unique for every API call. The ExternalReference will be included in version 1.2 of the settlement report, ViewAutomaticSettlementDetailsCSV.NoText23423525234
PSPMerchantHuman-readable identifier of the consumer-facing merchant (e.g. legal name or trade name)Yes*TextMerchant Ltd.
PSPMerchantURLURL of the consumer-facing website where the order is initiatedYes*Textwww.merchant.com
MerchantCategoryCodeVISA category codes describing the merchant's nature of business.Yes*Text5499
SenderInformationInformation about the Payer (ultimate debtor). ** Mandatory for certain types of merchants and partners (see more information below).Yes**Object{"Firstname": "Steve"...}

🚧

* PSPMerchant, PSPMerchantURL and MerchantCategoryCode

PSPMerchant, PSPMerchantURL and MerchantCategoryCode** are mandatory attributes for Trustly Partners that are using Express Merchant Onboarding (EMO) and aggregate traffic under a master processing account.

🚧

** SenderInformation

SenderInformation{} is mandatory to send in Attributes{} for money transfer services (including remittance houses), e-wallets, prepaid cards, as well as for Trustly Partners that are using Express Merchant Onboarding and aggregate traffic under a master processing account (other cases may also apply).

SenderInformation attributes

The parameters to SenderInformation{} are:

NameDescriptionRequiredTypeExample
PartytypePartytype can be "PERSON" or "ORGANISATION" (if the ultimate debtor is an organization/company).YesTextPERSON
AddressThe Payer's addressYesTextStreet 1, 12345 Barcelona
CountryCodeThe ISO 3166-1-alpha-2 code of the Payer's country.YesChar(2)SE
FirstnameFirst name of the person (or the name of the organization)YesTextSteve
LastnameLast name of the person (empty for organization)YesTextSmith
CustomerIDPayment account number or an alternative consistent unique identifier which allows to identify the Payer in the system of the PSP of the Payer. Note: this is not a transaction ID or similar. This identifier must stay consistent across all transactions relating to this Payer.NoText123456789
DateOfBirthDate of birth for the person (YYYY-MM-DD) or organisational number for the organizationNoText1990-03-31

A complete schematic withdrawal example is:

Response

The result returned is a hash with the following elements:

Hash keyDescriptionTypeExample
orderidThe globally unique OrderID the withdrawal was assigned in our system.BigInt7653345
urlThe URL that should be loaded so that the end-user can complete the withdrawal.Texthttps://trustly.com/_/2f6b14fa-446a-4364-92f8-84b738d589ff

Code example

APIResult = TrustlyAPI({
  "method": "Withdraw",
  "params": {
    "Signature": "S9+hjuMqbsH0Ku ... S16VbzRsw==",
    "UUID": "258a2184-2842-b485-25ca-293525152425",
    "Data": {
      "Username": "merchant_username",
      "Password": "merchant_password",
      "NotificationURL": "https://URL\_to\_your\_notification\_service",
      "EndUserID": "12345",
      "MessageID": "your\_unique\_withdrawal_id",
      "Currency": "SEK",
      "Attributes": {
        "Country": "SE",
        "Locale": "sv_SE",
        "IP": "83.140.44.184",
        "MobilePhone": "+46709876543",
        "Firstname": "Steve",
        "Lastname": "Smith",
        "Email": "[email protected]",
        "DateOfBirth": "1990-01-20",
        "NationalIdentificationNumber": "790131-1234",
        "SuccessURL":"https://yourpage.com/success",
        "FailURL":"https://yourpage.com/fail",
        "AddressCountry": "SE",
        "AddressPostalCode": "SE-11253",
        "AddressCity": "Stockholm",
        "AddressLine1": "Main street 1"
      }
    }
  },
  "version": "1.1"
});

print( '<iframe src="' + APIResult.result.data.url + '"></iframe>' );
{
    "result": {
        "signature": "F7jhjuMqbsD4ju ... S16VbzdR1==",
        "uuid": "258a2184-2842-b485-25ca-293525152425",
        "method": "Withdraw",
        "data": {
            "orderid": "2190971587",
            "url": "https://trustly.com/_/2f6b14fa-446a-4364-92f8-
            84b738d589ff"
        }
    },
    "version": "1.1"
}

Failed withdrawals

In case an error occurs when processing the withdrawal, a credit notification will be sent to the provided NotificationURL so that the merchant can flag the withdrawal as failed in their system. And in case the end-user holds a balance on the merchant's system, the amount specified in the credit notification should be credited back to the end user's balance. Note that the credit notification will be sent AFTER the withdrawal has been successfully approved (either automatically or by sending ApproveWithdrawal .

There are 2 main reasons why a Withdrawal can fail after being approved:

  1. There are not enough funds on the merchant's Trustly account. In this case the credit notification will be sent immediately after the withdrawal has been approved.
  2. The funds are sent to the end user's bank account, but then later Trustly is notified by the bank that the transfer failed, for example if the recipient's bank account has been closed. This is usually very uncommon, but if it happens the credit notification can be sent several days after the Withdrawal has been approved.

In case something is wrong in the Withdrawal API call itself, you will receive a synchronous API error code. A list of the most common error codes can be found here.