Payment flow summary

📘

The Redirect-based Checkout sample projects for Node and Python enable you to experiment with Redirect-based Checkout and produce a working prototype with minimal changes.

Step 1: Generate signature

After you have collected all relevant transaction information, you need to generate and add a signature to your request for authentication. The signature uses the HMAC SHA256 algorithm and all the payment parameters in the request. The secret token provided to you by Peach Payments acts as the key to generate the signature.

For more details on how to generate the signature, see the Authentication and authorisation section.

Step 2: Initialise Hosted Checkout and redirect customer

After you have generated the signature, you can initialise Hosted Checkout using your request parameters and signature and redirect the user to the payment page using one of the following methods:

  • Redirect
  • Form POST

🚧

For the form POST method, you must sign the data on the backend and execute the POST from the browser.

Run in Postman

Redirect-based Checkout

Execute the Redirect-based Checkout call and redirect the user to the returned URL.

Form POST Checkout

Execute the Checkout call and use a form POST to redirect the user to the payment page:

<!doctype html>
<html>
<body>
<form name="form" action="https://testsecure.peachpayments.com/checkout" method="POST" accept-charset="utf-8">
    <input type="hidden" name="amount" value="2" />
    <input type="hidden" name="authentication.entityId" value="8ac7a4ca68c22c4d0168c2caab2e0025" />
    <input type="hidden" name="currency" value="ZAR" />
    <input type="hidden" name="merchantTransactionId" value="TESTING002" />
    <input type="hidden" name="nonce" value="Test1234" />
    <input type="hidden" name="paymentType" value="DB" />
    <input type="hidden" name="shopperResultUrl" value="https://example.com/example-webhook" />
    <input type="hidden" name="signature" value="311ed8e11e2da00d98c7479ca390a5396fe643e13629d850243dada877963afd" />
    <input type="submit" value="Continue to Payment Method"/></form>
</body>
</html>

Step 3: Query checkout status

After payment processing completes, Checkout redirects the customer to your shopperResultUrl. That redirect is a POST request which has the same structure as that of the webhook. You can make a request to get the status of a Checkout request by using the checkoutId parameter as a reference to the payment.

The webhook notification and the POST redirect to the shopperResultUrl include the checkoutId.

import requests

url = "https://testsecure.peachpayments.com/status?authentication.entityId=8ac7a4c8708b8dae01708be6bb3b018e&merchantTransactionId=ffghfsdrererwsdsf&signature=99699bb4a04af65a762ec4d15363a3d79aa21a12786721e0e89fa6c98933fb18"

payload = {}
headers= {}

response = requests.request("GET", url, headers=headers, data = payload)

print(response.text.encode('utf8'))
curl --location --request GET 'https://testsecure.peachpayments.com/status?authentication.entityId=8ac7a4c8708b8dae01708be6bb3b018e&merchantTransactionId=ffghfsdrererwsdsf&signature=99699bb4a04af65a762ec4d15363a3d79aa21a12786721e0e89fa6c98933fb18'

Run in Postman