-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckout.php
More file actions
70 lines (56 loc) · 1.55 KB
/
checkout.php
File metadata and controls
70 lines (56 loc) · 1.55 KB
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
62
63
64
65
66
67
68
69
70
<?php
/**
* This PHP script helps you do the iframe checkout
*
*/
/**
* Put your API credentials here:
* Get these from your API app details screen
* https://stage.wepay.com/app
*/
$client_id = "xxxxx";
$client_secret = "xxxxxxxxxx";
$access_token = "xxxxxxxxxx";
$account_id = xxxxxxxxx; // you can find your account ID via list_accounts.php which users the /account/find call
/**
* Initialize the WePay SDK object
*/
require 'wepay.php';
Wepay::useStaging($client_id, $client_secret);
$wepay = new WePay($access_token);
/**
* Make the API request to get the checkout_uri
*
*/
try {
$checkout = $wepay->request('checkout/create', array(
'account_id' => $account_id,
'amount' => $_REQUEST['amnt'],
'short_description' => "Product name",
'type' => "service",
'currency' => 'USD'
)
);
} catch (WePayException $e) { // if the API call returns an error, get the error message for display later
$error = $e->getMessage();
}
?>
<html>
<head>
</head>
<body>
<h1>Please Wait ...</h1>
<p></p>
<?php if (isset($error)): ?>
<h2 style="color:red">ERROR: <?php echo $error ?></h2>
<?php else: ?>
<!-- <div id="checkout_div"></div> -->
<!--<script type="text/javascript" src="https://stage.wepay.com/js/iframe.wepay.js">
</script> -->
<script type="text/javascript">
//WePay.iframe_checkout("checkout_div", "<?php echo $checkout->hosted_checkout->checkout_uri ?>");
window.location.href = "<?php echo $checkout->hosted_checkout->checkout_uri ?>";
</script>
<?php endif; ?>
</body>
</html>