PHP code example of wonderfulpaymentsltd / one-api-sdk-php
1. Go to this page and download the library: Download wonderfulpaymentsltd/one-api-sdk-php 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/ */
wonderfulpaymentsltd / one-api-sdk-php example snippets
use Wonderful\OneApi\OneApiClient;
$client = OneApiClient::make('your-api-key');
use OneApi;
OneApi::customers()->list();
use Wonderful\OneApi\OneApiClient;
class PaymentController
{
public function __construct(protected OneApiClient $oneApi) {}
public function index()
{
return $this->oneApi->payments()->list();
}
}
$payment = $client->quickPay()
->amount(1000) // £10.00 in GB pence
->reference('ORDER-1234') // Shown on bank statement (max 18 chars, A-Z, 0-9, -)
->description('Website Order #1234') // Order description
->customerEmail('[email protected]') // Links order to customer
->redirectUrl('https://mysite.com/success')
->webhookUrl('https://mysite.com/webhooks')
->create();
echo $payment->pay_link; // Send customer to this URL to pay
$payment = $client->quickPay()
->amount(1000)
->reference('ORDER-1234')
->bankId('natwest') // Pre-select the customer's bank
->skipConfirmation(true) // Skip the confirmation page
->sendToTap('a1b2c3d4') // Send to a Tap device
->create();
// List orders
$orders = $client->orders()->list([
'payment_status' => 'paid',
'sort' => 'created_desc',
'per_page' => 25,
]);
// Find a specific order
$order = $client->orders()->find('ed6d3016');
// Access related data
echo $order->total_formatted;
echo $order->customer->email;
echo $order->payments[0]->pay_link;
echo $order->order_lines[0]->description;
// Create a refund (amount in GB pence)
$refund = $client->orders()->refund(
id: 'ed6d3016',
amount: 500,
reference: 'REF-001', // Optional, max 18 chars
reason: 'Item returned, too big.' // Optional, internal note
);
echo "Refunded: {$refund->refund_amount_formatted} ({$refund->status})";
// List payments
$payments = $client->payments()->list([
'sort' => 'created_desc',
'per_page' => 10,
]);
// Find a specific payment
$payment = $client->payments()->find('e2611865');
// Stop a payment (before it's authorised at the bank)
$payment = $client->payments()->stop('e2611865');
// Delete a payment (only if status is 'created')
$client->payments()->delete('e2611865');
// List all tap devices
$devices = $client->tapDevices()->list();
// Filter by action type
$tapDevices = $client->tapDevices()->list(['tap_payments']);
$reusableLinkDevices = $client->tapDevices()->list(['reusable_payment']);
$merchantLinkDevices = $client->tapDevices()->list(['merchant_link']);