-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpurchase.php
37 lines (31 loc) · 1 KB
/
purchase.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
<?php
checkout();
function checkout()
{
$checkout = httpPost('https://bitpave.com/api/checkout/create', [
'client' => 'client_id',
'client_secret' => 'client_secret',
'name' => 'Tesla Model Y',
'icon' => 'https://media.autoweek.nl/m/2moyzhpb33tk.jpg',
'price' => 65000,
'wallet' => 'bc1qpy8vlun5fah906h87wwyussshjmtndyv55dlaf',
'success_url' => 'https://example.com/store/',
'cancel_url' => 'https://example.com/store?method=cancelled',
'callback_url' => 'https://example.com/store/callback.php',
]);
return redirect($checkout->checkout_url);
}
function httpPost($url, $data)
{
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
return json_decode($response);
}
function redirect($location)
{
header('Location: '.$location);
}