Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

eggplantSword's avatar

How to use node.js API

I'm trying to implement a node.js API in my project but I'm at a complete loss of what to do or where to start. This library is for credit card payments https://github.com/cayasso/gpayments I haven't used a library like this before so I'm confused how to get it to work and there aren't many instructions on the github page.

What should I do to get it working?

0 likes
6 replies
Snapey's avatar

you are unlikely to be able to use this unless you also setup a node.js server, which is outside the scope of most people here

eggplantSword's avatar

@snapey Did you see the other link I provided? I was told maybe I could use the API directly without the library above. Would that be possible?

Sinnbeck's avatar

You most likely are yes but sadly I don't speak Spanish so I can't much sense of it

eggplantSword's avatar

@sinnbeck Realitically I need only the authentication, accounts, changes parts. This is for simple online store so payment plans or subscriptions aren't needed. I'll translate anything you need, here I translated the Create a Charge part so you can see.

Create a Charge
await gpApi.charges.create({
  amount: 90.32,
  customer_key: 'GfGsOKTZVlTKyn7khcihXYuEUx0nBxb',
  description: 'Plan 1 service charge',
  entity_description: 'Plan 1',
  currency: 'usd',
})
Returns a HTTP 201 Created status

This endpoint creates a charge, in other words, creates a charge and takes it out of the client''s card, using their financial data.

HTTP Request
POST https://api.payments.4geeks.io/v1/charges/create/

Fields
Parameter	Description	Type	Required
customer_key	Customer key, for getting the card info of the associated client.	string	true

amount	Amount of money for the charge.	float	true

description	Description with which you can search for the transaction.	string	true

entity_description	Description for the account status of the client''s card. Max 22 caracteres.	string	false

currency	Currency of the transaction (crc, usd), by default the customer currency is going to be used. string	false
eggplantSword's avatar

@sinnbeck Regardless of language, what are the base steps to implement something like this? According to the javascript site first you need to send your credentials via oAuth2 and get a token to then send along with the rest of the requests. That's the first hurdle since the requests use js, how would I go about doing that? I pretty desperate at this point, I don't have many options to start with.

Please or to participate in this conversation.