Quickstart Guide

With ambrpay you can accept recurring cryptocurrency payments in no time. Currently we do crypt-to-crypto recurring payments, with crypto-to-fiat coming soon.


Create an account and a plan

Sign up for an ambrpay account and create a plan. You need your plan's ID to continue.


Include ambrpay.js

<script src="https://js.ambrpay.io/ambrpay.js"></script>

Set your API Key

var ambrpay = new Ambrpay("YOUR_API_KEY");

Prepare the subscription data

var subscriptionData = {
    subscriptionPlan: "YOUR_SUBSCRIPTIONPLAN_ID", // sp_123456
    amount: 0.01,
    receiverWallet: "0x...",
    interval: 30,
    transferOut: true,
    network: "ropsten",
};

Subscribe a customer to a plan

ambrpay.subscribe(subscriptionData)
.then((txHash) => {
    // do something after the subscription
});
Ambrpay.js functions
Function Parameters Type Example

ambrpay.subscribe({})

Subscribes a customer to a plan. Returns the transaction hash.
subscriptionPlanRequired
amountRequired
receiverWalletoptional
intervaloptional
transferOutoptional
networkoptional
string
integer or float (min:0.01 for ETH, 1 for FIAT)
string
integer (min:1, max:365)
boolean
string
ambrpay.subscribe({
    subscriptionPlan: "sp_123456",
    amount: 0.01,
    receiverWallet: "0x5D6a22Cc5c70D452E406Df657C0f6beE5508C802",
    interval: 30,
    transferOut: true,
    network: "ropsten",
})
.then((txHash) => {
    //
});

ambrpay.getSubscriptions(address)

Returns a JSON of all active subscriptions for an address.
If address parameter is ommitted, it will use the current metamask wallet address.
addressoptional
string
ambrpay.getSubscriptions()
.then((subscriptions) => {
    // 
});

ambrpay.addFunds(amount)

Adds funds to the smart contract for the current metamask wallet address so it can pay the active subscriptions.
Amount in ether.
amountRequired
integer
ambrpay.addFunds(0.02)
.then((txHash) => {
    // 
});

ambrpay.withdrawFunds(amount)

Withdraws funds from the smart contract for the current metamask wallet address.
Amount in ether.
amountRequired
integer
ambrpay.withdrawFunds(0.01)
.then((txHash) => {
    // 
});

ambrpay.unsubscribe(position, smartContractAddress)

Unsubscribes a customer from a plan. Returns the transaction hash. You will receive the smart contract address and the position from getSubscriptions().
positionRequired
smartContractAddressRequired
integer
string
ambrpay.unsubscribe(55, "0xa5a179c7570F4d17F174F73c7668013000E305a4")
.then((txHash) => {
    //
});
Endpoints

Base API URL

https://ambrpay.io/api/

Method Endpoint Parameters Example
GET

/subscriptions/{address}

Retrieves the subscriptions of an address for your plans
address

Required

Example Request
curl https://ambrpay.io/api/subscriptions/{address} -u {YOUR_SECRET_API_KEY}:
Example Response
{
    "id": "s_q1XqMxVfJcp2C1",
    "cycleStart": "03.05.2019",
    "cycleEnd": "04.05.2019",
    "price": 0.01,
    "storagePos": 32,
    "subscriptionPlan": "Crypto to Crypto",
    "subscriptionInterval": 1,
    "receiverWallet": "0x5D6a22Cc5c70D452E406Df657C0f6beE5508C802",
    "subscriptionPlanCurrencyCode": "ETH",
    "subscriptionCurrencyCode": "ETH",
    "subscriptionStatus": "Unpaid",
    "smartContractAddress": "0xa5a179c7570F4d17F174F73c7668013000E305a4"
}