aboutsummaryrefslogtreecommitdiffstats
path: root/public/system/storage/vendor/divido/divido-php/Example.php
blob: 88de621d90e1039be3a32aea95f1459fb87344ce (plain)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
$apiKey = "";

$amount = 1200;
$sandbox = true;

require_once('./lib/Divido.php');
Divido::setMerchant($apiKey);

if ($_POST) {
	$response = Divido_CreditRequest::create(array(
	  "country" => "GB",
	  "finance" => $_POST['finance'],
	  "reference"=>$_POST['reference'],
	  "customer" => array(
		"title" => $_POST['title'],
		"first_name" => $_POST['firstName'],
		"middle_name" => $_POST['middleName'],
		"last_name" => $_POST['lastName'],
		"email" => $_POST['email'],
		"mobileNumber" => $_POST['mobileNumber'],
		"phoneNumber" => $_POST['phoneNumber'],
		"postcode" => $_POST['postCode'],
		"country" => $_POST['country'],
	  ),
	  "metadata"=>array(
	  	"orderNumber"=>10001,
	  	"checksum"=>md5('10001:mySecret')
	  ),
	  "products"=>array(
	  	array(
		  	"type"=>"product",
		  	"text"=>"Gibson Les Paul Studio Raw Guitar",
		  	"quantity"=>1,
		  	"value"=>1153.00,
		),
		array(
		  	"type"=>"service",
		  	"text"=>"Restring Upgrade",
		  	"quantity"=>1,
		  	"value"=>100.00,
		),
	  ),
	  "response_url"=>"http://www.webshop.com/callback.php",
	  'checkout_url'=>'http://www.webshop.com/checkout',
	  "redirect_url"=>"http://www.webshop.com/success.php",
	));

	if ($response->status == 'ok') {
		header("Location:".$response->url);
	} else {
		print_r($response->__toArray());
	}

} else {
	?>
		<form method="post">
			
			<table width="400">
				<tr>
					<td>Finance:</td>
					<td><select name="finance">
						<?php
						$response = Divido_Finances::all();

						if ($response->status == 'ok') {
							foreach($response->finances as $finance) {
								print '<option value="'.$finance->id.'">'.$finance->text.' ('.$finance->interest_rate.'% APR)</option>';
							}
						}
						?>
					</select></td>
				</tr>
				<tr>
					<td>Reference:</td>
					<td><input type="text" name="reference" value="11001"></td>
				</tr>
				<tr>
					<td>Amount:</td>
					<td>&pound; <?php print number_format($amount); ?></td>
				</tr>
				<tr>
					<td>Deposit:</td>
					<td>&pound; <input type="text" name="deposit" value="100"></td>
				</tr>
				<tr>
					<td colspan="2">&nbsp;</td>
				</tr>
				<tr>
					<td>Title:</td>
					<td><select name="title">
						<option value="Mr">Mr</option>
						<option value="Mrs" selected>Mrs</option>
					</select></td>
				</tr>
				<tr>
					<td>First Name:</td>
					<td><input type="text" name="firstName" value="Ann"></td>
				</tr>
				<tr>
					<td>Middle Name:</td>
					<td><input type="text" name="middleName" value=""></td>
				</tr>
				<tr>
					<td>Last Name:</td>
					<td><input type="text" name="lastName" value="Heselden"></td>
				</tr>
				<tr>
					<td>Phone:</td>
					<td><input type="text" name="phoneNumber" value="0201234567"></td>
				</tr>
				<tr>
					<td>Mobile:</td>
					<td><input type="text" name="mobileNumber" value="0701234567"></td>
				</tr>
				<tr>
					<td>Email:</td>
					<td><input type="text" name="email" value="hallsten@me.com"></td>
				</tr>
				<tr>
					<td>Post Code:</td>
					<td><input type="text" name="postCode" value="BA13 3BN"></td>
				</tr>
				<tr>
					<td>Country:</td>
					<td><select name="country">
						<option value="GB" selected>GB</option>
					</select></td>
				</tr>
			</table>



			<input type="submit" name="test" value="Continue to Divido" />

		</form>
	<?
}