Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP智能树网关API_Php_Wordpress_Integration_Payment Gateway_Braintree - Fatal编程技术网

PHP智能树网关API

PHP智能树网关API,php,wordpress,integration,payment-gateway,braintree,Php,Wordpress,Integration,Payment Gateway,Braintree,请耐心等待,我正在尝试为我的wordpress预订系统创建一个Braintree网关,而不了解php。我已经从Braintree下载了php库文件,我用下面的代码实现了api连接和创建事务的区域。此代码是从另一个网关获取和调整的!这是一个好方法吗?这样行吗 我的代码 $config = new Braintree\Configuration(); $config->environment($ap

请耐心等待,我正在尝试为我的wordpress预订系统创建一个Braintree网关,而不了解php。我已经从Braintree下载了php库文件,我用下面的代码实现了api连接和创建事务的区域。此代码是从另一个网关获取和调整的!这是一个好方法吗?这样行吗

我的代码

                        $config = new Braintree\Configuration();
                        $config->environment($api_keys_merchant_id);
                        $config->merchantId(trim($api_keys_merchant_id));
                        $config->publicKey(trim($api_keys_public_key));
                        $config->privateKey(trim($api_keys_private_key));
                        $gateway = new Braintree\Gateway($config);

                        // Create transaction
                        $result = $gateway->transaction()->sale([
                        'amount' => $price,
                        'paymentMethodNonce' => 'nonceFromTheClient',
                              'options' => [ 'submitForSettlement' => true ]]);

                        if ($result->success) {
                              print_r("success!: " . $result->transaction->id);
                       } else if ($result->transaction) {
                              print_r("Error processing transaction:");
                              print_r("\n  code: " . $result->transaction->processorResponseCode);
                              print_r("\n  text: " . $result->transaction->processorResponseText);
                       } else {
                              print_r("Validation errors: \n");
                              print_r($result->errors->deepAll());
                     } ```

就我个人而言,我不明白问题是什么,所以如果有,请说明。就调整而言,根据随附的代码示例,我想说:

  • 不要引用未知变量或共享它们的上下文(例如:$parsedCredentials已初始化但未使用;还有什么是$request?)

  • 在文件顶部使用“use”语句,而不是使用FQCN;这使得理解依赖项是什么以及代码做什么变得更容易


如何将Braintree PHP库实现为1的问题。连接到api,2。创建付款/交易或提交交易,结果为成功或失败。上面的代码不是完整的代码。什么是错误,当你实现这一点时,请告诉解释确切的错误我得到的错误是字段\u无效\u货币使用我的沙盒帐户
$gateway = new Braintree_Gateway([
    'environment' => $api_keys_merchant_id,
    'merchantId' => trim($api_keys_merchant_id),
    'publicKey' => 'use_your_public_key',
    'privateKey' => 'use_your_private_key'
]);

$result = $gateway->transaction()->sale([
                        'amount' => $price,
                        'paymentMethodNonce' => 'nonceFromTheClient',
                        'options' => [ 'submitForSettlement' => true ]]);

                        if ($result->success) {
                              print_r("success!: " . $result->transaction->id);
                       } else if ($result->transaction) {
                              print_r("Error processing transaction:");
                              print_r("\n  code: " . $result->transaction->processorResponseCode);
                              print_r("\n  text: " . $result->transaction->processorResponseText);
                       } else {
                              print_r("Validation errors: \n");
                              print_r($result->errors->deepAll());
                     }