Skip to content

Commit 8071022

Browse files
Revert "Use an instantiated gateway object instead of static method calls (braintree#31)"
This reverts commit bd728ba.
1 parent bd728ba commit 8071022

File tree

6 files changed

+12
-17
lines changed

6 files changed

+12
-17
lines changed

includes/braintree_init.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
$dotenv->load();
88
}
99

10-
$gateway = new Braintree\Gateway([
11-
'environment' => getenv('BT_ENVIRONMENT'),
12-
'merchantId' => getenv('BT_MERCHANT_ID'),
13-
'publicKey' => getenv('BT_PUBLIC_KEY'),
14-
'privateKey' => getenv('BT_PRIVATE_KEY')
15-
]);
10+
Braintree\Configuration::environment(getenv('BT_ENVIRONMENT'));
11+
Braintree\Configuration::merchantId(getenv('BT_MERCHANT_ID'));
12+
Braintree\Configuration::publicKey(getenv('BT_PUBLIC_KEY'));
13+
Braintree\Configuration::privateKey(getenv('BT_PRIVATE_KEY'));

public_html/checkout.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
$amount = $_POST["amount"];
55
$nonce = $_POST["payment_method_nonce"];
66

7-
$result = $gateway->transaction()->sale([
7+
$result = Braintree\Transaction::sale([
88
'amount' => $amount,
99
'paymentMethodNonce' => $nonce,
1010
'options' => [

public_html/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<script src="https://js.braintreegateway.com/web/dropin/1.9.2/js/dropin.min.js"></script>
4040
<script>
4141
var form = document.querySelector('#payment-form');
42-
var client_token = "<?php echo($gateway->ClientToken()->generate()); ?>";
42+
var client_token = "<?php echo(Braintree\ClientToken::generate()); ?>";
4343

4444
braintree.dropin.create({
4545
authorization: client_token,

public_html/transaction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
require_once("../includes/braintree_init.php");
77
require_once("../includes/header.php");
88
if (isset($_GET["id"])) {
9-
$transaction = $gateway->transaction()->find($_GET["id"]);
9+
$transaction = Braintree\Transaction::find($_GET["id"]);
1010

1111
$transactionSuccessStatuses = [
1212
Braintree\Transaction::AUTHORIZED,

tests/TestHelper.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
$dotenv->load();
88
}
99

10-
$gateway = new Braintree\Gateway([
11-
'environment' => getenv('BT_ENVIRONMENT'),
12-
'merchantId' => getenv('BT_MERCHANT_ID'),
13-
'publicKey' => getenv('BT_PUBLIC_KEY'),
14-
'privateKey' => getenv('BT_PRIVATE_KEY')
15-
]);
10+
Braintree\Configuration::environment(getenv('BT_ENVIRONMENT'));
11+
Braintree\Configuration::merchantId(getenv('BT_MERCHANT_ID'));
12+
Braintree\Configuration::publicKey(getenv('BT_PUBLIC_KEY'));
13+
Braintree\Configuration::privateKey(getenv('BT_PRIVATE_KEY'));

tests/integration/TransactionPageTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ class TransactionPageTest extends PHPUnit_Framework_TestCase
55
{
66
function test_showsTransactionInformation()
77
{
8-
global $gateway;
9-
$result = $gateway->transaction()->sale([
8+
$result = Braintree\Transaction::sale([
109
'amount' => 10,
1110
'paymentMethodNonce' => 'fake-valid-nonce'
1211
]);

0 commit comments

Comments
 (0)