npm install fluxpayments
Register for an account and get your sandbox keys at https://portal.fluxpayments.com
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.
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();
Send the session to the frontend to create a payment method for the account.
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)
Create a product and a transaction to charge the newly created account
//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}
})
- Account
- Address
- BankAccount
- Card
- FluxIdentifier
- FluxType
- InstallmentTransaction
- OneTimePaymentLink
- PaymentMethod
- Product
- RecurringTransaction
- Token
- Transaction
- IAccount
- IAddress
- IBankAccount
- ICard
- IInstallmentTransaction
- IOneTimePaymentLink
- IPaymentMethod
- IProduct
- IRecurringTransaction
- ISearchOptions
- IToken
- ITransaction