AfterPay API
With the HTTP API for Request payment, you can start and check payments. Use the HTTP API when you want to send requests to DigiWallet from your shop or app and when the DigiWallet PHP SDK can not be used.
Payment in 3 steps:
- Start the payment via DigiWallet by calling an URL with all the payment details. If all consumer information is directly provided, DigiWallet will give you a transaction ID and process the AfterPay invoice immediately. If not, DigiWallet gives you a link to an information enrichment screen and a transaction ID. (Start API) ;
- If not all consumer information is provided in the initial request, the consumer can be redirected to the DigiWallet environment to provide the missing information (Enrichment) ;
- The status of the payment will be reported and the visitor will be returned to your site. You can check the status of the payment with the "Check API" (Check API) ;
For more information and terms contact our sales team at sales@targetmedia.eu.
Start API Request payment
Before starting the payment, you have to call the Start API. You will get a paymentlink and a transaction ID (for in your database).
Call the next URL with GET
or POST
:
https://transaction.digiwallet.nl/afterpay/start
With the following parameters (* = required):
Variable | Explanation | Example |
---|---|---|
ver* | API version, this is version 1 | 1 |
rtlo* | Shop ID (also known as subaccount or layoutcode) to which the payment has to be made | 93393 |
amount* | Amount in eurocents: Minimum 500 , Maximum 1000000 | 1000 |
reporturl |
Report URL: is called after payment (server-to-server), by means of a POST .
Check here if the payment was indeed completed and process the order further. This script is also invoked if the customer were to accidentally close the browser.
If parameters are sent:
|
https://www.myshop.nl /reportOrder |
returnurl* |
Return URL: this page is where your customer will be referred to after a (successful) payment. To this URL shall the transaction number in the variable trxid
be given.Example: https://www.myshop.nl/thankYouPage?trxid=30626804185492 |
https://www.myshop.nl /thankYouPage |
cancelurl |
Cancel URL: The URL where the visitor is sent to after cancelling the payment. |
https://www.myshop.nl /orderCancelled |
userip* | IP address of the customer. | 213.76.8.33 |
invoicelines* | JSON-encoded array of the various invoice lines of this invoice | See Invoice Lines |
billingstreet | Consumer billing street address | Dorpsstraat |
billinghousenumber | Consumer billing house number | 1 A2 |
billingpostalcode | Consumer billing postal code | 1234AB |
billingcity | Consumer billing city | Dorpstad |
billingpersonemail | Consumer billing personal email address | jan.klaas.modaal@voorbeeld.nl |
billingpersoninitials | Consumer billing initials | J.K. |
billingpersongender | Consumer billing gender | "M" or "F" |
billingpersonsurname | Consumer billing surname | Modaal |
billingcountrycode |
Consumer billing country code according to ISO 639-1 |
NLD |
billingpersonlanguagecode |
Consumer billing language code according to ISO 639-1 |
NLD |
billingpersonbirthdate | Consumer billing birth date in YYYY-MM-DD format | 1992-11-01 |
billingpersonphonenumber | Consumer billing phone number | 31612345678 |
shippingstreet | Consumer shipping street address | Dorpsstraat |
shippinghousenumber | Consumer shipping house number | 1 A2 |
shippingpostalcode | Consumer shipping postal code | 1234AB |
shippingcity | Consumer shipping city | Dorpstad |
shippingpersonemail | Consumer shipping personal email address | jan.klaas.modaal@voorbeeld.nl |
shippingpersoninitials | Consumer shipping initials | J.K. |
shippingpersongender | Consumer shipping gender | "M" or "F" |
shippingpersonsurname | Consumer shipping surname | Modaal |
shippingcountrycode |
Consumer shipping country code according to ISO 639-1 |
NLD |
shippingpersonlanguagecode |
Consumer shipping language code according to ISO 639-1 |
NLD |
shippingpersonbirthdate | Consumer shipping birth date in YYYY-MM-DD format | 1992-11-01 |
shippingpersonphonenumber | Consumer shipping phone number | 31612345678 |
test | Whether to use the test connection or not. | "1" or "0" |
If you provided all consumer information in the Start API call, the invoice will be immediately processed by AfterPay. This can result in either a "Captured" invoice or a "Rejected" invoice. In case an invoice is "Captured" the result looks like this:
resultcode
transactionumber
|status
Example
000000 12345|Captured
You can then save transactionumber
in your database.
In case an invoice gets "Rejected", the result looks like this:
resultcode
transactionumber
|status
|reason
Example
000000 12345|Rejected|Leeftijd is onder de 18 jaar
If you did not provide all consumer information in the Start API call, you will get the following result:
resultcode
transactionumber
|status
|enrichment-url
Example
000000 12345|Incomplete|https://pay.digiwallet.nl/consumer/afterpay/enrich/79895d484eac22asd32d83323089f4723347645728d41282de03ff34ffc27574
You can then save transactionumber
in your database and send the visitor to the enrichment-url
through a redirect.
Possible result codes:
Result code | Description |
---|---|
000000 | Payment is prepared |
DW_XE_0003 Validation failed, details: JSON-encoded array
|
One or more fields failed to validate, you can decode the JSON array for a detailed analysis. |
DW_IE_0001 Unknown internal error | Unknown internal error, mail to techsupport@targetmedia.eu to be sorted out |
Invoice Lines Order specification
For AfterPay, it is required to specify each item in the consumers order. The invoicelines
parameter covers this concept. It has to be passed as a JSON-encoded array consisting of the following array structure (pseudocode):
[
0 => [
'productCode' => '0001-TEST',
'productDescription' => 'Test Object 1',
'quantity' => 1,
'price' => 10.00,
'taxCategory' => 1,
],
1 => [
'productCode' => '0002-TEST',
'productDescription' => 'Test Object 2',
'quantity' => 2,
'price' => 15.00,
'taxCategory' => 1,
],
]
As seen above, every element of the array represents an item in the order; amounts are indicated via the quantity key.
Explanation of invoicelines keys:
Key | Explanation | Example |
---|---|---|
productCode* | Webshop internal product code, free text input | 0001-TEST |
productDescription* | Description of the product, free text input | Test Object 1 |
quantity* | Quantity of this product in the order, integer | 1 |
price* | (Total, after quantity) price of this product in the order, including VAT (see below), decimal | 10.00 |
taxCategory* |
What kind of VAT applies to this product in the order, options:
|
1 |
Enrichment Consumer information
The enrichment page is a form on DigiWallet where the consumer can review their order and provide required information that is missing. The consumer cannot adjust any information that is provided to the Start API call, they will only be shown fields where the information is missing.
Once the form is submitted, the completed invoice will immediately be offered to AfterPay. The consumer will then be shown a screen with the result; the invoice will either be Captured or Rejected. In case the invoice is Rejected, the consumer will be shown the reason why. Afterwards the consumer is led back to the returnurl
.
Check API Request payment status
Based on the transaction number you can check if the payment is actually made. After payment, the report URL underwater is invoked by the DigiWallet server. It also mentions the payment status, but for safety reasons we strongly recommend to always ask the status from DigiWallet.
Invoke the following URL with a GET
or POST
:
https://transaction.digiwallet.nl/afterpay/check
The following parameters (* = required):
Variable | Explanation | Example |
---|---|---|
rtlo* | Shop ID (layoutcode) | 93393 |
trxid* | Transaction number | 30626804185492 |
If the invoice is successfully captured, you will receive as answer :
000000
invoiceKey
|invoicePaymentReference
|status
Example
000000
8f33ac0f15ab7793b273708ae408c8fb7e2asda58fd12f891ac2b4b7a6c915013
|AFP-0000012345
|Captured
If the invoice is still lacking consumer information, you will receive as answer :
000000
invoiceKey
|invoicePaymentReference
|status
|enrichmentURL
Example
000000
8f33ac0f15ab7793b273708ae408c8fb7e2asda58fd12f891ac2b4b7a6c915013
|AFP-0000012345
|Incomplete
|https://pay.digiwallet.nl/consumer/afterpay/enrich/8f33ac0f15ab7793b273708ae408c8fb7e2asda58fd12f891ac2b4b7a6c915013
If the invoice has been rejected by AfterPay, you will receive as answer :
000000
invoiceKey
|invoicePaymentReference
|status
|rejectionReason
|rejectionMessages
Example
000000
8f33ac0f15ab7793b273708ae408c8fb7e2asda58fd12f891ac2b4b7a6c915013
|AFP-0000012345
|Rejected
|Leeftijd is onder de 18 jaar
|[{"message":"De consument is onder 18 jaar oud","description":"Het spijt ons u te moeten mededelen dat uw aanvraag om uw bestelling achteraf \n te betalen niet door AfterPay wordt geaccepteerd. This is because your age is under 18. If you \n want to use the AfterPay Open Invoice service, your age has to be 18 years or older.\n Voor vragen over uw afwijzing kunt u contact opnemen met de Klantenservice van AfterPay. Of \n kijk op de website van AfterPay.\n Wij adviseren u voor een andere betaalmethode te kiezen om alsnog de betaling van uw bestelling \n af te ronden."}]
If the call to the Check API failed :
Error code | Description |
---|---|
DW_XE_0003 Validation failed, details: JSON-encoded array
|
One or more fields failed to validate, you can decode the JSON array for a detailed analysis. |
DW_IE_0001 Unknown internal error | Unknown internal error, mail to techsupport@targetmedia.eu to be sorted out |
Available in plugins
This payment method is supported in the following plugins: