{"id":13561026,"url":"https://github.com/stripe-samples/checkout-one-time-payments","last_synced_at":"2025-04-03T16:31:56.121Z","repository":{"id":38421887,"uuid":"202768861","full_name":"stripe-samples/checkout-one-time-payments","owner":"stripe-samples","description":"Use Checkout to quickly collect one-time payments.","archived":false,"fork":false,"pushed_at":"2024-04-25T23:33:21.000Z","size":9343,"stargazers_count":806,"open_issues_count":8,"forks_count":434,"subscribers_count":30,"default_branch":"main","last_synced_at":"2024-04-30T02:50:39.813Z","etag":null,"topics":["react","stripe","stripe-checkout"],"latest_commit_sha":null,"homepage":"https://checkout.stripe.dev/?mode=payment","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stripe-samples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-16T17:09:24.000Z","updated_at":"2024-05-03T00:25:38.857Z","dependencies_parsed_at":"2024-03-01T00:26:19.230Z","dependency_job_id":"a673d399-6ffe-4af5-ae81-1ae0f0ab482f","html_url":"https://github.com/stripe-samples/checkout-one-time-payments","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stripe-samples%2Fcheckout-one-time-payments","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stripe-samples%2Fcheckout-one-time-payments/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stripe-samples%2Fcheckout-one-time-payments/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stripe-samples%2Fcheckout-one-time-payments/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stripe-samples","download_url":"https://codeload.github.com/stripe-samples/checkout-one-time-payments/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247037065,"owners_count":20873090,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["react","stripe","stripe-checkout"],"created_at":"2024-08-01T13:00:51.770Z","updated_at":"2025-04-03T16:31:51.111Z","avatar_url":"https://github.com/stripe-samples.png","language":"CSS","funding_links":[],"categories":["CSS"],"sub_categories":[],"readme":"# Accept payments with Stripe Checkout\n\nThis sample shows you how to integrate with Stripe [Checkout](https://docs.stripe.com/checkout).\n\nBuilding a payment form UI from scratch is difficult -- input field validation, error message handing, and localization are just a few things to think about when designing a simple checkout flow.\n\nWe built [Checkout](https://docs.stripe.com/payments/checkout) to do that work for you so now you can focus on building the best storefront experience for your customers.\n\nOnce your customer is ready to pay, use [Stripe.js](https://github.com/stripe/stripe-js) to redirect them to the URL of your Stripe hosted payment page. 🥳\n\n## Demo\n\n- [Live demo](https://checkout.stripe.dev/)\n\nThe demo is running in test mode -- use `4242424242424242` as a test card number with any CVC + future expiration date.\n\nUse the `4000002500003155` test card number to trigger a 3D Secure challenge flow.\n\nRead more about testing on Stripe at https://stripe.com/docs/testing.\n\n\u003cdetails open\u003e\u003csummary\u003eUSD Cards Demo\u003c/summary\u003e\n\u003cimg src=\"./demo-gifs/checkout-demo.gif\" alt=\"A gif of the Checkout payment page rendering\" align=\"center\"\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eEUR Cards \u0026 iDEAL Demo\u003c/summary\u003e\n\u003cimg src=\"./demo-gifs/checkout-demo-ideal.gif\" alt=\"A gif of the Checkout payment page rendering\" align=\"center\"\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eMYR Cards \u0026 FPX Demo\u003c/summary\u003e\n\u003cimg src=\"./demo-gifs/checkout-demo-fpx.gif\" alt=\"A gif of the Checkout payment page rendering\" align=\"center\"\u003e\n\u003c/details\u003e\n\n## Features\n\n- 🌍 Localization in different languages\n- 🍎⌚️ Built-in support for Apple Pay and Google Pay\n- 🔒 Built-in dynamic 3D Secure (ready for SCA)\n- 🧾💵 Support for various payment methods. See the [docs](https://docs.stripe.com/payments/checkout/payment-methods) for details.\n- 🍨 HTML + Vanilla JavaScript as well as ⚛️ React clients\n\nFor more features see the [Checkout documentation](https://docs.stripe.com/payments/checkout).\n\n\n\u003c!-- prettier-ignore --\u003e\n|     | ✅\n:--- | :---:\n🔨 **Prebuilt checkout page.** Create a payment page that is customizable with your business' name and logo. |  ✅ |\n🔢 **Dynamic checkout amounts.** Dynamically define product amounts rather than relying on predefined Prices.   | ✅ |\n⌛ **Capture payments later.** Optionally split the capture and authorization steps to place a hold on the card and charge later. | ✅ |\n\n\n## How to run locally\n\nThis sample includes 8 server implementations in Java, JavaScript (Node), PHP, PHP-Slim, Python, Ruby, .NET, and Go. All servers implement the same routes for the client to communicate with. There is a HTML + Vanilla JavaScript as well as a React client implemention available.\n\nFollow the steps below to run locally.\n\n**1. Clone and configure the sample**\n\nThe Stripe CLI is the fastest way to clone and configure a sample to run locally.\n\n**Using the Stripe CLI**\n\nIf you haven't already installed the CLI, follow the [installation steps](https://docs.stripe.com/stripe-cli#install). The CLI is useful for cloning samples and locally testing webhooks and Stripe integrations.\n\nIn your terminal, run the Stripe CLI command to clone the sample:\n\n```\nstripe samples create checkout-one-time-payments\n```\n\nThe CLI will walk you through picking your integration type, server and client languages, and configuring your `.env` config file with your Stripe API keys.\n\n**Installing and cloning manually**\n\nIf you do not want to use the Stripe CLI, you can manually clone and configure the sample yourself:\n\n```\ngit clone https://github.com/stripe-samples/checkout-one-time-payments\n```\n\nCopy the .env.example file into a file named .env in the folder of the server you want to use. For example:\n\n```\ncp .env.example server/node/.env\n```\n\nYou will need a Stripe account in order to run the demo. Once you set up your account, go to the Stripe [developer dashboard](https://docs.stripe.com/development#api-keys) to find your API keys.\n\n```\nSTRIPE_PUBLISHABLE_KEY=\u003creplace-with-your-publishable-key\u003e\nSTRIPE_SECRET_KEY=\u003creplace-with-your-secret-key\u003e\n```\n\nThe other environment variables are configurable:\n\n`STATIC_DIR` tells the server where the client files are located and does not need to be modified unless you move the server files.\n\n`DOMAIN` is the domain of your website, where Checkout will redirect back to after the customer completes the payment on the Checkout page.\n\n**2. Create a Price**\n\n[![Required](https://img.shields.io/badge/REQUIRED-TRUE-ORANGE.svg)](https://shields.io/)\n\n\nYou can create Products and Prices in the Dashboard or with the API. This sample requires a Price to run. Once you've created a Price, and add its ID to your `.env`.\n\n`PRICE` is the ID of a [Price](https://docs.stripe.com/api/prices/create) for your product. A Price has a unit amount and currency.\n\n\nYou can quickly create a Price with the Stripe CLI like so:\n\n```sh\nstripe prices create --unit-amount 500 --currency usd -d \"product_data[name]=demo\"\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eWith Stripe Tax\u003c/summary\u003e\n  Stripe Tax lets you calculate and collect sales tax, VAT and GST with one line of code.\n\n  Before creating a price, make sure you have Stripe Tax set up in the dashboard: [Docs - Set up Stripe Tax](https://docs.stripe.com/tax/set-up).\n\n  Stripe needs to know what kind of product you are selling to calculate the taxes. For this example we will submit a tax code describing what kind of product is used: `txcd_10000000` which is 'General - Electronically Supplied Services'. You can find a list of all tax codes here: [Available tax codes](https://docs.stripe.com/tax/tax-codes). If you leave the tax code empty, Stripe will use the default one from your [Tax settings](https://dashboard.stripe.com/test/settings/tax).\n\n  ```sh\n  stripe products create \\\n    --name=\"demo\" \\\n    --tax-code=\"txcd_10000000\"\n  ```\n\n  From the response, copy the `id` and create a price. The tax behavior can be either `inclusive` or `exclusive`. For our example, we are using `exclusive`.\n\n  ```sh\n  stripe prices create \\\n    --unit-amount=500 \\\n    --currency=usd \\\n    --tax-behavior=exclusive \\\n    --product=\u003cINSERT_ID, like prod_ABC123\u003e\n  ```\n\n  More Information: [Docs - Update your Products and Prices](https://docs.stripe.com/tax/checkout#product-and-price-setup)\n\u003c/details\u003e\n\nWhich will return the json:\n\n```json\n{\n  \"id\": \"price_1Hh1ZeCZ6qsJgndJaX9fauRl\",\n  \"object\": \"price\",\n  \"active\": true,\n  \"billing_scheme\": \"per_unit\",\n  \"created\": 1603841250,\n  \"currency\": \"usd\",\n  \"livemode\": false,\n  \"lookup_key\": null,\n  \"metadata\": {\n  },\n  \"nickname\": null,\n  \"product\": \"prod_IHalmba0p05ZKD\",\n  \"recurring\": null,\n  \"tiers_mode\": null,\n  \"transform_quantity\": null,\n  \"type\": \"one_time\",\n  \"unit_amount\": 500,\n  \"unit_amount_decimal\": \"500\"\n}\n```\n\nTake the Price ID, in the example case `price_1Hh1ZeCZ6qsJgndJaX9fauRl`, and set the environment variable in `.env`:\n\n```sh\nPRICE=price_1Hh1ZeCZ6qsJgndJaX9fauRl\n```\n\n**3. Follow the server instructions on how to run**\n\nPick the server language you want and follow the instructions in the server folder README on how to run.\n\nFor example, if you want to run the Node server:\n\n```\ncd server/node \n# There's a README in this folder with instructions to run the server and how to enable Stripe Tax.\nnpm install\nnpm start\n```\n\nIf you're running the react client, then the sample will run in the browser at\n`localhost:3000` otherwise visit `localhost:4242`.\n\n\n**4. [Optional] Run a webhook locally**\n\nYou can use the Stripe CLI to easily spin up a local webhook.\n\nFirst [install the CLI](https://docs.stripe.com/stripe-cli) and [link your Stripe account](https://docs.stripe.com/stripe-cli#link-account).\n\n```\nstripe listen --forward-to localhost:4242/webhook\n```\n\nThe CLI will print a webhook secret key to the console. Set `STRIPE_WEBHOOK_SECRET` to this value in your `.env` file.\n\nYou should see events logged in the console where the CLI is running.\n\nWhen you are ready to create a live webhook endpoint, follow our guide in the docs on [configuring a webhook endpoint in the dashboard](https://docs.stripe.com/webhooks/setup#configure-webhook-settings).\n\n## FAQ\n\nQ: Why did you pick these frameworks?\n\nA: We chose the most minimal framework to convey the key Stripe calls and concepts you need to understand. These demos are meant as an educational tool that helps you roadmap how to integrate Stripe within your own system independent of the framework.\n\nQ: What happened to Plans and SKUs?\n\nA: Plans and SKUs were old ways to model recurring and one-off prices. We created the Prices API to unify the two concepts and make it easier to reason about your pricing catalog. You can still pass old Plan and SKU IDs to Checkout -- to learn more read [our docs](https://docs.stripe.com/payments/checkout/migrating-prices) but know that you do not need to migrate any of your existing SKUs and Plans.\n\n## Get support\nIf you found a bug or want to suggest a new [feature/use case/sample], please [file an issue](../../issues).\n\nIf you have questions, comments, or need help with code, we're here to help:\n- on [Discord](https://stripe.com/go/developer-chat)\n- on Twitter at [@StripeDev](https://twitter.com/StripeDev)\n- on Stack Overflow at the [stripe-payments](https://stackoverflow.com/tags/stripe-payments/info) tag\n- by [email](mailto:support+github@stripe.com)\n\nSign up to [stay updated with developer news](https://go.stripe.global/dev-digest).\n\n## Author(s)\n\n- [@adreyfus-stripe](https://twitter.com/adrind)\n- [@thorsten-stripe](https://twitter.com/thorwebdev)\n- [@cjavilla-stripe](https://twitter.com/cjav_dev)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstripe-samples%2Fcheckout-one-time-payments","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstripe-samples%2Fcheckout-one-time-payments","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstripe-samples%2Fcheckout-one-time-payments/lists"}