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
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"
})
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