Billing Test Environment
This is a guide on how to setup a dev/test environment for the billing system of satellites.
We will setup storj-sim and connect it to the staging Stripe and CoinPayments accounts.
- Clone the following repositories, if you haven't done yet:
- Replace the cryptocurrency for payments from STORJ to LTCT:
sed -i 's/coinpayments\.CurrencySTORJ/coinpayments.CurrencyLTCT/g' $HOME/storj/satellite/payments/stripecoinpayments/tokens.go
- Copy the Tardigrade satellite theme:
cp -r $HOME/tardigrade-satellite-theme/europe-west-1/* $HOME/storj/web/satellite/
- Build the satellite GUI:
cd $HOME/storj/web/satellite
npm install
npm run build
cd $HOME/storj
- Build storj-sim:
go install ./...
Check Storj Test Network on how to setup and run storj-sim.
After executing the storj-sim network setup
command, open the satellite's config.yaml (located at ~/.local/share/storj/local-network/satellite/0/config.yaml
) and enable the following configuration:
payments.provider: stripecoinpayments
payments.stripe-coin-payments.stripe-public-key: ask-littleskunk-on-keybase
payments.stripe-coin-payments.stripe-secret-key: ask-littleskunk-on-keybase
payments.stripe-coin-payments.coinpayments-private-key: ask-littleskunk-on-keybase
payments.stripe-coin-payments.coinpayments-public-key: ask-littleskunk-on-keybase
Ask littleskunk on Keybase for the actual keys for staging Stripe and CoinPayments accounts.
Now you can start storj-sim with the storj-sim network run
command.
NOTE: To create Access Grant you will need satellite Node ID. To find it search storj-sim
logs and look for line like this:
storagenode/1 1ac27vuf38 09:41:21.159 | DEBUG contact:endpoint contact/endpoint.go:52 pinged {"by": "1aE3vja9wQv7UXqAD91ecwj1rjoWBTiRLkbaNjp3EnqqnMmktE", "srcAddr": "127.0.0.1:44040"}
Field by
will be the satellite Node ID.
- Open the satellite GUI in your browser: http://localhost:10002
- Click the
Create Account
button at the top right corner. - Enter user name, email, and password. The email does NOT need to be valid.
- Accept the Term of Service and click the
Create Account
button. - The "Account Created" page will be displayed stating that a confirmation email has been sent. In fact, no email has been sent and the account does NOT need to be confirmed.
- Click on the
Login
button and login with the new user.
DO NOT use real credit or debit cards for testing purposes!
Check the Stripe documentation for testing credit card numbers like 4242 4242 4242 4242
.
These testing credit card numbers work if storj-sim is configured with our staging Stripe account. They won't work on the production satellites.
For testing purposes it is recommended to use the LTCT cryptocurrency instead of STORJ. Using LTCT involves absolutely no cost for the transaction.
In the first section of this document we patched the source code of the satellite to use LTCT instead of STORJ.
One easy way to be able to make transactions in LTCT is to make your own account on CoinPayments.
You don't need to complete the KYC work with LTCT.
After you setup the account, you can request LTCT coins by clicking here.
10 LTCT coins will be added immediately to your wallet.
You can check the balance of your LTCT coins in the dashboard.
- On the satellite initiate a payment with STORJ by selecting an amount in USD and clicking the
Continue to CoinPayments
button. - A new web page to CoinPayments pops up displaying the details for completing the transaction.
- Go to your wallet in CoinPayments.
- Find the LTCT coin in the list.
- Select
LTCT Options
>Send / Withdraw
. - Enter the amount in LTCT. The amount should be exactly the same as requested by the CoinPayments popup from step 2. Do not enter any value for USD.
- Enter the Litecoin Testnet address. The address should be exactly the same as requested by the CoinPayments popup from step 2.
- Click the
Request Withdrawal/Send
button. - Check your inbox for a new email and confirm the transaction. It takes a few minutes for the transaction to confirm.
- In a few minutes the CoinPayments popup from step 2 will display that the transaction is payed.
- In a few more minutes the payment will be reflected on the satellite too.
You need to request login information to our staging Stripe account from Brandon.
Once you login, switch the View test data
toggle on the left-side menu.
Now you can search for your test users by email.
- Create a bucket, upload a file, and download it.
- Restart storj-sim to trigger Tally service faster.
- Edit the
created_at
column in theprojects
DB table to simulate the project was created earlier. - Edit the
created_at
column in thestripe_customers
DB table to simulate that the stripe customer was created earlier. - Edit one or more records in the
bucket_bandwidth_rollups
DB table:- The records should have
action
of type2
which means "download". - Change the time in the
interval_start
column to match the desired billing period. - Change the
allocated
andsettled
columns to match the desired Egress value in bytes.
- The records should have
- Edit at least two adjucent records (one is not enough) in the
bucket_storage_tallies
DB table:- Change the time in the
interval_start
column to match the desired billing period. - Change the
object_count
column to the maximum possible value (e.g.420000000
) to generate some noticeable Object-Month usage. - Change the
remote
column to some big value (e.g.356673702400000000
) to generate some noticeable GB-Month usage.
- Change the time in the
Invoices for the past month can be created with by executing these satellite commands (order matters):
satellite --config-dir ~/.local/share/storj/local-network/satellite/0 --log.level info billing prepare-invoice-records 04/2020
satellite --config-dir ~/.local/share/storj/local-network/satellite/0 --log.level info billing create-invoice-items 04/2020
satellite --config-dir ~/.local/share/storj/local-network/satellite/0 --log.level info billing create-invoice-coupons 04/2020
satellite --config-dir ~/.local/share/storj/local-network/satellite/0 --log.level info billing create-invoice-credits 04/2020
satellite --config-dir ~/.local/share/storj/local-network/satellite/0 --log.level info billing create-invoices 04/2020
The invoices will be created in Draft state and can be found in the Stripe account.
To revert the changes done by the invoice generating commands:
- Delete the draft invoices in Stripe.
- Delete any pending invoice items Stripe. Pending invoice items might be left if the last
create-invoices
commands has not been executed. - Delete the records for the respective billing period from the
stripecoinpayments_invoice_project_records
DB table. - Delete the records for the respective billing period from the
credits_spendings
DB table. - Delete the records for the respective billing period from the
coupon_usages
DB table. - Change the
status
to0
for the respective records in thecoupons
DB table.