Productsstripe-utilstools

[stripe-utils Version1.1.1] Stripeのdecline codeをマッピングする機能をアップデートしました

Stripeのdecline codeから、公式ドキュメントにある説明文を取得するメソッドをstripe-utilsという名前のライブラリでリリースしています。 使い方 できること Stripeのcustomers.cr […]

広告ここから
広告ここまで

Stripeのdecline codeから、公式ドキュメントにある説明文を取得するメソッドをstripe-utilsという名前のライブラリでリリースしています。

使い方

const { getDeclineDescription } = require('stripe-utils')
const { code } = getDeclineDescription("try_again_later")
console.log(code)

{
    "description": "The card has been declined for an unknown reason.", 
    "nextSteps": "Ask the customer to attempt the payment again. If subsequent payments are declined, the customer should contact their card issuer for more information."
}

できること

Stripeのcustomers.createなどのAPIはdecline_codeしか返してこないので、ユーザーに表示するメッセージは自前で用意する必要がありました。が、このライブラリを使うことでdecline_codeさえあればこちらからユーザーに表示すべき内容を出すことができます。

できなかったこと

nextStepsの文章を読んでいただくとわかるのですが、Stripeのドキュメントはあくまで運営者向けに書かれています。そのため、ユーザーに「次こうしてくださ」という風に案内するには不適切でした。

Version1.1.0でできるようになったこと

チームメンバー(Digitalcube)のDanielがこの文章を全てエンドユーザー向けに書き換えてくれました。

const { getDeclineDescription } = require('stripe-utils')
const { code } = getDeclineDescription("try_again_later")
console.log(code)

{
  "description": "The card has been declined for an unknown reason.",
  "nextSteps": "Ask the customer to attempt the payment again. If subsequent payments are declined, the customer should contact their card issuer for more information.",
  "nextUserAction": "Please try again. If it still cannot be processed, the please contact your card issuer.",
  "translations": {
    "ja_JP": {
      "description": "カードは未知の理由で拒否されました。",
      "nextUserAction": "もう一度やり直してください。それでも処理できない場合は、カード発行会社にお問い合わせください。"
    }
  }
}

さらに日本語翻訳までついています。

文言・翻訳のリクエストについて

ここにコードがあります。Pull Requestください。

ブックマークや限定記事(予定)など

WP Kyotoサポーター募集中

WordPressやフロントエンドアプリのホスティング、Algolia・AWSなどのサービス利用料を支援する「WP Kyotoサポーター」を募集しています。
月額または年額の有料プランを契約すると、ブックマーク機能などのサポーター限定機能がご利用いただけます。

14日間のトライアルも用意しておりますので、「このサイトよく見るな」という方はぜひご検討ください。

広告ここから
広告ここまで

Related Category posts