简体   繁体   中英

Reference error! Not defined using node.js / Runkit

I'm trying to use this https://npm.runkit.com/globalpayments-api script but I can't figure what I'm doing wrong.

When I run the Runkit and add the first code to create a new Credit Card it throws error "ReferenceError: CreditCardData is not defined":

const card = new CreditCardData();
card.number = "4111111111111111";
card.expMonth = "12";
card.expYear = "2025";
card.cvn = "123";

How I can point CreditCardData to var globalpaymentsApi = require("globalpayments-api") which contains all this consts?

Demo: https://runkit.com/embed/8hidbubpbk8n

What I'm doing wrong?

Most likely in your code, function CreditCardData() doesn't exist - this means you didn't import it. Try adding this at the beginning of your .js file:

const { CreditCardData } = require('globalpayments-api');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM