You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@cafebazaar/payment-sdk

Package Overview
Dependencies
Maintainers
5
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@cafebazaar/payment-sdk

Cafebazaar Payment SDK for Javascript

npmnpm
Version
0.2.0
Version published
Weekly downloads
0
Maintainers
5
Weekly downloads
 
Created
Source

Bazaar Payment SDK

Bazaar Payment SDK is a Javascript Library to Deal with Bazaar Payment Process in Client.

Install

npm i @cafebazaar/payment-sdk
# or
yarn add @cafebazaar/payment-sdk

ESM, CommonJS

script.js

// ESM
import { observePaymentStatus, startPaymentProcess } from '@cafebazaar/payment-sdk';

// CommonJS
const { observePaymentStatus, startPaymentProcess } = require('@cafebazaar/payment-sdk');

IIFE

index.html

<script src="https://unpkg.com/@cafebazaar/payment-sdk@x.x.x/dist/index.browser.js"></script>
<script>
  const { observePaymentStatus, startPaymentProcess } = window.cafeBazaarPaymentSdk;
</script>

Usage

  • getPaymentStatus()
  • getPaymentUrl()
  • observePaymentStatus()
  • unobservePaymentStatus()
  • startPaymentProcess()

Get Payment Status

Get Status of a Payment.

getPaymentStatus(checkoutToken: CheckoutToken): Promise<PaymentStatus>

Example

getPaymentStatus(12345678).then((paymentStatus) => {
  console.log(paymentStatus);
});

Get Payment Url

Get Url of Payment for Manual Actions

function getPaymentUrl(checkoutToken: CheckoutToken, addRedirectQuery: boolean): string

Example

getPaymentUrl(12345678, true); // httsp://cafebazaar.ir/user/payment?token=12345678&redirect=...
getPaymentUrl(12345678, false); // httsp://cafebazaar.ir/user/payment?token=12345678

Observe Payment Status

Observe Payment Status. It Will Register a Listener to the Payment Status and Fire the callback Param When It's Changed. It's Also Fire the callback on Initiation.

observePaymentStatus(checkoutToken: CheckoutToken, callback: PaymentStatusListenerCallback): void

Example

observePaymentStatus(12345678, (paymentStatus) => {
  console.log(paymentStatus); // Payment Status Changed!
});

UnObserve Payment Status

Un-Observe Payment Status. It Will UnRegister the Previous Listener of the Payment Status.

unobservePaymentStatus(checkoutToken: CheckoutToken, callback: PaymentStatusListenerCallback): void

Example

const callback = (paymentStatus) => {
  console.log(paymentStatus); // Payment Status Changed!
};

observePaymentStatus(12345678, callback);
///
///
unobservePaymentStatus(12345678, callback); // No More Calls on Callback Function

Start Payment Process

Start Payment Process. Based on Current Javascript Runtime, It May Shows a Popup to User and Resolves When Popup is Closed Or Redirect the Whole Document To Popup Url and Go Back to Current Url After Jobs Done (So Never Resolves In This Situation). To Understand What's Happening on the Payment, Register a Listener to Payment via observePaymentStatus Before Calling This.

function startPaymentProcess(checkoutToken: CheckoutToken): Promise<void>

Example

startPaymentProcess(12345678); // May Open a Popup or Redirect the Document and Comeback to Current Url After That

FAQs

Package last updated on 07 Jun 2022

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