GithubHelp home page GithubHelp logo

rahman123 / adding-sales-tax Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stripe-archive/adding-sales-tax

0.0 2.0 0.0 444 KB

Learn how to use PaymentIntents to build a simple checkout flow

CSS 24.43% HTML 8.66% JavaScript 22.30% Java 17.18% PHP 10.19% Python 9.02% Ruby 8.22%

adding-sales-tax's Introduction

Sales Tax Sample

There are two things certain in life: death and taxes.

Use this sample to learn how to build a minimal checkout form with a sales tax estimator and charge a card using the new Payment Intents API. We use simplified logic for calculating sales tax, so you can replace the logic with your own method to suit your unique business needs. The amount of sales tax to collect depends on the product, customer location, and local tax laws.

Demo

See a hosted version of the sample or fork on codesandbox.io

The hosted demo is running in test mode -- use 4242424242424242 as a test card number with any CVC + future expiration date.

Use the 4000000000003220 test card number to trigger a 3D Secure challenge flow.

Read more about test cards on Stripe at https://stripe.com/docs/testing.

Checkout page with sales tax

There are two ways you can implementate this sample:

  • Using webhooks to run any post-payment process (e.g. sending an email, shipping an order)
  • Confirming the payment on your server and running any post-payment process immediately after (without using webhooks)
Using webhooks Without webhooks
๐Ÿ’ณ Collecting card and cardholder details. Both integrations use Stripe Elements to build a custom checkout form. โœ… โœ…
๐Ÿ™… Handling card authentication requests and declines. Attempts to charge a card can fail if the bank declines the purchase or requests extra authentication. โœ… โœ…
โ†ช๏ธ Easily scalable to other payment methods. Webhooks enable easy adoption of other asynchroneous payment methods like direct debits and push-based payment flows. โœ… โŒ
๐Ÿ’ฐ Tracking multiple payment attempts in a PaymentIntent. Automatic confirmation lets you use a single PaymentIntent for multiple payment attempts so you can track the customer's payment session in one object. โœ… โŒ

How to run locally

Before you run the sample, be sure to you have a Stripe account with its own set of API keys.

Each sample implementation includes 5 servers in Node, Ruby, Python, Java, and PHP in the /server/ directory.

1. Clone and configure the sample

The Stripe CLI is the fastest way to clone and configure a sample to run locally.

Using the Stripe CLI

If you haven't already installed the CLI, follow the installation steps in the project README. The CLI is useful for cloning samples and locally testing webhooks and Stripe integrations.

In your terminal shell, run the Stripe CLI command to clone the sample:

stripe samples create adding-sales-tax

The CLI will walk you through picking your integration type, server and client languages, and configuring your .env config file with your Stripe API keys.

Installing and cloning manually

If you do not want to use the Stripe CLI, you can manually clone and configure the sample yourself:

git clone https://github.com/stripe-samples/adding-sales-tax

Copy the .env.example file into a file named .env in the folder of the server you want to use. For example:

cp .env.example using-webhooks/server/node/.env

Go to the Stripe developer dashboard to find your API keys.

STRIPE_PUBLISHABLE_KEY=<replace-with-your-publishable-key>
STRIPE_SECRET_KEY=<replace-with-your-secret-key>

2. Follow the server instructions on how to run:

Pick the server language you want and follow the instructions in the server folder README on how to run.

For example, if you want to run the Node server in using-webhooks:

cd using-webhooks/server/node # there's a README in this folder with instructions
npm install
npm start

FAQ

Q: Why did you pick these frameworks?

A: 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.

Q: Can you show me how to build X?

A: We are always looking for new sample ideas, please email [email protected] with your suggestion!

Author(s)

@adreyfus-stripe

adding-sales-tax's People

Contributors

adreyfus-stripe avatar ctrudeau-stripe avatar thorsten-stripe avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.