1. Go to this page and download the library: Download ndenisj/longswipe-payment library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ndenisj / longswipe-payment example snippets
// PHP code block
use Longswipe\Payment\LongswipeClient;
use Longswipe\Payment\Exceptions\LongswipeException;
// Initialize the client
$client = new LongswipeClient('your-api-key', true); // true for sandbox, false for production
// Example parameters
$params = [
'voucherCode' => 'VOUCHER123',
'amount' => 1000,
'receivingCurrencyId' => '2eedd32', // Replace with actual receiving currency ID,
'lockPin' => '1234', // Optional
'walletAddress' => '0x123...' // Optional
];
try {
// Fetch voucher details
$voucherDetails = $client->fetchVoucherDetails($params);
// If details are okay, process the payment
$paymentResult = $client->processVoucherPayment($params);
} catch (LongswipeException $e) {
echo "Error: " . $e->getMessage();
echo "Code: " . $e->getCode();
var_dump($e->getData());
}
// For sandbox environment
$client = new LongswipeClient('your-api-key', true);
// For production environment
$client = new LongswipeClient('your-api-key', false);