|
| 1 | +# Payments |
| 2 | + |
| 3 | +This is a guide to how to use the Obscura API to create and fund accounts. |
| 4 | + |
| 5 | +<div class="warning"> |
| 6 | + |
| 7 | +This API is only officially supported for our partners. If you are interested in partnering with Obscura please contact <support@obscura.net>. |
| 8 | + |
| 9 | +</div> |
| 10 | + |
| 11 | +## Background Information |
| 12 | + |
| 13 | +This documentation will be critical to understanding how to manage funding. |
| 14 | + |
| 15 | +- [Account Number](crate::types::AccountId) |
| 16 | +- [Authentication](crate::doc::auth) |
| 17 | +- [Errors](crate::doc::error) |
| 18 | +- [Making Requests](crate::doc::requests) |
| 19 | + |
| 20 | +## Example Flows |
| 21 | + |
| 22 | +These are some example flows that highlight how the API can be used for common integration patterns. The links go to reference documentation. |
| 23 | + |
| 24 | +### One-Click Top-Up |
| 25 | + |
| 26 | +If you are a crypto wallet and would like to let your user easily subscribe to Obscura the flow would look something like this: |
| 27 | + |
| 28 | +1. Request the user's Account Number. |
| 29 | +1. [Fetch the account info](crate::cmd::GetAccountInfo) to validate the current status. If the account is already [`active`](crate::types::AccountInfo::active) check the [`current_expiry`](crate::types::AccountInfo::current_expiry) field. If it is `None` or far in the future then inform the user about the time left and confirm they do want to top-up now. |
| 30 | +1. [Fetch the prices](crate::cmd::ListPrices) and ask the user to select the desired package. |
| 31 | +1. Generate an invoice ([Monero](crate::cmd::CreateMoneroTopUp) or [Lightning](crate::cmd::CreateLightningTopUp)) and confirm the crypto price with the user. |
| 32 | +1. Record the ID ([Monero](crate::cmd::MoneroTopUpInfo::id) or [Lightning](crate::cmd::LightningTopUpInfo::id)) for the user. This is their payment reference if they ever need to contact support. |
| 33 | +1. Pay the invoice. |
| 34 | +1. Poll the check status API ([Monero](crate::cmd::CheckMoneroTopUp) or [Lightning](crate::cmd::CheckLightningTopUp)). |
| 35 | +1. Let the user know when their account is funded. |
| 36 | + |
| 37 | +### Auto Top-up |
| 38 | + |
| 39 | +While none of the supported currencies support native subscriptions a wallet could help the user avoid forgetting to fund their account. |
| 40 | + |
| 41 | +1. Request the user's Account Number. |
| 42 | +1. [Fetch the account info](crate::cmd::GetAccountInfo) to validate the current status. |
| 43 | + - If the account is not [`active`](crate::types::AccountInfo::active) then the user will be making the first payment to fund the account immediately. |
| 44 | +1. Poll the account info. Daily is a reasonable rate. |
| 45 | +1. Wait until [`current_expiry`](crate::types::AccountInfo::current_expiry) is soon (how soon is user preference). |
| 46 | +1. Notify the user that their account is expiring, or with user authorization automatically perform a top-up. |
| 47 | +1. [Fetch the prices](crate::cmd::ListPrices) and determine the appropriate package. |
| 48 | +1. Generate an invoice ([Monero](crate::cmd::CreateMoneroTopUp) or [Lightning](crate::cmd::CreateLightningTopUp)) and confirm the price is within the user's authorized parameters. |
| 49 | +1. Pay the invoice. |
| 50 | +1. Poll the check status API ([Monero](crate::cmd::CheckMoneroTopUp) or [Lightning](crate::cmd::CheckLightningTopUp)) and notify the user if the payment isn't processed in an appropriate time period. |
0 commit comments