<html>
<head>
<!-- Import the SDK -->
<!-- Sandbox -->
<!-- <script src="https://widget.klyme.io/test.js"></script> -->
<!-- Production -->
<script src="https://widget.klyme.io/prod.js"></script>
<title>Klyme Example</title>
</head>
<body>
<!-- Widget -->
<klyme-widget id="INSERT UUID HERE"></klyme-widget>
</body>
</html>
const axios = require('axios');
const qs = require('qs');
let data = qs.stringify({
'merchantUuid': '3fe3539cba3a59731be57905b8a12345',
'reference': 'Test 1'
'amount': '2.99',
'currency': 'GBP',
'redirectUrl': 'https://klyme.io/payment-confirmation'
;
let config = {
method: 'post',
url: 'http://api.klyme.io/api/v1/payment-auth-requests',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': '••••••'
},
data: data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
<?php
$curl = curl_init();
$data = array(
'merchantUuid' => '3fe3539cba3a59731be57905b12345',
'reference' => 'Test',
'amount' => 2.99,
'currency' => 'GBP',
'redirectUrl' => 'https://klyme.io/payment-confirmation'
);
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://api.klyme.io/api/v1/payment-auth-requests',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => http_build_query($data),
CURLOPT_HTTPHEADER => array(
'Content-Type: application/x-www-form-urlencoded',
'Authorization: Basic ••••••'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpHeaders;
import java.util.Map;
import java.util.stream.Collectors;
public class ApiRequest {
public static void main(String[] args) {
String url = "https://api.klyme.io/api/v1/payment-auth-requests";
Map<String, String> data = Map.of(
"merchantUuid", "3fe3539cba3a59731be57905b8a12345",
"reference", "Test",
"amount", "2.99",
"currency", "GBP",
"redirectUrl", "https://klyme.io/payment-confirmation"
);
String formData = data.entrySet().stream()
.map(entry -> entry.getKey() + "=" + entry.getValue())
.collect(Collectors.joining("&"));
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Content-Type", "application/x-www-form-urlencoded")
.header("Authorization", "Bearer ••••••")
.POST(HttpRequest.BodyPublishers.ofString(formData))
.build();
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
} catch (Exception e) {
e.printStackTrace();
}
}
}
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
class Program {
static async Task Main(string[] args) {
string url = "http://api.klyme.io/api/v1/payment-auth-requests";
var data = new Dictionary<string, string>
{
{ "merchantUuid", "3fe3539cba3a59731be57905b12345" },
{ "reference", "Test" },
{ "amount", "2.99" },
{ "currency", "GBP" },
{ "redirectUrl", "https://klyme.io/payment-confirmation" }
};
var content = new FormUrlEncodedContent(data);
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Basic", "••••••");
try {
HttpResponseMessage response = await client.PostAsync(url, content);
string responseString = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseString);
}
catch (Exception ex) {
Console.WriteLine("An error occurred: " + ex.Message);
}
}
}
}