🖥

#Stripe #API でカスタマー = 顧客を作成・取得する ( 公式ドキュメントのまま ) ( #Ruby )

2019/12/02に公開

Command

Ruby

require 'stripe'
Stripe.api_key = 'sk_test_xxxxx'

Stripe::Customer.create({
  description: 'Customer for jenny.rosen@example.com',
})

curl

curl https://api.stripe.com/v1/customers -u sk_test_xxxxx: -d description="Customer for jenny.rosen@example.com"

API Doc

https://stripe.com/docs/api/customers/create?lang=curl

example

$ curl -s curl https://api.stripe.com/v1/customers -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: -d description="Customer for jenny.rosen@example.com"
{
  "id": "cus_GHaC8VxZWYuwcl",
  "object": "customer",
  "account_balance": 0,
  "address": null,
  "balance": 0,
  "created": 1575239418,
  "currency": null,
  "default_source": null,
  "delinquent": false,
  "description": "Customer for jenny.rosen@example.com",
  "discount": null,
  "email": null,
  "invoice_prefix": "B92698A0",
  "invoice_settings": {
    "custom_fields": null,
    "default_payment_method": null,
    "footer": null
  },
  "livemode": false,
  "metadata": {
  },
  "name": null,
  "phone": null,
  "preferred_locales": [

  ],
  "shipping": null,
  "sources": {
    "object": "list",
    "data": [

    ],
    "has_more": false,
    "total_count": 0,
    "url": "/v1/customers/cus_GHa5lNIgPs4wF3/sources"
  },
  "subscriptions": {
    "object": "list",
    "data": [

    ],
    "has_more": false,
    "total_count": 0,
    "url": "/v1/customers/cus_GHa5lNIgPs4wF3/subscriptions"
  },
  "tax_exempt": "none",
  "tax_ids": {
    "object": "list",
    "data": [

    ],
    "has_more": false,
    "total_count": 0,
    "url": "/v1/customers/cus_GHa5lNIgPs4wF3/tax_ids"
  },
  "tax_info": null,
  "tax_info_verification": null
}

ダッシュボードで確認

https://dashboard.stripe.com/test/customers

image

発行された customer_id がURLにも反映されるみたいだ

https://dashboard.stripe.com/test/customers/cus_GHaC8VxZWYuwcl

image

Original by Github issue

https://github.com/YumaInaura/YumaInaura/issues/2796

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ

Twitter

https://twitter.com/YumaInaura

公開日時

2019-12-02

Discussion