Stripeのinvoiceを作成するとき、自由記載できる項目があります。
- メモ(description)
- カスタムフィールド(name, value)
- フッター
これらの項目について、何文字まで利用できるか気になったので、試してみました。
おすすめの方
- Stripeのinvoiceでメモ・カスタムフィールド・フッターの最大長を知りたい方
結論
項目 | 最大長 |
---|---|
メモ(description) | 500 |
カスタムフィールド(name) | 30 |
カスタムフィールド(value) | 30 |
フッター | 5000 |
画面や文字列によって収まりきらない可能性があるので、しっかり確認してください(とくにカスタムフィールド)。
Stripe SDKでinvoiceを作成する(アルファベット)
とりあえず、ぜんぶ256文字で試す
app.py
import stripe
from pprint import pprint
stripe.api_key = "sk_test_xxx"
def main():
options = {
"customer": "cus_aaa",
"collection_method": "send_invoice",
"days_until_due": 30,
"description": "d" * 256,
"footer": "f" * 256,
"custom_fields": [
{
"name": "n" * 256,
"value": "v" * 256,
},
],
}
stripe.Invoice.create(**options)
if __name__ == "__main__":
main()
カスタムフィールド(name)は、最大30文字のようです。
stripe._error.InvalidRequestError: Request req_VocMzGP1FvRkKu: Invalid string: nnnnnnnnnn...nnnnnnnnnn; must be at most 30 characters
カスタムフィールド(name)を30文字にして試す
app.py
import stripe
from pprint import pprint
stripe.api_key = "sk_test_xxx"
def main():
options = {
"customer": "cus_aaa",
"collection_method": "send_invoice",
"days_until_due": 30,
"description": "d" * 256,
"footer": "f" * 256,
"custom_fields": [
{
"name": "n" * 30,
"value": "v" * 256,
},
],
}
stripe.Invoice.create(**options)
if __name__ == "__main__":
main()
カスタムフィールド(value)も最大30文字のようです。
stripe._error.InvalidRequestError: Request req_iJ82HBiLi8H1r3: Invalid string: vvvvvvvvvv...vvvvvvvvvv; must be at most 30 characters
カスタムフィールド(name, value)を30文字にして試す
app.py
import stripe
from pprint import pprint
stripe.api_key = "sk_test_xxx"
def main():
options = {
"customer": "cus_aaa",
"collection_method": "send_invoice",
"days_until_due": 30,
"description": "d" * 256,
"footer": "f" * 256,
"custom_fields": [
{
"name": "n" * 30,
"value": "v" * 30,
},
],
}
stripe.Invoice.create(**options)
if __name__ == "__main__":
main()
これは成功しました。
メモとフッターを1000文字にして試す
app.py
import stripe
from pprint import pprint
stripe.api_key = "sk_test_xxx"
def main():
options = {
"customer": "cus_aaa",
"collection_method": "send_invoice",
"days_until_due": 30,
"description": "d" * 1000,
"footer": "f" * 1000,
"custom_fields": [
{
"name": "n" * 30,
"value": "v" * 30,
},
],
}
stripe.Invoice.create(**options)
if __name__ == "__main__":
main()
メモ(description)は、最大500文字のようです。
stripe._error.InvalidRequestError: Request req_8b7rHNyVOIkVXZ: Invalid string: dddddddddd...dddddddddd; must be at most 500 characters
フッターだけを1000文字にして試す
app.py
import stripe
from pprint import pprint
stripe.api_key = "sk_test_xxx"
def main():
options = {
"customer": "cus_aaa",
"collection_method": "send_invoice",
"days_until_due": 30,
"description": "d" * 500,
"footer": "f" * 1000,
"custom_fields": [
{
"name": "n" * 30,
"value": "v" * 30,
},
],
}
stripe.Invoice.create(**options)
if __name__ == "__main__":
main()
これは成功しました。(するのか)
フッターを10000文字にして試す
app.py
import stripe
from pprint import pprint
stripe.api_key = "sk_test_xxx"
def main():
options = {
"customer": "cus_aaa",
"collection_method": "send_invoice",
"days_until_due": 30,
"description": "d" * 500,
"footer": "f" * 10000,
"custom_fields": [
{
"name": "n" * 30,
"value": "v" * 30,
},
],
}
stripe.Invoice.create(**options)
if __name__ == "__main__":
main()
メモ(description)は、最大5000文字のようです。
stripe._error.InvalidRequestError: Request req_sXOI5BOvpj0KDr: Invalid string: ffffffffff...ffffffffff; must be at most 5000 characters
最大長でinvoiceを作成してみる
app.py
import stripe
from pprint import pprint
stripe.api_key = "sk_test_xxx"
def main():
options = {
"customer": "cus_aaa",
"collection_method": "send_invoice",
"days_until_due": 30,
"description": "d" * 500,
"footer": "f" * 5000,
"custom_fields": [
{
"name": "n" * 30,
"value": "v" * 30,
},
],
}
stripe.Invoice.create(**options)
if __name__ == "__main__":
main()
プレビュー画面の様子です。
Stripe SDKでinvoiceを作成する(日本語)
文字数の最大値はアルファベットと同じだった
それぞれ+1した値だと、ダメでした。つまり、文字数の最大値はアルファベットと同じでした。
app.py
import stripe
from pprint import pprint
stripe.api_key = "sk_test_xxx"
def main():
options = {
"customer": "cus_aaa",
"collection_method": "send_invoice",
"days_until_due": 30,
"description": "メ" * 500,
"footer": "フ" * 5000,
"custom_fields": [
{
"name": "名" * 30,
"value": "値" * 30,
},
],
}
stripe.Invoice.create(**options)
if __name__ == "__main__":
main()
ただし、カスタムフィールドは、長すぎて途切れています。
(長すぎるので省略)