Get Available Methods

Methods That Require Public Key

These methods depend on the public API key being set in the MoneyHashSDK using the setPublicKey method.

To obtain your public API key, please refer to the MoneyHash Integration Documentation.


Get Account Methods

To access the available pay-in methods, saved cards, and customer balances, call the getMethods method with the appropriate search criteria.

Parameters:

  • currency: String - required
  • amount: Double? - optional
  • customerId: String? - optional
  • flowId: String? - optional
// Retrieve available methods
    try {
        val currency = "USD"
        val amount: Double? = 100.0 // Optional
        val customerId: String? = "customer_id" // Optional
        val flowId: String? = "flow_id" // Optional

        val methods = moneyHashSDK.getMethods(currency = currency, amount = amount, customerId = customerId, flowId = flowId)

        println("Available Payment Methods: ${methods.paymentMethods}")
        println("Available Express Methods: ${methods.expressMethods}")
        println("Saved Cards: ${methods.savedCards}")
        println("Customer Balances: ${methods.customerBalances}")
    } catch (throwable: Throwable) {
        // Handle error
        println("Error retrieving methods: ${throwable.message}")
    }

Get Methods For Intent

The getMethods method allows you to access the available pay-in/pay-out methods, saved cards, and customer balances associated with a specific intent.

Usage Example:

// Retrieve available methods using intent
    try {
        // The intentId should be obtained from your backend after creating an intent
        val intentId = "your_intent_id_here"
        val intentType = IntentType.Payment // or IntentType.Payout

        val methods = moneyHashSDK.getMethods(intentId = intentId, intentType = intentType)

        println("Available Payment Methods: ${methods.paymentMethods}")
        println("Available Express Methods: ${methods.expressMethods}")
        println("Saved Cards: ${methods.savedCards}")
        println("Customer Balances: ${methods.customerBalances}")
    } catch (throwable: Throwable) {
        // Handle error
        println("Error retrieving methods: ${throwable.message}")
    }

Get Intent Details

To access all intent details related to a specific intentId, use the getIntentDetails method.

// Retrieve intent details
    try {
        val intentId = "your_intent_id_here"
        val intentType = IntentType.Payment // or IntentType.Payout

        val intentDetails = moneyHashSDK.getIntentDetails(intentId = intentId, intentType = intentType)

        println("Intent Details: $intentDetails")
    } catch (throwable: Throwable) {
        // Handle error
println("Error retrieving intent details: ${throwable.message}")
    }

Proceed With Payment

To proceed with a selected payment method, use the proceedWithMethod method. This method allows you to initiate a payment using the chosen method, such as a payment method ID, saved card ID, or customer balance ID.

// Proceed with a selected method
try {
    val intentId = "your_intent_id_here"
    val intentType = IntentType.Payment
    val selectedMethodId = "selected_method_id_here"
    val methodType = MethodType.PAYMENT_METHOD // e.g., MethodType.PAYMENT_METHOD, MethodType.SAVE_CARD, MethodType.CUSTOMER_BALANCE

    // If you are using a saved Card then pass the saved card CVV, provide it in methodMetaData
    val methodMetaData: MethodMetaData? = if (methodType == MethodType.SAVE_CARD) {
     	 	MethodMetaData(cvv = "123") // CVV if required
    } else {
      	null
    }

    val intentResult = moneyHashSDK.proceedWithMethod(
        intentId = intentId,
        intentType = intentType,
        selectedMethodId = selectedMethodId,
        methodType = methodType,
        methodMetaData = methodMetaData
    )

    println("Proceeded with method: $intentResult")
} catch (throwable: Throwable) {
    // Handle error
    println("Error proceeding with payment: ${throwable.message}")
}