Trustly
Accept Trustly payments in your online store.
Trustly is a popular payment solution that enables customers to make online payments directly from their bank accounts in Europe. It offers a secure and convenient payment experience without the need for a credit or debit card. Use the emerchantpay Trustly API to accept Trustly as a payment method across all of emerchantpay’s payment integrations.
Payment method | pay-ins and payouts for end customers |
---|---|
Bank transfer | Austria, Czech Republic, Denmark, Estonia, Finland, Germany, Latvia, Lithuania, Netherlands, Norway, Spain, Sweden, United Kingdom |
Prerequisites
To proceed with this solution, you must have an emerchantpay merchant account. Apply for a merchant account by filling out and submitting this contact form.
You will be assigned an emerchantpay Account Manager, who will provide you with credentials and assist you with any of emerchantpay’s payment solutions.1. Create a Trustly payment request
To submit a payment using Trustly, create a payment request to the emerchantpay Genesis payment gateway. Specify trustly_sale as thetransaction_type
.
<?xml version=”1.0″ encoding=”UTF-8″?>
<payment_transaction>
<transaction_type>trustly_sale</transaction_type>
<transaction_id>119643250547501c79d8295</transaction_id>
<payment_transaction>payment_type</payment_transaction>
<usage>40208 concert tickets</usage>
<remote_ip>245.253.2.12</remote_ip>
<notification_url>https://www.example.com/notification</notification_url>
<return_success_url>http://www.example.com/success</return_success_url>
<return_failure_url>http://www.example.com/failure</return_failure_url>
<return_success_url_target>self</return_success_url_target>
<amount>100</amount>
<currency>EUR</currency>
<customer_email>travis@example.com</customer_email>
<billing_address>
<first_name>Max</first_name>
<last_name>Mustermann</last_name>
<address1>Muster Str. 12</address1>
<zip_code>10178</zip_code>
<city>Berlin</city>
<country>DE</country>
</billing_address>
<business_attributes>
<event_start_date>23-03-2023</event_start_date>
<event_end_date>04-04-2023</event_end_date>
<event_organizer_id>20192375</event_organizer_id>
<event_id>1912</event_id>
</business_attributes>
<payment_transaction>user_id</payment_transaction>
<payment_transaction>account_id</payment_transaction>
</payment_transaction>
2. Receive a response
You will receive a Success or Error response to your payment request. Example of a Success response: <?xml version=”1.0″ encoding=”UTF-8″?>
<payment_response>
<transaction_type>trustly_sale</transaction_type>
<status>pending_async</status>
<mode>live</mode>
<transaction_id>119643250547501c79d8295</transaction_id>
<unique_id>44177a21403427eb96664a6d7e5d5d48</unique_id>
<technical_message>Transaction successful!</technical_message>
<message>Transaction successful!</message>
<redirect_url>https://staging.gate.emerchantpay.net/redirect/to_acquirer/649e1ff35c61</redirect_url>
<timestamp>2023-02-22T07:32:58Z</timestamp>
<descriptor>Descriptor one</descriptor>
<amount>100</amount>
<currency>EUR</currency>
<sent_to_acquirer>true</sent_to_acquirer>
</payment_response>
redirect_url
to redirect your customer to authorise the payment with Trustly. See the emerchantpay Trustly API for the complete list of Trustly response parameters and code samples.
Asynchronous notification
Because the Trustly payment transaction is asynchronous, the result of your customer’s payment is sent as a separate HTTP POST notification from the gateway to thenotification_url
that you supplied with the transaction request.
Example of a notification for a Trustly transaction:
:transaction_id=>”119643250547501…”,
:terminal_token=>”f6a34b886c07f409a8f6f0899e834b5…”,
:unique_id=>”efc8bf370da577670e2ca65e52…”,
:transaction_type=>”trustly_sale”,
:status=>”approved”,
:signature=>”8d895b2d231f86ee85cdff64dbfecec1931…”,
:amount=>10000
status
field provides you with information on the outcome of the transaction. See Transaction States for more information about transaction statuses.
Use the signature
field to verify that the notification has been sent by the Genesis gateway. Each session signature is generated by combining the unique_id
of the transaction and your API password, and generating a SHA-1 hash function of the combined string.
signature
= SHA-1 hash value of <unique_id><API password>
unique_id | API password | signature |
---|---|---|
26aa150ee68b1b2d6758a0e6c44fce4c | 50fd87e65eb415f42fb5af4c9cf497662e00b785 | c5219b3d385e74496b2b48a549 |
3f760162ef57a829011e5e2379b3fa17 | 50fd87e65eb415f42fb5af4c9cf497662e00b785 | 14519d0db2f7f8f407efccc9b099 |
After you have verified the notification state and validity, render an XML page containing the transaction’s unique id to acknowledge that you have received the notification.
Example of a notification reply you use to confirm a notification:<?xml version=”1.0″ encoding=”UTF-8″?>
<notification_echo>
<unique_id>3f760162ef57a829011e5e2379b3fa17</unique_id>
</notification_echo>
3. Test your integration
- Add an item to your cart in your online store.
- Proceed to the checkout page and check out using Trustly.
- Follow the redirect link in the response.
- In the payment simulator, follow the instructions to simulate a transaction.
- Complete the order and verify that you are redirected to the order confirmation page.
- Log in to Genesis.
- In the navigation menu, go to Payment transactions.
- Verify that the transaction appears at the top of the list and is successful.