paysafecard API
Getting started
To start using the paysafecard API you must meet the following requirements:
- Have an active Mollie partner ID: After you log in, you wil be able to see it on the Account page.
- Have an active payment profile.
- Have enabled the paysafecard service in your account. The requirements can be found on the Diensten page.
(Please note that the Diensten/Services page is currently only available in Dutch)
Examples & Modules
Download our ready-to-use example script here:
| Description | Programming language | Author | Version |
|---|---|---|---|
| PHP class | PHP 5.x and higher | Mollie | v1.0 |
How does the paysafecard API work?
To create a paysafecard payment you need to go follow these steps:
- Request a new payment from us, with your
partner_idand theamountin cents you want to receive from your customer. We return the payment details including the uniquetransaction_idandURLof the prepared payment. Please store this data in your own database. - Checking the status of the payment. The API gives you a report in the background at the specified
reporturlwhen the payment status changes. With this information, you can check the new status of your payment. - The customer returns on the returnurl. The customer is sent to the
returnurlafter the payment is complete, so he or she can continue the payment process in your website. Here, if you wish, you can show your customer what the latest payment status is. There is an overview of possible statuses later in this document.
Our API works with HTTP requests. Simply send us HTTP requests with the parameters as GET variables.
Step 1: Request a new payment with the paysafecard API
To prepare a new paysafecard payment you need to specify some parameters. In the table below you can find the parameters you need to create a new paysafecard payment. All parameters are required.
Example prepare request:
https://secure.mollie.nl/xml/paysafecard/prepare/?partnerid=[your partner id]&amount=123&profile_key=1a2b3c4d
&reporturl=http%3A%2F%2Fwww.yourwebsite.nl%2Freport.php
&returnurl=http%3A%2F%2Fwww.yourwebsite.nl%2Freturn.php
&customer_ref=client123-255-0-12
You can find the table with the request parameter explanations below:
| Parameter | Explanation |
|---|---|
partnerid |
Your Mollie Partner ID. You can find this on the account details page. The payment is linked to your account using your partner ID. |
profile_key |
Mollie Profile Key. You can find the profile_key of your profile on the Profielen page. You can also create a new profile on that page. |
amount |
Amount of the payment. GIVEN IN CENTS! So, if you want to receive EUR 10.00, please request like this: amount=1000. |
reporturl |
This is the URL payment notification reports will be sent to. These happen in the background and will be sent once the payment status changes. These don't provide information about the payment, like the paid status. You will have to ask for the updated status using the check-status API, as shown in Step 2. This is a security feature, so nobody else can call your reporturl with fake payment information. The payment noticication report will include the transaction_id of the payment, so you will be able to match it to a created payment. |
returnurl |
This URL is where your customers will be sent to after the payment (whether successful or not) has been completed. It is possible your customer will reach this page before you get the actual payment status. You can show the most current payment status on this page. We provide the transaction_id as GET variable so you can will be able to match the customer to a payment. |
customer_ref |
This parameter is a unique customer reference that you keep for the customer, for example by generating it with your customer's account ID or IP address. (You're not allowed to use capitals or spaces with this parameter) |
This is an example of how the answer would look like:
<?xml version="1.0"?>
<response>
<order>
<transaction_id>482d599bbcc7795727650330ad65fe9b </transaction_id>
<amount>123</amount>
<currency>EUR</currency>
<URL>https://customer.cc.at.paysafecard.com/psccustomer/GetCustomerPanelServlet?mid=1000002193&mtid=192C-50D3-C396-4E02-AD90-3701-0423&amount=1.23¤cy=EUR</URL>
</order>
</response>
The XML answer explained:
| Parameter | Explanation |
|---|---|
transaction_id |
This is the alphanumeric combination that corresponds to the payment you prepared. It is advised to save this ID with the payment in your database, so you can look for it in a report, or when your customer visits the returnurl. |
amount |
The amount like you requested it, just as a check |
URL |
This is the URL where you should redirect your customer to, so they can actually complete the prepared payment at paysafecard. |
Step 2: Checking the status of the payment
When you were preparing the payment, you also sent us the reporturl. At this URL you will need a script thats checks the payment status with us. This check gives you the current state of the payment. It is advised to save any status updates in your database.
- Notice: When the callback to the reporturl fails (like when the connection fails or the HTTP status is not 200), Mollie will request 10 times with different time intervals to the reporturl again. If it won't succeed you get an error notice in your error log at your Dashboard.
Example check-status request:
https://secure.mollie.nl/xml/paysafecard/check-status/?partnerid=[your partner id]&transaction_id=[transaction_id]
The parameters are explained below:
| Parameter | Explanation |
|---|---|
partnerid |
Your Mollie Partner ID. You can find this on the account details page. To this account we assign the payment. |
transaction_id |
This is the alphanumeric combination that corresponds to the payment you prepared. With it, you can request a status update about a particular payment. |
This is an example the answer would look like:
<?xml version="1.0"?>
<response>
<order>
<transaction_id>482d599bbcc7795727650330ad65fe9b</transaction_id>
<amount>123</amount>
<paid>true</paid>
<status>Completed</status>
</order>
</response>
For security reasons, once you receive a final status, you cannot check the status again. If you try to check for a second time, you will get a custom error code. The final statuses are 'Success', 'Cancelled' and 'Expired'.
The check-status parameters are explained below:
| Parameter | Explanation | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
transaction_id |
This is the alphanumeric combination that corresponds to the payment you prepared. It is advised to store this ID in your database, so you can use for it in a report, or to match a customer sent to the returnurl. | ||||||||||||
amount |
The amount like you requested it, just as a check. | ||||||||||||
paid |
'true' or 'false'. Gives your the paid status. Notice, you can only check the final status once. If you check a second time, you will get 'false'. This is to protect against fraud for your customers. | ||||||||||||
status
|
Gives you the exact status we get from paysafecard, if available. Possible statuses are:
|
Step 3: The customer returns on the returnurl
After the payment has been completed, the customer will be sent to the returnurl, provided when the payment was first made (step 1). A GET variable transaction_id, will have been added to this URL. This will allow you to match the customer to the payment. If you've already got the final state, you can show it here to your customer.
Exceptional situations
In rare situations, it may be possible your customer will reach the returnurl before we called the reporturl. This can happen when there is a failure with paysafecard that may delay us recieving the the final state of the payment.
In these situations, it's important to know that we only report you when we got the final state. So, it's possible your customer will reach the returnurl when the payment in still pending in your system.
Overview error codes
All the possible error codes that are returned by the API are listed below:
| Errorcode | Description |
|---|---|
| -1 | We've failed to create the payment due an unknown error |
| -2 | Missing parameter: [missing parameters will be here] |
| -3 | This account doesn't exist or is suspended |
| -4 | Invalid profile_key |
| -5 | Amount is too low. Minimal amount is [the minimal amount will be here] |
| -6 | Amount is too high. Maximum amount is [the maximum amount will be here] |
| -7 | There is a problem with the 'reporturl' you have provided: [your request url will be here] |
| -8 | There is a problem with the 'returnurl' you have provided: [your request url will be here] |
| -9 | Invalid type |
| -10 | Invalid transaction_id |
| -11 | Payments are disabled for this customer |
| -12 | Invalid customer_ref |
Other languages
On this page
- Getting started
- How does the API work?
- Step 1: Create a payment
- Step 2: Get payment status
- Step 3: Return to your shop
- Overview error codes
- Examples & Modules