重复条带付款和发票

时间:2018-03-22 21:17:01

标签: php laravel stripe-payments payment-gateway

我目前正在创建一个捐赠表单,允许用户输入他们想捐赠的金额(可变金额)并定期按月收费。我找到了两种方法来做到这一点"

选项1

  1. 创建客户
  2. 订阅客户订阅费用为0.00美元的订阅计划
  3. 向客户收取可变金额
  4. 创建发票

       $customer = Customer::create(array(
                    "card" => $_POST['stripe_token'],
                    "description" => "Monthly Donation",
                    "email" => $_POST['email'],
                    "metadata" => array("email" => $_POST['email']),
                    ));  
    
        $subscription = Subscription::create(array(
                                   "customer" => $customer->id,
                                   "items" => array(array('plan' => '004')),
                                   ));
    
       $charge = Charge::create(array(
                                    "amount" => $_POST['amount'],
                                    "currency" => "usd",
                                    "customer" => $customer['id'],
                                    "description" => "Monthly Donation",
                                    "metadata" => array("email" => $_POST['email']),
                                    "receipt_email" => $_POST['email'],
                                   )); 
    
    
        $invoice = InvoiceItem::create(array("amount" => $_POST['amount'],
                                    "currency" => "usd",
                                    "customer" => $customer['id'],
                                    "description" => "Monthly Donation",
                                    ));
    
  5. 除了在下个月发送给客户的发票之外,这实际上非常有效。包含发票的价格和名称为0.00美元,然后是每月捐赠。

    有没有办法删除$ 0.00和订阅名称?

    以下是发票的图片,以便您更好地理解: enter image description here

    选项2:

    1. 创建客户
    2. 创建产品(每月捐赠)
    3. 制定计划
    4. 向客户收取可变金额
    5. 创建发票

      $customer = Customer::create(array(
          "card" => $_POST['stripe_token'],
          "description" => "VA Monthly Donation",
          "email" => $_POST['email'],
          "metadata" => array("email" => $_POST['email']),
      ));
      
      $product = Product::create(array(
          "name" => "PR Monthly Donation",
          "type" => "service",
      ));
      
      $plan = Plan::create(array(
          "currency" => "usd",
          "interval" => "month",
          "product" => array("name" => "Monthly Donation"),
          "id" => "005",
          "amount" => $_POST['amount'],
      ));
      
      $charge = Charge::create(array(
          "amount" => $_POST['amount'],
          "currency" => "usd",
          "customer" => $customer['id'],
          "description" => "Monthly Donation",
          "metadata" => array("email" => $_POST['email']),
          "receipt_email" => $_POST['email'],
      ));
      
      $invoice = InvoiceItem::create(array("amount" => $_POST['amount'],
          "currency" => "usd",
          "customer" => $customer['id'],
          "description" => "Monthly Donation",
      ));
      
    6. 发票结果非常好,正如我在选项1中想要的那样: enter image description here 但负面的是,这为每个客户创建了一个新的订阅计划。 我最终会得到数百个订阅计划,这不是很干净。 enter image description here

      所以我绝对喜欢选项1,但如果可能的话,需要一种清理发票的方法。有没有办法从选项1中的发票中删除$ 0.00和订阅名称?或者使选项1中的发票看起来像选项2中的发票?

      如果有人有更好的方法,我会接受建议。谢谢!

0 个答案:

没有答案