0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Stripe CLI ターミナルからクレカ情報を登録するコマンド

Last updated at Posted at 2024-10-22

概要

Stripe CLIを使ってターミナルからクレカ情報を登録するコマンドを簡単に紹介する。

前提

下記の方法でCLIの導入とCLIでのログインができていること。

方法

  1. Stripe CLIでのログインができている状態で下記を実行する。

    stripe payment_intents create  \
        --amount=500 \
        --currency=gbp \
        --payment-method=pm_card_visa
    
  2. それっぽいクレカ情報系のレスポンスが得られれば正常に動いている。筆者の場合、下記のようなレスポンスが得られた。

    $ stripe payment_intents create  \
        --amount=500 \
        --currency=gbp \
        --payment-method=pm_card_visa
    {
      "id": "pi_3OJdtHEwNfmSaNN21yk3dxoN",
      "object": "payment_intent",
      "amount": 500,
      "amount_capturable": 0,
      "amount_details": {
        "tip": {}
      },
      "amount_received": 0,
      "application": null,
      "application_fee_amount": null,
      "automatic_payment_methods": {
        "allow_redirects": "always",
        "enabled": true
      },
      "canceled_at": null,
      "cancellation_reason": null,
      "capture_method": "automatic",
      "client_secret": "pi_3OJdtHEwNfmSaNN21yk3dxoN_secret_HregMKip8Z35kAsmpncOgUhET",
      "confirmation_method": "automatic",
      "created": 1701703019,
      "currency": "gbp",
      "customer": null,
      "description": null,
      "invoice": null,
      "last_payment_error": null,
      "latest_charge": null,
      "livemode": false,
      "metadata": {},
      "next_action": null,
      "on_behalf_of": null,
      "payment_method": "pm_1OJdtHEwNfmSaNN2Nsl95ubw",
      "payment_method_configuration_details": null,
      "payment_method_options": {
        "card": {
          "installments": null,
          "mandate_options": null,
          "network": null,
          "request_three_d_secure": "automatic"
        }
      },
      "payment_method_types": [
        "card"
      ],
      "processing": null,
      "receipt_email": null,
      "review": null,
      "setup_future_usage": null,
      "shipping": null,
      "source": null,
      "statement_descriptor": null,
      "statement_descriptor_suffix": null,
      "status": "requires_confirmation",
      "transfer_data": null,
      "transfer_group": null
    
  3. なお、今はまだクレカ情報をStripeに登録したに過ぎず、この後顧客と今登録したクレカ情報を紐付ける必要がある。

  4. 余談だが今は下記の様なコマンドでクレカ情報を作ることはほぼ不可能、実行してもエラーで弾かれる。テスト環境でも望ましく無いらしい。一応サポートに連絡すれば解除してもらえる可能性はあるっぽい。

    stripe payment_methods create \
      --type=card \
      -d "card[number]"=4242424242424242 \
      -d "card[exp_month]"=8 \
      -d "card[exp_year]"=2024 \
      -d "card[cvc]"=314
    

参考文献

上記のStripe CLIを確認

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?