Giter Club home page Giter Club logo

Comments (1)

karlr-stripe avatar karlr-stripe commented on September 18, 2024 1

Hey @Syirrus, it sounds like what you are looking for here is metadata, which is arbitrary information you can attach to an object in Stripe's API.

In terms of implementing that as part of this demo, you'd want to add your hidden input tag in index.html:

<input type="hidden" id="user_id" value="user_123">

and then access it when the form is submitted:

var userId = document.getElementById("user_id").value

You might then pass it to the payOrder function, in order to send the value to the backend, around here :
https://github.com/stripe/stripe-payments-demo/blob/c242611d0abd2ca99ec0557d3cf5855657ade2cc/public/javascripts/payments.js#L391

order.userId = userId;
const response = await store.payOrder(order, source);

You can then attach it to the charge object created on the backend server:
https://github.com/stripe/stripe-payments-demo/blob/c242611d0abd2ca99ec0557d3cf5855657ade2cc/server/node/routes.js#L63-L75

charge = await stripe.charges.create(
          {
            source: source.id,
            amount: order.amount,
            metadata : {userId : order.userId}
            ....
         }
)

This issue tracker is for bugs or issues directly related to this project, and not for general support. Please feel free to reach out to https://support.stripe.com/email and we would be glad to help further!

from stripe-payments-demo.

Related Issues (20)

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.