Charge
Introduction
Charges a specific AccountID using direct debit. A previously approved direct debit mandate must exist on the AccountID (see SelectAccount for details).
Request parameters
Parameter name | Description | Req. | Type | Example |
---|---|---|---|---|
Username | The username. | Yes | Text | joe |
Password | The password. | Yes | Text | secret |
AccountID | The AccountID received from an account notification which shall be charged. | Yes | Text | 1234567890 |
NotificationURL | The URL to which notifications for this payment should be sent to. This URL should be hard to guess and not contain a ? ("question mark"). | Yes | Text | https://example.com/trustly/ notification/a2b63j23dj23883jhfhfh |
EndUserID | ID, username, hash or anything uniquely identifying the end-user being charged. Preferably the same ID/username as used in the merchant's own backoffice in order to simplify for the merchant's support department. | Yes | Text | 123123 |
MessageID | Your unique ID for the charge. | Yes | Text | 12345678 |
Amount | The amount to charge. See format in Currencies Only digits. Use dot (.) as decimal separator. | Yes | Text | 98.02 |
Currency | The currency of the amount to charge. | Yes | Char(3) | SEK |
Attributes | Attributes for this method. | Yes | Hash | {"ShopperStatement":"Flowers"} |
Attributes
Attribute name | Description | Req. | Type | Example |
---|---|---|---|---|
ShopperStatement | The text to show on the end-user's bank statement as well as in end-user e-mail communication. On the bank statement, only the first seven characters (along with Trustly's reference) will be shown. Allowed characters: A-Z (both upper and lower case), 0-9, ".", "-", "_", " " (dot, dash, underscore, space). | Yes | Text | Shopperstatement: "Sport Shop". Will result in "T Sport S xyz" in bank statement and "Sport Shop" in e-mails. |
The email address of the end user. | Yes | Text | [email protected] | |
PaymentDate | The date when the funds will be charged from the end user's bank account. If this attribute is not sent, the charge will be attempted as soon as possible. | No | Text | 2019-06-25 |
ExternalReference | The ExternalReference is a reference set by the merchant for any purpose and does not need to be unique for every API call. For example, it can be used for invoice references, OCR numbers and also for offering end users the option to part-pay an invoice using the same ExternalReference. The ExternalReference will be included in version 1.2 of the settlement report, ViewAutomaticSettlementDetailsCSV. | No | Text | 32423534523 |
PSPMerchant | Human-readable identifier of the consumer-facing merchant (e.g. legal name or trade name) | Yes* | Text | Merchant Ltd. |
PSPMerchantURL | URL of the consumer-facing website where the order is initiated | Yes* | Text | www.merchant.com |
MerchantCategoryCode | VISA category codes describing the merchant's nature of business. | Yes* | Text | 5499 |
* 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.
The returned result is a hash with the following elements:
Hash key | Description | Type | Example |
---|---|---|---|
result | 1 if the charge was accepted for processing, 0 otherwise. Note that this is an acceptance of the order, no money has been charged from the account until you receive notifications thereof. | Boolean | 1 |
orderid | The globally unique OrderID the charge order was assigned in our system, or null if the charge was not accepted. The order has no end-user interaction; it is merely used as a reference for the notifications delivered regarding the charge. See section "Notifications" below for details. | BigInt | 7653345737 |
rejected | If the charge was NOT accepted, a textual code describing the rejection reason, null otherwise. The possible rejected codes are: ERROR_MANDATE_NOT_FOUND - the AccountID does not have an active mandate ERROR_DIRECT_DEBIT_NOT_ALLOWED - Trustly Direct Debit is not enabled on the merchant's account in Trustly's system. ERROR_ACCOUNT_NOT_FOUND - the specified AccountID does not exist. | Text | ERROR_MANDATE_NOT_FOUND |
Code example
{
"method":"Charge",
"params":{
"Signature":"f4ThjuMqbsdG6u ... S16VbzD4h==",
"UUID":"258a2184-2842-b485-25ca-293525152425",
"Data":{
"AccountID":"1234567890",
"Amount":"25.00",
"Attributes":{
"Email":"[email protected]",
"ShopperStatement":"Trustly"
},
"Currency":"SEK",
"EndUserID":12345,
"MessageID":"your_unique_deposit_id",
"NotificationURL":"https://URL_to_your_notification_service",
"Password":"merchant_password",
"Username":"merchant_username"
}
},
"version":"1.1"
}
{
"method": "Charge",
"params": {
"Signature": "f4ThjuMqbsdG6u ... S16VbzD4h==",
"UUID": "258a2184-2842-b485-25ca-293525152425",
"Data": {
"AccountID": "1234567890",
"Amount": "25.00",
"Attributes": {
"PSPMerchant": "merchant_name",
"PSPMerchantURL": "https://merchantURL.com/",
"MerchantCategoryCode": "1234",
"Email": "[email protected]",
"ShopperStatement": "Trustly"
},
"Currency": "SEK",
"EndUserID": 12345,
"MessageID": "your_unique_transaction_id",
"NotificationURL": "https://URL_to_your_notification_service",
"Password": "merchant_password",
"Username": "merchant_username"
}
},
"version": "1.1"
}
{
"method":"Charge",
"uuid":"258a2184-2842-b485-25ca-293525152425",
"data":{
"result":"1",
"rejected":null,
"orderid":"1234512345"
},
"signature":"QBuLx ... JDGM/GVq5EBaPnGmvxA=="
}
Notifications
The notifications delivered for Charge orders are as follows:
- Immediately after the Charge has been accepted for processing, a pending notification is sent.
- If the Charge could not be processed, a cancel notification is sent.
- Once the Charge has been successfully processed, a credit notification is sent.
Updated over 1 year ago