Transmitting supported payment methods

Implement the getCardPaymentMethod function.

Create a cardPaymentMethod object to transmit the supported payment methods for the CARD payment method as well as the payment gateway details.

Excerpt from the code sample:

private fun getCardPaymentMethod(additionalParams: JSONObject?, tokenizationSpecification: JSONObject?): JSONObject {
    val params = JSONObject()
            .put("allowedAuthMethods", getAllowedCardAuthMethods())
            .put("allowedCardNetworks", getAllowedCardNetworks())

    // Additional parameters provided? 
   if (additionalParams != null && additionalParams.length() > 0) {
        val keys = additionalParams.keys()
        while (keys.hasNext()) {
            val key =
            params.put(key, additionalParams.get(key))
    val cardPaymentMethod = JSONObject()
    cardPaymentMethod.put("type", "CARD")
            "parameters", params)
    if (tokenizationSpecification != null) {
                "tokenizationSpecification", tokenizationSpecification)

For more information, see the documentation of the CardParameters object.