Skip to content

Twispay/api-sdk

Repository files navigation

@xmoney/api-sdk

Instalaltion

npm install @xmoney/api-sdk

Usage

Get needed params for checkout initialization:

import xMoney from "@xmoney/api-sdk";

const xMoneyCheckout = new xMoney({
  secretKey: "sk_test_secretKey",
});

const order = xMoneyCheckout.initializeCheckout({
  publicKey: 'pk_test_abc123',
  customer: {
    identifier: "customerIdentifier",
    firstName: "John",
    lastName: "Doe",
    country: "RO",
    city: "Bucharest",
    email: "[email protected]",
  },
  order: {
    orderId: "myUniqueOrderId",
    description: "Order Description",
    type: "purchase",
    amount: 100,
    currency: "EUR",
  },
  cardTransactionMode: "authAndCapture",
  backUrl: "https://127.0.0.1:8080",
});

Get HTML for hosted checkout (mobile/webview):

import xMoney from "@xmoney/api-sdk";

const xMoneyCheckout = new xMoney({
  secretKey: "sk_test_secretKey",
});

const orderHtml = xMoneyCheckout.initializeHostedCheckout({
  publicKey: 'pk_test_abc123',
  customer: {
    identifier: "customerIdentifier",
    firstName: "John",
    lastName: "Doe",
    country: "RO",
    city: "Bucharest",
    email: "[email protected]",
  },
  order: {
    orderId: "myUniqueOrderId",
    description: "Order Description",
    type: "purchase",
    amount: 100,
    currency: "EUR",
  },
  cardTransactionMode: "authAndCapture",
  backUrl: "https://127.0.0.1:8080",
});

How to decrypt order webhook payload:

import xMoney from "@xmoney/api-sdk";

const xMoneyCheckout = new xMoney({
  secretKey: "sk_test_secretKey",
});

const webhookPayload = 'ecryptedPayload'; 

console.log(
    xMoneyCheckout.decryptOrderResponse(webhookPayload)
);

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •