provideDefaultValues

Allows to provide default values response which must be constructed from request that has been collected by subscribing to defaultValuesRequest.

viewModelScope.launch {
with(ProcessOut.instance.dispatchers.nativeAlternativePaymentMethod) {
// Subscribe for request to provide default values.
defaultValuesRequest.collect { request ->
// Default values should be provided as Map<String, String>
// where key is a [PONativeAlternativePaymentMethodParameter.key]
// and value is a custom default value.
val defaultValues = mutableMapOf<String, String>()

// Populate default values map based on request parameters.
// It's not mandatory to provide defaults for all parameters.
request.parameters.find {
it.type() == ParameterType.PHONE
}?.also {
defaultValues[it.key] = "+111122223333"
}

// Provide response which must be constructed from request with default values payload.
// Note that once you've subscribed to 'defaultValuesRequest'
// it's required to send response back, otherwise the payment flow will not proceed.
// If there is no default values to provide it's still required
// to call this method with 'emptyMap()'.
provideDefaultValues(request.toResponse(defaultValues))
}
}
}