Skip to main content

Create Test Payment

Creating a Test Payment (createTestPayment) allows you to verify the functionality of your webhook endpoint, token, parameters, and all necessary informations.

This process closely mimics a real payment. However, note that you can only pay using faucets within the Sepolia Test Network (Native SepoliaETH Coin & ERC-20 Faucet Tokens).

How to obtain these faucets?

Requirements

In order to create a test payment, you will need:

  • Your API Token: abcd... which can be found in your dashboard here.
  • The action: createTestPayment
  • Your desired amount in dollars: 10
warning

It's crucial to keep your API Token confidential. Tokens should never be exposed in front-end code. It's advised to make the API request server-side to prevent parameter tampering and token leaks.

The HTTPS Request

To initiate a test payment, make a GET request to https://api.swaycoin.io, including the required parameters.

You can test it within your browser!
https://api.swaycoin.io?token=YOUR_API_TOKEN&action=createTestPayment&amount=10

Using Code

const YOUR_API_TOKEN = 'YOUR_API_TOKEN';
const amount = 10;
const endpoint = 'https://api.swaycoin.io?token=' + YOUR_API_TOKEN + '&action=createTestPayment&amount=' + amount;

fetch(endpoint)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

The HTTPS Response

Upon successful execution, you should receive a JSON response similar to:

// Response indicating a successful request
{
"request_status": "success",
"message": "Your payment has been successfully created!",
"paymentID": "XXXXXXXXXX"
}

Upon failed execution, you should receive a JSON response similar to:

// Response indicating a failed request
{
"request_status": "error",
"message": "Invalid API token, action, or amount. Please check your input parameters."
}
info

A valid paymentID for test payments will consist of 10 letters only.

Forwarding the user

To proceed with the payment, redirect the user to https://payment.swaycoin.io, appending the newly generated paymentID as the paymentID parameter.

URL Example:

// Replace XXXXXXXXXX by the paymentID received within the response
https://payment.swaycoin.io?paymentID=XXXXXXXXXX
https://payment.swaycoin.io?paymentID=XXXXXXXXXX

SwayCoin.io Test Payment Website

Please select your currency for your $10 Payment.

Logo Ethereum

SepoliaETH