【问题标题】:Laravel Cashier: Resume a single paymentLaravel Cashier:恢复单笔付款
【发布时间】:2015-11-10 16:15:51
【问题描述】:

成功付款后,我将条带 ID 存储在 mysql 表中。使用该 ID,我想检索存储在条带数据库中的所有详细信息。

那么是否可以通过条带 id 恢复单笔付款?

谢谢

【问题讨论】:

  • 您说您希望“恢复单次付款” - 这是否意味着您希望进行第二次一次性收费,或者是否意味着您希望恢复订阅计划你已经设置了吗?
  • 一次性收费,然后恢复该收费的详细信息.. 没有订阅
  • 所以您想在进行 1 次收费后从 Stripe 数据库中检索存储的所有详细信息?您不是要进行第二次收费吗?
  • 是的,我不想进行第二次充电。只恢复细节

标签: laravel laravel-cashier


【解决方案1】:

这里是您需要使用的文档:https://stripe.com/docs/api/php#retrieve_customer

使用“客户检索”Stripe API 调用来检索有关客户购买的详细信息:

 Stripe::setApiKey(Config::get('your_stripe_secret_key_here'));
 $customer_object = Customer::retrieve(customers_stripe_id);

这将返回以下 JSON:

Stripe\Customer JSON: {
  "id": "cus_7KJZQ8Z6jfSSMl",
  "object": "customer",
  "account_balance": 0,
  "created": 1447172728,
  "currency": "usd",
  "default_source": "card_175evz2eZvKYlo2CKoS2WEDk",
  "delinquent": false,
  "description": "Bingo|www|0c1234567890",
  "discount": null,
  "email": null,
  "livemode": false,
  "metadata": {
  },
  "shipping": null,
  "sources": {
    "object": "list",
    "data": [
      {
        "id": "card_175evz2eZvKYlo2CKoS2WEDk",
        "object": "card",
        "address_city": null,
        "address_country": null,
        "address_line1": null,
        "address_line1_check": null,
        "address_line2": null,
        "address_state": null,
        "address_zip": null,
        "address_zip_check": null,
        "brand": "Visa",
        "country": "US",
        "customer": "cus_7KJZQ8Z6jfSSMl",
        "cvc_check": "pass",
        "dynamic_last4": null,
        "exp_month": 5,
        "exp_year": 2016,
        "funding": "credit",
        "last4": "4242",
        "metadata": {
        },
        "name": null,
        "tokenization_method": null
      }
    ],
    "has_more": false,
    "total_count": 1,
    "url": "/v1/customers/cus_7KJZQ8Z6jfSSMl/sources"
  },
  "subscriptions": {
    "object": "list",
    "data": [

    ],
    "has_more": false,
    "total_count": 0,
    "url": "/v1/customers/cus_7KJZQ8Z6jfSSMl/subscriptions"
  }
}

这是 Stripe 的 API 调用版本:

\Stripe\Stripe::setApiKey("your_secret_key");
\Stripe\Customer::retrieve("the_customers_id");

确保通过在模型或控制器顶部添加 \Stripe 类来导入:

use Stripe\Customer;
use Stripe\Stripe;

如果您想使用“Stripe”而不是 \Stripe\Stripe 和 \Stripe\Customer 前缀)

【讨论】:

  • 但这不是 Laravel Cashier
  • 它有效,据我所知,Laravel Cashier 在这里没有提供解决方案。
  • 如果你想让 Laravel Cashier 为你做这件事,那么它仍然会做与上面完全相同的事情,只是将它包装在一个具有不同名称的自定义函数中。
  • 所以使用纯stripe php比Laravel Cashier更完善
  • 我刚刚发现了一个有趣的 laravel 包:cartalyst.com/manual/stripe/2.0
猜你喜欢
  • 2021-11-27
  • 2021-02-14
  • 2021-11-13
  • 2020-12-14
  • 2020-06-09
  • 2021-02-27
  • 2016-07-10
  • 2019-10-22
  • 1970-01-01
相关资源
最近更新 更多