New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

payrex-node

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

payrex-node

PayRex Node JS Library

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
146
increased by484%
Maintainers
0
Weekly downloads
 
Created
Source

PayRex Node.js

PayRex Node library provides Node applications an easy access to the PayRex API. Explore various classes that represents PayRex API resources on object instantiation.

Requirements

Node 12 or higher.

Installation

If you want to use the package, run the following command:

npm install payrex-node
# or
yarn add payrex-node

Getting Started

Simple usage looks like:

const payrex = require('payrex-node')('sk_test_...');

payrex.paymentIntents.retrieve('pi_...')
  .then(paymentIntent => console.log(paymentIntent.id))

payrex.paymentIntents.create({
  amount: 10000,
  currency: 'PHP',
  description: 'Dino Treat',
  payment_methods: ['gcash', 'card']
})
  .then(paymentIntent => console.log(paymentIntent.id))

Or using async/await:

const payrex = require('payrex-node')('sk_test_...');

const paymentIntent = await payrex.paymentIntents.retrieve('pi_...');

console.log(paymentIntent.id);

Handle errors

const payrex = require('payrex-node')('sk_test_...');

payrex.paymentIntents.create({
  amount: 10000
})
  .then(paymentIntent => console.log(paymentIntent.id))
  .catch(error => {
    // Handle errors
    console.error(error.name);
    console.error(error.errors);
  });

Verify webhook signature

try {
  payload = '{"id":"evt_...","resource":"event","type":"payment_intent.succeeded","data":{...';
  signatureHeader = 't=1715236958,te=,li=...';
  webhookSecretKey = 'whsk_...';

  payrex.webhooks.parseEvent(payload, signatureHeader, webhookSecretKey);
} catch (error) {
  // Handle invalid signature
}

Keywords

FAQs

Package last updated on 06 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc