简体   繁体   中英

How do configure Braintree Php

I'm installing brain tree on my server, I visit their GitHub and download their sample project this work fine the only problem is that this is not a clean installation. I download the clean installation from braintree the structure of these folders are completely different. I have access to my merchant number and everything else I need but I do not know where I need to put them, do I place them in every file that is using?. Before I was using Checkout to make all changes. in the version that I download it look like I have to send customers info and transactions to different files. sorry if this situation sound confusing but Braintree get started did not a great job explaining things.

New download file structure

新的下载文件结构

old file Structure

旧文件结构

Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support .

The client library itself is going to have a different file structure on the root level than what you're seeing in the example integration. This is because the client library is installed via composer into a /vendor directory in the example integration when it is installed. If examining it from the /vendor directory, it should look very similar.
That said, with any Braintree integration with PHP, you'll need to have your PHP script load the library itself to initialize the various classes, methods, and objects needed to create API calls to Braintree. This means that your API keys and a path to the /lib/Braintree.php file in the Braintree client library. It's fairly common practice to include an "autoload" PHP file to have these API keys and a path to your client library in a given file that will use Braintree API calls. Below is an example of what a file like that might look like:

<?php
require_once '/PATH/to/braintree-php-3.17.0/lib/Braintree.php';
Braintree_Configuration::environment('sandbox');
Braintree_Configuration::merchantId('your_merchant_id');
Braintree_Configuration::publicKey('your_public_key');
Braintree_Configuration::privateKey('your_private_key');
?>

In regards to your second question about sending information to a different file, that could be the case depending on your integration. If specific files handle specific API calls to Braintree, then that would be the case. Actions from a form which are meant to create a customer would be sent to one of your php files which contains a Braintree_Customer::create() call, and actions that are meant to create a transaction would go to a file containing a Braintree_Transaction::sale() call. You won't have to send the data to the various php files in the Braintree client library as the API calls outlined in our documentation create/send the various transaction objects to Braintree as needed.

These however could be part of a class or other logic that are contained in a single PHP file. It all really depends on your integration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM