php 如何在WordPress上创建Stripe express帐户?

enxuqcxy  于 6个月前  发布在  PHP
关注(0)|答案(2)|浏览(43)

我想在我的WordPress平台上为我的客户(他们将收到钱)创建Stripe express帐户。当用户在我的平台上注册时,将创建一个用户帐户。我该怎么做?
我已经安装了两个Stripe扩展来帮助我,但这些扩展都不允许为客户创建帐户。我尝试浏览Stripe文档以编写自己的代码。我找到了一些示例,并在将Stripe库文件夹包含在我的主题文件夹中后尝试了下面的代码的简短代码。

require_once get_template_directory() . '/stripe-php-master/lib/Stripe.php';
$stripe = new \Stripe\StripeClient('<my_stripe_secret_api_key');

$stripe->accounts->create(['type' => 'express']);

字符串
我已经在我的客户注册页面上包含了短代码,但没有任何预期的效果。我希望我的代码创建一个没有任何信息的快捷帐户(除了强制性的帐户类型),看看代码是否有效,但什么也没有发生。

66bbxpm5

66bbxpm51#

1.只是为了仔细检查@NigelRen的思路--如果你完全按照example in the API docs来做会发生什么--更好的是,转储响应并添加一个try/catch来查看潜在的问题?

try {
  require_once get_template_directory() . '/stripe-php-master/lib/Stripe.php';
  $stripe = new \Stripe\StripeClient('<my_stripe_secret_api_key');

  // A. Use exact example from API Docs just to make sure we're not missing something
  $response = $stripe->accounts->create([
    'type' => 'custom',
    'country' => 'US',
    'email' => '[email protected]',
    'capabilities' => [
      'card_payments' => ['requested' => true],
      'transfers' => ['requested' => true],
    ],
  ]);
  echo "Response 1: ";
  var_dump($response);

  // B. Then switch *just* the account type and confirm the difference
  $response = $stripe->accounts->create([
    'type' => 'express',
    'country' => 'US',
    'email' => '[email protected]',
    'capabilities' => [
      'card_payments' => ['requested' => true],
      'transfers' => ['requested' => true],
    ],
  ]);
  echo "Response 2: ";
  var_dump($response);

} catch (Exception $e) {
  echo "ERROR: ";
  var_dump($e->getMessage());
  die;
}

字符串
1.你怎么验证?
1.您在Stripe帐户中看到了什么?

  1. API调用本身的结果是什么--还是抛出了异常?
    1.结果是否与上面的1A和1B不同?
    1.结果是否与手动创建帐户时不同?
    我希望这能帮助你走上正确的道路!
jgwigjjp

jgwigjjp2#

我终于得到了为平台工作的帐户创建。你可以注意到我纠正了一些错误。我还移动了服务器上的条带库文件夹。

try{
 require_once('/htdocs/wp-content/stripe-php-master/init.php');
    $stripe = new \Stripe\StripeClient('<my_stripe_secret_api_key>');

    $account = $stripe->accounts->create([
        'type' => 'express',
        'country' => 'US',
        'email' => '[email protected]',
        'capabilities' => [
          'card_payments' => ['requested' => true],
          'transfers' => ['requested' => true],
        ]]);
}catch(Exception $e){
   print($e->getMessage());
}

字符串
谢谢大家。

相关问题