You can use the following template to create URLs for redirecting a customer to a Hosted Payments Form.
https://<converge-api-url>?sessionId=<payment-session-id>
The Converge-API-URL is the URL for the environment you are currently using. Typically these will be either:
-
Sandbox:
- https://uat.api.converge.eu.elavonaws.com/
- https://uat.hpp.converge.eu.elavonaws.com/
-
Production:
- https://api.eu.convergepay.com/
- https://hpp.eu.convergepay.com/
On top of that, you will need a Session ID. This is obtained from creating a payment session. For more information, see Server-Side Scripting and the Payment Sessions resource.
Example: A Client-Side Approach
One way to approach executing this redirect is to have a button that initiates the checkout when it's clicked.
First, create an HTML button that invokes a redirect function on click. Then, define a function that the previous button invokes. This function should handle the work of creating a Hosted Payments Page redirect URL and redirects the client's browser to the location.
There are multiple ways to make this function. The following function is one possible approach.
async function hostedRedirect() { const sessionId = await paymentSession(); // A function that returns a payment session ID. // Use a string literal to append the session ID to the URL. const redirectUrl = 'https://uat.hpp.converge.eu.elavonaws.com?sessionId=${sessionId}'; // Redirect the window to the payment session. window.location = redirectURL; }