简体   繁体   English

使用PHP显示Braintree中的所有计划

[英]Show all plans in Braintree, using PHP

I am using Braintree payment gateway in my PHP application. 我在PHP应用程序中使用Braintree付款网关。 I am creating subscription page on which I want to show all plans, so that the customer can subscribe any of them. 我正在创建要显示所有计划的订阅页面,以便客户可以订阅其中的任何计划。 How can we show all plans using PHP? 我们如何使用PHP显示所有计划?

I have used the following code: 我使用了以下代码:

    require_once ("../braintree/_environment.php");
    $plans = Braintree_Plan::all();
    print_r($plans);

but it shows nothing. 但什么也没显示。 I already have created a plan in my braintree account. 我已经在我的braintree帐户中创建了一个计划。

Following is the code for _environment.php file 以下是_environment.php文件的代码

 <?php
require_once('braintree-php/lib/Braintree.php');
Braintree_Configuration::environment('sandbox');
Braintree_Configuration::merchantId('merchantkey');
Braintree_Configuration::publicKey('publickey');
Braintree_Configuration::privateKey('privatekey');
?>
print_r("<pre>");
$plans = Braintree_Plan::all();
foreach ($plans AS $plan) {
    print_r("<br>PLAN");
    print_r("<br>    id                    = " . $plan->id);
    print_r("<br>    name                  = " . $plan->name);
    print_r("<br>    description           = " . $plan->description);
    print_r("<br>    price                 = " . $plan->price);
    print_r("<br>    currency              = " . $plan->currency);
    print_r("<br>    trialPeriod           = " . $plan->trialPeriod);
    print_r("<br>    billingDayOfMonth     = " . $plan->billingDayOfMonth);
    print_r("<br>    numberOfBillingCycles = " . $plan->numberOfBillingCycles);
 // print_r("<br>    billingCycle          = " . $plan->billingCycle);
}
print_r("</pre>");

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

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