0.0.1 • Published 4 years ago

picpay-nodejs v0.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

picpay-nodejs

Integration with PicPay Payments for Node.js

Configuration

Seller account required in picpay website.

const PicPayNodeJS = require("picpay-nodejs");
const picpay = new PicPayNodeJS({
  x_seller_token: "123",
  picpay_token: "456",
  callback_url: "/",
  return_url: "/"
})

Create Payment

async function newTransaction(){
  const order = {
    referenceId: "100", // string [ Generated By Application ]
    callbackUrl: "callbackUrl", // string
    returnUrl: "returnUrl", // string
    value: 19.90, // float
    expiresAt: "2022-08-02T16:00:00-03:00", // string
    buyer: {
      firstName: "Hello", // string
      lastName: "World Da Silva", // string
      document: "123.456.789-10", // string
      email: "test@picpay.com", // string
      phone: "+55 11 12345-6789" // string
    }
  }
  const result = await picpay.createPayment(order);
  console.log(result);
}
newTransaction();

Get Payment Status

async function getTransaction(){
  // _referenceId -> String [ Generated By Application ]
  const status = await picpay.getPaymentStatus("_referenceId");
  console.log(status);
}

getTransaction();

Cancel Payment

async function cancelTransaction(){
  // _referenceId -> String [ Generated By Application ]
  // _authorizationId -> String [ If Transaction Already Approved ]
  const cancel = await picpay.cancelPayment("_referenceId", "_authorizationId");
  console.log(cancel);
}

cancelTransaction();