We require you to send the following fields when initiating a payment:
email (merchant field)password (merchant field)account (client field)full_name (client field)description (required)failurl (required)okurl (required)amount (required)Here’s a sample JSON object combining all required fields. Remember to adjust values according to your environment.
{
"email": "merchant@example.com", // Merchant credentials
"password": "SecretPass123", // Merchant credentials
"account": "1167243219", // Client's SWINTO account
"full_name": "John Doe", // Client's full name
"description": "Example payment transaction",
"failurl": "https://yoursite.com/payment-fail",
"okurl": "https://yoursite.com/payment-success",
"amount": "50.00"
}
As before, you must **encrypt** this JSON object with our public key
before sending it. Below is a sample PHP function demonstrating how
to do this using openssl_public_encrypt.
public function encrypt($decryptedData): ?string
{
// Path to your public key
$publicKey = file_get_contents('/public.key');
// Load the key
$pubKey = openssl_pkey_get_public($publicKey);
if ($pubKey === false) {
return "Failed to load public key!";
}
// Encrypt the JSON string
$encrypted = '';
if (!openssl_public_encrypt(json_encode($decryptedData), $encrypted, $pubKey)) {
return "Failed to encrypt data! " . openssl_error_string();
}
// Cleanup
openssl_free_key($pubKey);
// Return base64 encoded ciphertext
return base64_encode($encrypted);
}
In your frontend (or server-side form), you will only post
encrypted data. The original (plain text) fields are
commented out for clarity.
<form id="form" method="post" action="/payment">
<!--
Collect these above fields in your application,
then encrypt them using our public key.
-->
<input
type="text"
class="form-control"
placeholder="encrypted"
name="encrypted"
value="<?= $yourEncryptedPayload ?>"
>
<button type="submit">test</button>
</form>
email, password, account, full_name, amount, description, failurl, okurl.
name="encrypted" and POST to /payment.