I am working on an Angular2 application that requires integration with a payment API.
https://stripe.com/docs/quickstart
When following the code sample in the Node.js section from the provided link, the instructions suggest using the following code structure:
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
var stripe = require("stripe")("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
// Token is created using Stripe.js or Checkout!
// Get the payment token submitted by the form:
var token = request.body.stripeToken; // Using Express
// Charge the user's card:
var charge = stripe.charges.create({
amount: 1000,
currency: "usd",
description: "Example charge",
source: token,
}, function(err, charge) {
// asynchronously called
});
Although we have installed requireJS with NPM, we encountered an error when trying to run the application:
Cannot find name 'require'.
L48: pagar() { L49: var stripe = require("stripe")("sk_test_ayzCMDmjq2QOIW0s3dTihxNR");