-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.php
executable file
·64 lines (53 loc) · 1.82 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
62
63
64
<?php
// This file shows you sample usage of the SnapScan class I wrote
// SnapScan is a awesome service, and I would like to contribute to it's success
// Even if it just shows you possible usage
// Add the required files
require_once('class.qrcode.php');
require_once('class.snapscan.php');
// Initialize SnapScan. Used to be able to generate your Custom SnapScan
// QRCode
$snapMerchantId = "SnapSanID1232_test";
SnapScan::Init($snapMerchantId);
// Generating your custom QR Code. There are some options available
// Where amount is the only required parameter.
// $strict means that a client can overpay, but not overpay.
//
// QR($amount=false, $id=false, $strict=true, $size=300, $margin=0)
// Generate a R50 QRCode
$QRCode = SnapScan::QR(50);
?>
<img
src="<?php echo $QRCode ?>"
width="300"
height="300"
alt="ScanScan Barcode"
/>
<?php
// Generate the QR Code with a unique reference to keep track of the transaction
// Generate a R100 QRCode, with a Unique Reference
$uniqueId = "Super_Awesome_Unique_ID_101201";
$QRCode = SnapScan::QR(100, $uniqueId);
?>
<img
src="<?php echo $QRCode ?>"
width="300"
height="300"
alt="ScanScan Barcode"
/>
<?php
// To be able to do calls against the API, you will need to obtain a
// API Token from SnapScan, and specify it.
$snapToken = "0a63fca2-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
SnapScan::setApiToken($snapToken);
// After you have set your API Token you can check that a transaction was successful
$uniqueId = "Super_Awesome_Unique_ID_101201";
$checkPayment = SnapScan::checkPayment($uniqueId);
// returns [] With payment details / False depending on whether the payment was successful
// Or fails miserably
if (!empty($checkPayment)) {
echo "FOUND PAYMENT!!!" . PHP_EOL;
echo print_r($checkPayment, true) . PHP_EOL;
} else {
echo "PAYMENT NOT FOUND!" . PHP_EOL;
}