-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
28 lines (25 loc) · 930 Bytes
/
Copy pathindex.php
File metadata and controls
28 lines (25 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
require_once 'UddoktaPay.php';
$apiKey = "982d381360a69d419689740d9f2e26ce36fb7a50";
$apiBaseURL = "https://sandbox.uddoktapay.com/api/checkout-v2";
$uddoktaPay = new UddoktaPay($apiKey, $apiBaseURL);
// Example request data for initializing a payment
$requestData = [
'full_name' => "John Doe",
'email' => "test@test.com",
'amount' => 10,
'metadata' => [
'example_metadata_key' => "example_metadata_value",
// ... Add more key-value pairs for dynamic metadata ...
],
'redirect_url' => 'http://localhost/success.php',
'return_type' => 'GET',
'cancel_url' => 'http://localhost/cancel.php',
'webhook_url' => 'http://localhost/ipn.php',
];
try {
$paymentUrl = $uddoktaPay->initPayment($requestData);
header('Location:' . $paymentUrl); // redirect user
} catch (Exception $e) {
echo "Initialization Error: " . $e->getMessage();
}