Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fluxpayments

Package Overview
Dependencies
Maintainers
1
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fluxpayments

Api for merchants to connect to flux payments

  • 1.0.113
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Flux Payments

Installation

npm install fluxpayments

Configuration

Register for an account and get your sandbox keys at https://portal.fluxpayments.com

Introduction

Welcome to the Flux Payments documentation. Below you will find sample code that demonstrates the API workflow and a comprehensive list of modules and their respective documentation links.

Server Side code

import { flux } from "fluxpayments/lib";
import { Account } from "fluxpayments/flux_types";

await flux (
    "public_key", 
    "private_key", 
    "username", 
    "password"
);

let firstAccount : Account = await Account.createInstanceSafe({
    accountUserType: AccountUserType.CUSTOMER,
    uniqueId: "TESTACCOUNT"
});

let firstAddress = await Address.createInstanceSafe({
    uniqueId: "FIRSTADDRESS",
    streetAddress: "123 Main Street",
    zipCode: "123456",
    city: "Tampa",
    state: "Florida"
})

let secondAddress = await Address.createInstanceSafe({
    uniqueId: "SECONDADDRESS",
    streetAddress: "123 Main Street",
    zipCode: "123453",
    city: "Tampa",
    state: "Florida"
})

await acc.addAddress(firstAddress);
await acc.addAddress(secondAddress);
await acc.setDefaultShippingAddress(firstAddress);

let sessionGenerated = await acc.generateSession();

Getting exciting...

Send the session to the frontend to create a payment method for the account.

Browser Code

import { fluxBrowser } from "fluxpayments/lib";
import { Card, Account } from "fluxpayments/flux_types";

await fluxBrowser("PK_ewRVuDFJEe61LwJCwKjwBA==");

paymentMethod = await Card.createInstanceSafe({
    address: add1,
    firstName: "Jane",
    lastName: "Doe",
    accountSession: sessionGenerated,
    cardNumber: "1234123412341234",
    cvv: "1234",
    expMonth: "05",
    expYear: "35"
});

await Account.setDefaultPaymentMethod(paymentMethod)

Drum roll...

Create a product and a transaction to charge the newly created account

Server side code

//Create a product and a transaction
import { flux } from "fluxpayments/lib";
import { Account, Product, Transaction, Address } from "fluxpayments/flux_types";

await flux(
    "public_key", 
    "private_key", 
    "username", 
    "password"
);

let prod: Product = await Product.createInstanceSafe({
    uniqueId: "FIRST_PRODUCT",
    type: "PHYSICAL_PRODUCT",
    name: "TEST 1",
    inventoryCount: 100,
    price: .51
})

let account : Account = await Account.createInstanceLazy({
    uniqueId: "TESTACCOUNT"
});

let address : Address = await Address.createInstanceLazy({
    uniqueId: "SECONDADDRESS"
})

//Transaction that uses the default payment method
//and a provided address.
let txn = await Transaction.createInstanceSafe({
    account: account,
    shippingAddress: address,
    products: {...prod, orderQuantity: 5}
})

Table of contents

Flux Classes

Flux Class Interfaces

Query Classes

Query Types

FAQs

Package last updated on 04 May 2024

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