-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
61 lines (51 loc) · 1.46 KB
/
index.php
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
require 'vendor/autoload.php';
use IntaSend\IntaSendPHP\Checkout;
use IntaSend\IntaSendPHP\Customer;
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://sandbox.intasend.com/api/v1/checkout/', [
'headers' => [
'accept' => 'application/json',
'content-type' => 'application/json',
],
]);
// Create customer data
$customer = new Customer();
$customer->first_name = "Joe";
$customer->last_name = "Doe";
$customer->email = "joe@doe.com";
$customer->country = "KE";
$customer->city = "Nairobi";
$customer->address = "Apt 123, Westland road";
$customer->zipcode = "0100";
$customer->state = "Nairobi";
$amount = 10;
$currency = "KES";
// Define redirect and host URLs
$host = "https://example.com";
$redirect_url = "https://example.com/callback";
$ref_order_number = "test-order-10";
// Initialize Checkout
$checkout = new Checkout();
$checkout->init($credentials);
// Create a new checkout session
try {
$resp = $checkout->create(
$amount,
$currency,
$customer,
$host,
$redirect_url,
$ref_order_number,
null, // Optional comment
null // Optional method
);
print_r($resp);
} catch (GuzzleHttp\Exception\ClientException $e) {
// Log the response for debugging
echo 'ClientException: ' . $e->getMessage();
echo "\nResponse:\n" . $e->getResponse()->getBody()->getContents();
} catch (Exception $e) {
echo 'Exception: ' . $e->getMessage();
}
?>