38 lines
1.2 KiB
PHP
38 lines
1.2 KiB
PHP
<?php
|
|
class ThawaniService {
|
|
private $pdo;
|
|
private $publicKey;
|
|
private $secretKey;
|
|
private $isSandbox;
|
|
|
|
public function __construct($pdo) {
|
|
$this->pdo = $pdo;
|
|
$this->loadConfig();
|
|
}
|
|
|
|
private function loadConfig() {
|
|
$stmt = $this->pdo->prepare("SELECT setting_key, setting_value FROM integration_settings WHERE provider = 'thawani'");
|
|
$stmt->execute();
|
|
$settings = $stmt->fetchAll(PDO::FETCH_KEY_PAIR);
|
|
|
|
$this->publicKey = $settings['public_key'] ?? '';
|
|
$this->secretKey = $settings['secret_key'] ?? '';
|
|
$this->isSandbox = ($settings['environment'] ?? 'sandbox') === 'sandbox';
|
|
}
|
|
|
|
public function createCheckoutSession($orderId, $amount, $customerData) {
|
|
// Implementation for creating a checkout session
|
|
// This is a placeholder for actual API integration
|
|
return [
|
|
'success' => true,
|
|
'session_id' => 'sess_' . uniqid(),
|
|
'redirect_url' => 'https://uat.thawani.om/pay/...' // Example URL
|
|
];
|
|
}
|
|
|
|
public function handleWebhook($payload) {
|
|
// Implementation for webhook handling
|
|
return true;
|
|
}
|
|
}
|