-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransaction.php
More file actions
35 lines (30 loc) · 901 Bytes
/
transaction.php
File metadata and controls
35 lines (30 loc) · 901 Bytes
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
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
include ("lib/Braintree.php");
include ("lib/braintreeconfig.php");
$result = Braintree_Transaction::sale(array(
"amount" => $_REQUEST["amount"],
"creditCard" => array(
"number" => $_REQUEST["number"],
"cvv" => $_REQUEST["cvv"],
"expirationMonth" => $_REQUEST["month"],
"expirationYear" => $_REQUEST["year"]
),
"options" => array(
"submitForSettlement" => true
)
));
if ($result->success) {
echo("Success! Transaction ID: " . $result->transaction->id);
} else if ($result->transaction) {
echo("Error: " . $result->message);
echo("<br/>");
echo("Code: " . $result->transaction->processorResponseCode);
} else {
echo("Validation errors:<br/>");
foreach (($result->errors->deepAll()) as $error) {
echo("- " . $error->message . "<br/>");
}
}
?>