From 8f0fc979bbfeb39418c131c13e59a2e005a98c29 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone <exarkun@twistedmatrix.com> Date: Wed, 2 Nov 2022 10:38:37 -0400 Subject: [PATCH] You really need a payment link, not a product. --- admin/create-payment-link.sh | 41 ++++++++++++++++++++++++++++++++++++ admin/create-product.sh | 16 -------------- 2 files changed, 41 insertions(+), 16 deletions(-) create mode 100644 admin/create-payment-link.sh delete mode 100644 admin/create-product.sh diff --git a/admin/create-payment-link.sh b/admin/create-payment-link.sh new file mode 100644 index 00000000..abd8f529 --- /dev/null +++ b/admin/create-payment-link.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -x +set -euo pipefail + +KEY=$1 +shift + +PRODUCT_ID=$( + curl https://api.stripe.com/v1/products \ + -u "${KEY}:" \ + -d "name=30 GiB-months" \ + -d "description=30 GiB-months of Private.Storage storage × time" \ + -d "statement_descriptor=PRIVATE STORAGE" \ + -d "url=https://private.storage/" | + jp --unquoted id + ) + +echo "Product: $PRODUCT_ID" + +PRICE_ID=$( + curl https://api.stripe.com/v1/prices \ + -u "${KEY}:" \ + -d "currency=USD" \ + -d "unit_amount=650" \ + -d "tax_behavior=exclusive" \ + -d "product=${PRODUCT_ID}" | + jp --unquoted id + ) + +echo "Price: $PRICE_ID" + +LINK_URL=$( + curl https://api.stripe.com/v1/payment_links \ + -u "${KEY}:" \ + -d "line_items[0][price]=${PRICE_ID}" \ + -d "line_items[0][quantity]=1" | + jp --unquoted url + ) + +echo "Payment link: $LINK_URL" diff --git a/admin/create-product.sh b/admin/create-product.sh deleted file mode 100644 index 797e825d..00000000 --- a/admin/create-product.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -KEY=$1 -shift - -curl https://api.stripe.com/v1/products \ - -u "${KEY}:" \ - -d "name=30 GiB-months" \ - -d "description=30 GiB-months of Private.Storage storage × time" \ - -d "default_price_data[currency]=USD" \ - -d "default_price_data[unit_amount]=650" \ - -d "default_price_data[tax_behavior]=exclusive" \ - -d "statement_descriptor=PRIVATE STORAGE" \ - -d "url=https://private.storage/" -- GitLab