npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

oneoffice-api

v1.0.20

Published

Standardized OneOffice payment gateway.

Downloads

138

Readme

oneoffice-api

The standardized OneOffice API.

Supported Payment Channels

At the moment, only Maya Payment is supported. See their documentation here: https://developers.maya.ph/

Installation and Usage

Install the library using npm install oneoffice-api

Use Maya Checkout

import { createMayaCheckout } from "oneoffice-api";

const {data, error} = await createMayaCheckout({
    publicKey: "pk-NCLk7JeDbX1m22ZRMDYO9bEPowNWT5J4aNIKIbcTy2a",
    paymentDetails: {
      totalAmount: 100,
      items: [
        {
          name: "Foo Item",
          quantity: 1,
          description: "Foo item from General Store.",
          totalAmount: {
             value: 100,
          },
        },
      ],
      redirectUrl: {
         success: "http://yourapp.com/payment/success",
         failure: "http://yourapp.com/payment/fail",
         cancel: "http://yourapp.com/payment/cancel"
      },
      requestReferenceNumber: "23c210c4-6193-4896-a829-73a1dfc99bf9",
      metadata: {},
    },
    isSandbox: true // optional, default true, set to false in production
});

The following methods require a Supabase project with a transaction_table. Please see src/types/transaction for further reference.

Get Transaction List

import { getTransactionList } from "oneoffice-api";

const {data, count, error} = await getTransactionList({
  pagination: { from: 0, to: 10 },
  supabaseUrl: "<yoursupabaseurl>",
  supabaseAnonKey: "<yoursupabaseanonkey>",
});

// add filters
const {data, count, error} = await getTransactionList({
  pagination: {
    from: 0,
    to: 10,
  },
  filter: {
    appSourceUserId: "f69933b2-fe12-4fc4-bb56-63f370e40a45",
    appSource: "ba9e641e-d7fe-4d61-b9ee-85c919f457ca",
    status: "COMPLETED_PAYMENT",
    serviceName: "mailroom",
  },
  supabaseUrl: `${process.env.NEXT_PUBLIC_TRANSACTION_SUPABASE_URL}`,
  supabaseAnonKey: `${process.env.NEXT_PUBLIC_TRANSACTION_SUPABASE_ANON_KEY}`,
});

// order by date ascending
const {data, count, error} = await getTransactionList({
  pagination: {
    from: 0,
    to: 10,
  },
  orderByDateAscending: true,
  supabaseUrl: `${process.env.NEXT_PUBLIC_TRANSACTION_SUPABASE_URL}`,
  supabaseAnonKey: `${process.env.NEXT_PUBLIC_TRANSACTION_SUPABASE_ANON_KEY}`,
});

Get Transaction Record

import { getTransactionRecord } from "oneoffice-api";

const {data, error} = await getTransactionRecord({
  transactionReferenceId: "23c210c4-6193-4896-a829-73a1dfc99bf9",
  supabaseUrl: "<yoursupabaseurl>",
  supabaseAnonKey: "<yoursupabaseanonkey>",
});

Create Transaction

import { createTransactionRecord } from "oneoffice-api";

const {data, error} = await createTransactionRecord({
  transactionData: {
    transaction_reference_id: "23c210c4-6193-4896-a829-73a1dfc99bf9",
    transaction_service_name: "Buy n Sell",
    transaction_payment_channel: "paymaya",
    transaction_total_amount: 100,
    transaction_app_source_user_id: "88274006-487f-49ba-b82e-99a2b2387d19",
    transaction_app_source: "ba9e641e-d7fe-4d61-b9ee-85c919f457ca", // app_source_id
  },
  supabaseUrl: "<yoursupabaseurl>",
  supabaseAnonKey: "<yoursupabaseanonkey>",
});

Update Transaction

import { updateTransactionRecord } from "oneoffice-api";

const {data, error} = await updateTransactionRecord({
  transactionData: {
    transaction_id: "1a1a1394-81aa-490f-8a94-4cb64b0f5b86",
    transaction_reference_id: "23c210c4-6193-4896-a829-73a1dfc99bf9",
    transaction_service_name: "Buy n Sell",
    transaction_payment_channel: "paymaya",
    transaction_total_amount: 100,
    transaction_app_source_user_id: "88274006-487f-49ba-b82e-99a2b2387d19",
    transaction_app_source: "ba9e641e-d7fe-4d61-b9ee-85c919f457ca", // app_source_id
  },
  supabaseUrl: "<yoursupabaseurl>",
  supabaseAnonKey: "<yoursupabaseanonkey>",
});

Use Maya Checkout With Transaction

import { createMayaCheckoutWithTransaction } from "oneoffice-api";

const referenceNumber = "23c210c4-6193-4896-a829-73a1dfc99bf9";

const paymentDetails = {
  totalAmount: 100,
  items: [
    {
      name: "Foo Item",
      quantity: 1,
      description: "Foo item from General Store.",
      totalAmount: {
          value: 100,
      },
    },
  ],
  redirectUrl: {
      success: "http://yourapp.com/payment/success",
      failure: "http://yourapp.com/payment/fail",
      cancel: "http://yourapp.com/payment/cancel"
  },
  requestReferenceNumber: referenceNumber,
  metadata: {},
};

const transactionData = {
  transaction_reference_id: referenceNumber,
  transaction_service_name: "Buy n Sell",
  transaction_payment_channel: "paymaya",
  transaction_total_amount: 100,
  transaction_app_source_user_id: "88274006-487f-49ba-b82e-99a2b2387d19",
  transaction_app_source: "ba9e641e-d7fe-4d61-b9ee-85c919f457ca", // app_source_id
}

// will create maya checkout and transaction record
// then redirect user to maya checkout page
await createMayaCheckoutWithTransaction({
  publicKey: "pk-NCLk7JeDbX1m22ZRMDYO9bEPowNWT5J4aNIKIbcTy2a",
  paymentDetails,
  transactionData,
  supabaseUrl: "<yoursupabaseurl>",
  supabaseAnonKey: "<yoursupabaseanonkey>",
});

Fetch All App Source

import { getAppSourceList } from "oneoffice-api";

const {data, error} = await getAppSourceList({
  supabaseUrl: "<yoursupabaseurl>",
  supabaseAnonKey: "<yoursupabaseanonkey>",
});

Fetch All Region

import { getRegion } from "oneoffice-api";

const { data, error } = await getRegion({
  supabaseUrl: "<yoursupabaseurl>",
  supabaseAnonKey: "<yoursupabaseanonkey>",
});

Fetch All Province Based On Region

import { getProvince } from "oneoffice-api";

const { data, error } = await getProvince({
  supabaseUrl: "<yoursupabaseurl>",
  supabaseAnonKey: "<yoursupabaseanonkey>",
  regionId: "<regionId>"
});

Fetch All Cities Based On Province

import { getCity } from "oneoffice-api";

const { data, error } = await getCity({
  supabaseUrl: "<yoursupabaseurl>",
  supabaseAnonKey: "<yoursupabaseanonkey>",
  provinceId: "<provinceId>"
});

Fetch All Barangay With Zip Code Based On City

import { getBarangay } from "oneoffice-api";

const { data, error } = await getBarangay({
  supabaseUrl: "<yoursupabaseurl>",
  supabaseAnonKey: "<yoursupabaseanonkey>",
  cityId: "<cityId>"
});

Typescript

Typescript supported. Import types from src/types.

License

ISC License

Copyright (c) 2024 Juan Carlos Lumingkit [email protected]

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.