-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtransaction.php
185 lines (173 loc) · 6.63 KB
/
transaction.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
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<html>
<?php require_once("head.php"); ?>
<body>
<?php
require_once("braintree-init.php");
require_once("header.php");
if (isset($_GET["id"])) {
$transaction = Braintree\Transaction::find($_GET["id"]);
$transactionSuccessStatuses = [
Braintree\Transaction::AUTHORIZED,
Braintree\Transaction::AUTHORIZING,
Braintree\Transaction::SETTLED,
Braintree\Transaction::SETTLING,
Braintree\Transaction::SETTLEMENT_CONFIRMED,
Braintree\Transaction::SETTLEMENT_PENDING,
Braintree\Transaction::SUBMITTED_FOR_SETTLEMENT
];
if (in_array($transaction->status, $transactionSuccessStatuses)) {
$header = "Sweet Success!";
$icon = "success";
$message = "Your test transaction has been successfully processed. See the Braintree API response and try again.";
} else {
$header = "Transaction Failed";
$icon = "fail";
$message = "Your test transaction has a status of " . $transaction->status . ". See the Braintree API response and try again.";
}
}
?>
<div class="wrapper">
<div class="response container">
<div class="content">
<div class="icon">
<img src="/images/<?php echo($icon)?>.svg" alt="">
</div>
<h1><?php echo($header)?></h1>
<section>
<p><?php echo($message)?></p>
</section>
<section>
<a class="button primary back" href="/index.php">
<span>Test Another Transaction</span>
</a>
</section>
</div>
</div>
</div>
<aside class="drawer dark">
<header>
<div class="content compact">
<a href="https://developers.braintreepayments.com" class="braintree" target="_blank">Braintree</a>
<h3>API Response</h3>
</div>
</header>
<article class="content compact">
<section>
<h5>Transaction</h5>
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>id</td>
<td><?php echo($transaction->id)?></td>
</tr>
<tr>
<td>type</td>
<td><?php echo($transaction->type)?></td>
</tr>
<tr>
<td>amount</td>
<td><?php echo($transaction->amount)?></td>
</tr>
<tr>
<td>status</td>
<td><?php echo($transaction->status)?></td>
</tr>
<tr>
<td>created_at</td>
<td><?php echo($transaction->createdAt->format('Y-m-d H:i:s'))?></td>
</tr>
<tr>
<td>updated_at</td>
<td><?php echo($transaction->updatedAt->format('Y-m-d H:i:s'))?></td>
</tr>
</tbody>
</table>
</section>
<section>
<h5>Payment</h5>
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>token</td>
<td><?php echo($transaction->creditCardDetails->token)?></td>
</tr>
<tr>
<td>bin</td>
<td><?php echo($transaction->creditCardDetails->bin)?></td>
</tr>
<tr>
<td>last_4</td>
<td><?php echo($transaction->creditCardDetails->last4)?></td>
</tr>
<tr>
<td>card_type</td>
<td><?php echo($transaction->creditCardDetails->cardType)?></td>
</tr>
<tr>
<td>expiration_date</td>
<td><?php echo($transaction->creditCardDetails->expirationDate)?></td>
</tr>
<tr>
<td>cardholder_name</td>
<td><?php echo($transaction->creditCardDetails->cardholderName)?></td>
</tr>
<tr>
<td>customer_location</td>
<td><?php echo($transaction->creditCardDetails->customerLocation)?></td>
</tr>
</tbody>
</table>
</section>
<?php if (!is_null($transaction->customerDetails->id)) : ?>
<section>
<h5>Customer Details</h5>
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>id</td>
<td><?php echo($transaction->customerDetails->id)?></td>
</tr>
<tr>
<td>first_name</td>
<td><?php echo($transaction->customerDetails->firstName)?></td>
</tr>
<tr>
<td>last_name</td>
<td><?php echo($transaction->customerDetails->lastName)?></td>
</tr>
<tr>
<td>email</td>
<td><?php echo($transaction->customerDetails->email)?></td>
</tr>
<tr>
<td>company</td>
<td><?php echo($transaction->customerDetails->company)?></td>
</tr>
<tr>
<td>website</td>
<td><?php echo($transaction->customerDetails->website)?></td>
</tr>
<tr>
<td>phone</td>
<td><?php echo($transaction->customerDetails->phone)?></td>
</tr>
<tr>
<td>fax</td>
<td><?php echo($transaction->customerDetails->fax)?></td>
</tr>
</tbody>
</table>
</section>i
<?php endif; ?>
<section>
<p class="center small">Integrate with the Braintree SDK for a secure and seamless checkout</p>
</section>
<section>
<a class="button secondary full" href="https://developers.braintreepayments.com/guides/drop-in" target="_blank">
<span>See the Docs</span>
</a>
</section>
</article>
</aside>
</body>
</html>