Class ETOPaySdk

java.lang.Object
com.etospheres.etopay.ETOPaySdk

public class ETOPaySdk extends Object
Main object that contains all the functionality for interfacing with the ETOPaySdk.
  • Constructor Details

    • ETOPaySdk

      public ETOPaySdk()
  • Method Details

    • setConfig

      public void setConfig(String config) throws Exception
      Set the configuration as a JSON-encoded string.
      Parameters:
      config - The input string representing the configuration with the following structure:
       
       {
       "auth_provider": "<authentication provider name>",
       "backend_url": "<valid URL to the backend API>",
       "storage_path": "/path/to/valid/folder",
       "log_level": "info",
       }
       
       
      Throws:
      Exception
    • getNetworks

      public String getNetworks() throws Exception
      Fetch available currencies and corresponding networks.
      Returns:
      Serialized string of ApiNetworks as value
      Throws:
      Exception
    • setNetwork

      public void setNetwork(String network_key) throws Exception
      Selects the network for the ETOPay SDK.
      Parameters:
      network_key - The input string representing the network key
      Throws:
      Exception
    • close

      public void close() throws Exception
      Destructor for the SDK handle
      Throws:
      Exception
    • createNewUser

      public void createNewUser(String username) throws Exception
      Creates a new user for the SDK.
      Parameters:
      username - The input string representing the username.
      Throws:
      Exception
    • initializeUser

      public void initializeUser(String username) throws Exception
      Initializes an existing user in the SDK
      Parameters:
      username - The input string representing the username.
      Throws:
      Exception
    • refreshAccessToken

      public void refreshAccessToken(String access_token) throws Exception
      Refreshes the access token for the user in the SDK.
      Parameters:
      access_token - The input string representing the access token.
      Throws:
      Exception
    • isKycVerified

      public boolean isKycVerified(String username) throws Exception
      Fetches the kyc verification status for the user
      Parameters:
      username - The input string representing the username.
      Returns:
      The kyc verification status as a boolean value
      Throws:
      Exception
    • verifyMnemonic

      public boolean verifyMnemonic(String pin, String mnemonic) throws Exception
      Verifies the mnemonic for the wallet
      Parameters:
      pin - The input string representing the pin.
      mnemonic - The input string representing the mnemonic
      Returns:
      a boolean indicating if the mnemonic is correct or not
      Throws:
      Exception
    • createNewWallet

      public String createNewWallet(String pin) throws Exception
      Creates a new wallet and sets the pin and password
      Parameters:
      pin - The input string representing the pin.
      Returns:
      The mnemonic of the created wallet as a string
      Throws:
      Exception
    • createWalletFromMnemonic

      public void createWalletFromMnemonic(String pin, String mnemonic) throws Exception
      Creates/migrates a wallet from an existing mnemonic
      Parameters:
      pin - The input string representing the pin.
      mnemonic - The input string representing the mnemonic
      Throws:
      Exception
    • createWalletFromBackup

      public void createWalletFromBackup(String pin, byte[] backup, String backup_password) throws Exception
      Creates a wallet from a previously created backup
      Parameters:
      pin - The input string representing the pin.
      backup - The bytes of the backup file.
      backup_password - The input string representing the password of the backup
      Throws:
      Exception
    • createWalletBackup

      public byte[] createWalletBackup(String pin, String backup_password) throws Exception
      Creates a wallet backup file for the existing wallet and encrypts it with the password
      Parameters:
      pin - The input string representing the pin.
      backup_password - The input string representing the password to be used to encrypt the backup
      Returns:
      The path to the generated backup file as string
      Throws:
      Exception
    • deleteWallet

      public void deleteWallet(String pin) throws Exception
      Deletes the local wallet and associated files
      Parameters:
      pin - The input string representing the pin.
      Throws:
      Exception
    • generateNewAddress

      public String generateNewAddress(String pin) throws Exception
      Generate a new receiver address based on selected currency in the config.
      Parameters:
      pin - The input string representing the pin.
      Returns:
      The receiver wallet address as String.
      Throws:
      Exception
    • getWalletBalance

      public double getWalletBalance(String pin) throws Exception
      Fetches the current balance of the base crypto currency on the wallet
      Parameters:
      pin - The input string representing the pin.
      Returns:
      The current balance as a double precision floating point number
      Throws:
      Exception
    • startKycVerificationForPostident

      public String startKycVerificationForPostident() throws Exception
      Initialize the KYC process for Postident by generating a case id.

      Note: This method is only available if the SDK is compiled with support for postident.

      Returns:
      The ID of the new Postident KYC case.
      Throws:
      Exception
    • getKycDetailsForPostident

      public String getKycDetailsForPostident() throws Exception
      Fetches the KYC details for the postident provider

      Note: This method is only available if the SDK is compiled with support for postident.

      Returns:
      The case details as a serialized JSON string
      Throws:
      Exception
    • updateKycStatusForPostident

      public void updateKycStatusForPostident(String case_id) throws Exception
      Triggers the backend to update the KYC status in the postident KYC provider

      Note: This method is only available if the SDK is compiled with support for postident.

      Parameters:
      case_id - The input string representing the case_id to be updated
      Throws:
      Exception
    • purchaseRequestCreate

      public String purchaseRequestCreate(String receiver, double amount, String product_hash, String app_data, String purchase_type) throws Exception
      Creates a purchase request for buying an artefact
      Parameters:
      receiver - The receiver of the purchase request.
      amount - The amount of the purchase.
      product_hash - The hash of the underlying product/artefact
      app_data - The app data for the purchase. This is application specific string or stringified object data.
      purchase_type - The type of the purchase. Either a COMPLIMENT or a PURCHASE
      Returns:
      The purchase id of the created purchase request as string
      Throws:
      Exception
    • purchaseDetails

      public String purchaseDetails(String purchase_id) throws Exception
      Fetches the purchase details from the given purchase ID.
      Parameters:
      purchase_id - The purchase id to query to details.
      Returns:
      The purchase details as a serialized JSON string
      Throws:
      Exception
    • purchaseRequestConfirm

      public void purchaseRequestConfirm(String pin, String purchase_id) throws Exception
      Confirm the purchase for the given purchase ID.
      Parameters:
      pin - The pin for confirmation of purchase
      purchase_id - The purchase id to confirm.
      Throws:
      Exception
    • startViviswapKyc

      public String startViviswapKyc(String mail, boolean terms_accepted) throws Exception
      Starts the KYC verification process for viviswap
      Parameters:
      mail - The email address of the user as a string.
      terms_accepted - The terms of conditions accepted flag for the user as a boolean
      Returns:
      The new viviswap user as a serialized JSON string
      Throws:
      Exception
    • getViviswapKyc

      public String getViviswapKyc() throws Exception
      Fetches the KYC details for a user by the viviswap onboarding process
      Returns:
      The KYC details as a serialized JSON string
      Throws:
      Exception
    • updateViviswapKycPartial

      public String updateViviswapKycPartial(boolean is_individual, boolean is_pep, boolean is_us_citizen, boolean is_regulatory_disclosure, String country_of_residence, String nationality, String full_name, String date_of_birth) throws Exception
      Updates the partial KYC details for the viviswap onboarding process
      Parameters:
      is_individual - Flag indicating if the user is an individual.
      is_pep - Flag indicating if the user is a politically exposed person.
      is_us_citizen - Flag indicating if the user is a US citizen.
      is_regulatory_disclosure - Flag indicating if the user has made a regulatory disclosure.
      country_of_residence - The country of residence of the user.
      nationality - The nationality of the user.
      full_name - The full name of the user.
      date_of_birth - The date of birth of the user.
      Returns:
      The KYC updated details reflected as a serialized JSON string
      Throws:
      Exception
    • submitViviswapKycPartial

      public void submitViviswapKycPartial() throws Exception
      Submits the partial KYC details for the viviswap onboarding process
      Throws:
      Exception
    • setViviswapKycIdentityDetails

      public void setViviswapKycIdentityDetails(String official_document_type, String expiration_date, String document_number, byte[] official_document_front_image_data, String official_document_front_image_filename, byte[] official_document_back_image_data, String official_document_back_image_filename, byte[] personal_video_data, String personal_video_filename) throws Exception
      Set Viviswap KYC identity details
      Parameters:
      official_document_type - The type of the official document.
      expiration_date - The expiration date of the official document.
      document_number - The number of the official document.
      official_document_front_image_data - The byte data of the image of the front of the official document.
      official_document_front_image_filename - The filename (including extension) of the image of the front of the official document.
      official_document_back_image_data - The byte data of the image of the back of the official document, or NULL to not provide a back image.
      official_document_back_image_filename - The filename (including extension) of the image of the back of the official document, or NULL to no provide a back image.
      personal_video_data - The byte data of the 30 second personal video recording.
      personal_video_filename - The filename (including extenstion) of the 30 second personal video recording.
      Throws:
      Exception
    • setViviswapKycResidenceDetails

      public void setViviswapKycResidenceDetails(String country_code, String region, String zip_code, String city, String address_line_1, String address_line_2, boolean is_public_entry, String public_entry_reference, boolean has_no_official_document, byte[] official_document_image_data, String official_document_image_filename) throws Exception
      Set Viviswap KYC residence details
      Parameters:
      country_code - `, `region`, `zip_code`, `city`, `address_line_1`, `address_line_2 basic address data.
      is_public_entry - Inidcates that a valid public entry of this clients address can be found.
      public_entry_reference - if `is_public_entry` is `true`, then this must contain the resource link.
      has_no_official_document - indicates if the client does not have any document verifying their address.
      official_document_image_data - if `has_no_official_document` is `false`, then this must contain the bytes of the document file that verifies that this person is currently living at the address submitted. Otherwise leave as NULL.
      official_document_image_filename - the filename (including extension) of the document, or NULL if no document needs to be provided.
      Throws:
      Exception
    • getViviswapKycAmlaOpenQuestions

      public String getViviswapKycAmlaOpenQuestions() throws Exception
      Get the open AMLA KYC questions
      Returns:
      A list of the currently open AMLA questions.
      Throws:
      Exception
    • setViviswapKycAmlaAnswer

      public void setViviswapKycAmlaAnswer(String question_id, String[] answers, String freetext_answer) throws Exception
      Set the answer to an open AMLA KYC question
      Parameters:
      question_id - The ID of the question to set the answer to.
      answers - a list of the selected available answers for the question.
      freetext_answer - an optional free-text answer. Pass NULL to not pass any value.
      Throws:
      Exception
    • getViviswapKycOpenDocuments

      public String getViviswapKycOpenDocuments() throws Exception
      Get the currently open/missing documents for KYC
      Returns:
      A list of the currently open documents.
      Throws:
      Exception
    • setViviswapKycDocument

      public void setViviswapKycDocument(String document_id, String expiration_date, String document_number, byte[] front_image_data, String front_image_filename, byte[] back_image_data, String back_image_filename) throws Exception
      Set / upload an open KYC document
      Parameters:
      document_id - The ID of the document to upload.
      expiration_date - the expiration date of this document.
      document_number - the official document number.
      front_image_data - the bytes of the image of the front side of the document.
      front_image_filename - the filename (including extension) of the front side of the document.
      back_image_data - the bytes of the mage of the back side of the documentk, or NULL for not specifying a back side image.
      back_image_filename - the filename (including extension) of the back side of the documentk, or NULL for not specifying a back side image.
      Throws:
      Exception
    • pinVerify

      public void pinVerify(String pin) throws Exception
      Verifies the pin for the wallet
      Parameters:
      pin - The pin to be verified
      Throws:
      Exception
    • pinReset

      public void pinReset(String pin, String new_pin) throws Exception
      Resets the pin for the wallet using the wallet password
      Parameters:
      new_pin - The new pin to be set for the wallet
      Throws:
      Exception
    • setWalletPassword

      public void setWalletPassword(String pin, String new_password) throws Exception
      Set the password to use for wallet operations. If the password was already set, this changes it.
      Parameters:
      pin - The pin for verification
      new_password - The new password to be set
      Throws:
      Exception
    • isWalletPasswordSet

      public boolean isWalletPasswordSet() throws Exception
      Check if the password to use for wallet operations is set. Use setWalletPassword(java.lang.String, java.lang.String) to set a new or change an existing password.
      Returns:
      whether the password is already set or not.
      Throws:
      Exception
    • sendAmount

      public String sendAmount(String pin, String address, double amount, byte[] data) throws Exception
      Sends the given amount to the given address
      Parameters:
      pin - The pin for verification
      address - The address of the receiver
      amount - The amount to send in the selected currency
      data - The data associated with the transaction. Pass NULL to not specify any data.
      Returns:
      The transaction id.
      Throws:
      Exception
    • updateIbanViviswap

      public String updateIbanViviswap(String pin, String address) throws Exception
      Updates the IBAN of the user
      Parameters:
      pin - The pin for verification
      address - The IBAN number to be updated
      Returns:
      The details of the added IBAN as a serialized JSON string.
      Throws:
      Exception
    • getIbanViviswap

      public String getIbanViviswap() throws Exception
      Gets the IBAN of the user
      Returns:
      The details of the IBAN as a serialized JSON string.
      Throws:
      Exception
    • depositWithViviswap

      public String depositWithViviswap(String pin) throws Exception
      Creates a payment contract for depositing money in wallet using viviswap [EURO --> Crypto]
      Parameters:
      pin - The input string representing the pin.
      Returns:
      The details of the added payment contract as a serialized JSON string.
      Throws:
      Exception
    • createViviswapDetail

      public String createViviswapDetail(String pin) throws Exception
      Creates a payment detail for the wallet crypto address in viviswap
      Parameters:
      pin - The input string representing the pin.
      Returns:
      The details of the added payment detail as a serialized JSON string.
      Throws:
      Exception
    • withdrawWithViviswap

      public String withdrawWithViviswap(double amount, String pin, byte[] data) throws Exception
      Creates a payment contract for withdrawing money from wallet using viviswap [Crypto --> EUR] and if the pin is provided automatically triggers a withdrawal
      Parameters:
      amount - The amount to withdraw from the wallet
      pin - The pin for verification. Pass NULL to not specify a pin.
      data - The data associated with the transaction. Pass NULL to not specify any data.
      Returns:
      The details of the created payment contract as a serialized JSON string.
      Throws:
      Exception
    • getSwapDetails

      public String getSwapDetails(String order_id) throws Exception
      Gets the detail of a particular swap(deposit or withdrawal) created at viviswap based on the given order id.
      Parameters:
      order_id - The amount to withdraw from the wallet
      Returns:
      The details of the created order as a serialized JSON string.
      Throws:
      Exception
    • getSwapList

      public String getSwapList(long start, long limit) throws Exception
      Gets the detailed lists of swaps (deposit and withdrawal) created at viviswap
      Parameters:
      start - The start page
      limit - The limit per page
      Returns:
      The details of the created orders as a serialized JSON string.
      Throws:
      Exception
    • txList

      public String txList(long start, long limit) throws Exception
      Gets the detailed lists of purchases (COMPLIMENTS and PURCHASES)
      Parameters:
      start - The start page
      limit - The limit per page
      Returns:
      The details of the created purchases as a serialized JSON string.
      Throws:
      Exception
    • getExchangeRate

      public double getExchangeRate() throws Exception
      Gets the current exchange rate for the cryptocurrency to EURO
      Returns:
      The exchange rate as a floating point number
      Throws:
      Exception
    • deleteUser

      public void deleteUser(String pin) throws Exception
      Deletes the user in ETOPay. Hazmat!
      Parameters:
      pin - The wallet pin for confirmation. Optional in case there is an active wallet.
      Throws:
      Exception
    • getWalletTransactionList

      public String getWalletTransactionList(String pin, long start, long limit) throws Exception
      Gets the detailed lists of wallet transactions
      Parameters:
      pin - The input string representing the pin.
      start - The start page
      limit - The limit per page
      Returns:
      The details of the wallet transactions as a serialized JSON string.
      Throws:
      Exception
    • getWalletTransaction

      public String getWalletTransaction(String pin, String tx_id) throws Exception
      Gets the details of a specific wallet transaction
      Parameters:
      pin - The input string representing the pin.
      tx_id - The ID of the transaction to get details for.
      Returns:
      The details of the wallet transaction as a serialized JSON string.
      Throws:
      Exception
    • getRecoveryShare

      public String getRecoveryShare() throws Exception
      Get/download the recovery share.
      Returns:
      The recovery share as a string, or `null` if none exists.
      Throws:
      Exception
    • setRecoveryShare

      public void setRecoveryShare(String share) throws Exception
      Set/upload the recovery share.
      Parameters:
      share - The recovery share to upload.
      Throws:
      Exception
    • getPreferredNetwork

      public String getPreferredNetwork() throws Exception
      Get the user's preferred network.
      Returns:
      The preferred network, or `null` if it has not been set.
      Throws:
      Exception
    • setPreferredNetwork

      public void setPreferredNetwork(String network_key) throws Exception
      Set the user's preferred network.
      Parameters:
      network_key - The preferred network, or `null` if it should be unset.
      Throws:
      Exception
    • getBuildInfo

      public String getBuildInfo() throws Exception
      Get sdk build information.
      Returns:
      The sdk build information as a string.
      Throws:
      Exception