简体   繁体   English

如何配置Braintree Php

[英]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. 我正在服务器上安装大脑树,我访问了他们的GitHub并下载了他们的示例项目,这个工作很好,唯一的问题是这不是一个干净的安装。 I download the clean installation from braintree the structure of these folders are completely different. 我从braintree下载了全新安装,这些文件夹的结构完全不同。 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. 在我使用Checkout进行所有更改之前。 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. 很抱歉,如果这种情况令人困惑,但是Braintree入门并不能很好地解释事情。

New download file structure 新的下载文件结构

新的下载文件结构

old file Structure 旧文件结构

旧文件结构

Full disclosure: I work at Braintree. 全面披露:我在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. 这是因为在安装示例库时,客户端库是通过composer安装到/ vendor目录中的。 If examining it from the /vendor directory, it should look very similar. 如果从/ vendor目录中进行检查,则它看起来应该非常相似。
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. 也就是说,与Braintree与PHP进行任何集成,您都需要让您的PHP脚本加载库本身,以初始化创建对Braintree的API调用所需的各种类,方法和对象。 This means that your API keys and a path to the /lib/Braintree.php file in the Braintree client library. 这意味着您的API密钥以及Braintree客户端库中/lib/Braintree.php文件的路径。 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. 相当普遍的做法是在一个将使用Braintree API调用的给定文件中包括一个具有这些API密钥的“自动加载” PHP文件以及一个到您的客户端库的路径。 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. 如果特定文件处理了对Braintree的特定API调用,那就是这种情况。 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. 用于创建客户的表单中的操作将被发送到您的php文件中,其中包含Braintree_Customer::create()调用,而旨在创建交易的操作将进入包含Braintree_Transaction::sale()的文件中。 Braintree_Transaction::sale()调用。 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. 您无需将数据发送到Braintree客户端库中的各个php文件因为我们文档中概述的API调用可根据需要创建/发送各种交易对象至Braintree。

These however could be part of a class or other logic that are contained in a single PHP file. 但是,这些可以是包含在单个PHP文件中的类或其他逻辑的一部分。 It all really depends on your integration. 这完全取决于您的集成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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