Laravel Cashier:恢复一次付款

时间:2015-11-10 16:15:52

标签: laravel laravel-cashier

成功付款后,我将条带ID存储在mysql表中。有了这个id,我想检索存储在条带数据库中的所有细节。

那么可以通过条带ID恢复单笔付款吗?

由于

1 个答案:

答案 0 :(得分:0)

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

使用“客户检索”条带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前缀)