Step 5: Analyze the payment result
Objective
Analyzing the payment result:
Via the IPN (Instant Payment Notification), during a server-to-server call.
Via the return to the shop, during the browser return.
I. Response structure
PARAMETER | Description |
---|---|
kr-hash-key | Type of key to sign thekr-answer . The possible values are:password for the IPN /sha256_hmac for the return to shop. |
kr-hash-algorithm | Algorithm used to calculate the hash. Its value is sha256_hmac. |
kr-answer | Object containing the payment result, encoded in JSON. |
kr-answer-type | Type the JSON object stored in kr-answer. |
kr-hash | Hash of the JSON object stored in kr-answer. It allows to verify the authenticity of the response. |
- Go to the REST API Keys tab, from the Settings > Shop to retrieve your keys.
II. Analyze the IPN (Instant Payment Notification)
It is imperative to retrieve and analyze the IPN payment data.
- Retrieve the JSON from the IPN (IPN settings )
- Check the authenticity of the notification with the value of kr-hash ( 2nd key of the REST API key table )
- Check the payment status
More info: NPI Analysis (notification URL).
III. Analyze the response when returning to the shop
In the HEAD
, implement the kr-post-url-success initialization parameter to receive the payment result in case of successful payment (Step 4: Display the payment form).
- Retrieve the JSON posted in the browser
- Check the authenticity of the notification with the value of kr-hash ( 4th key of the REST API key table )
- Check the payment status
.
VI. Simplified PHP example
In the sample
folder, the sample files are:
- ipn.php.
- paid.php.
For more information, click on: Example files: ipn.php and paid.php