I am trying to integrate Adyen payment in iOS through HPP method. Constantly getting Merchant signature was not valid error, I am suspecting some issue with the encoding part.
Following is the code snippet I use to create request body
var urlComponents = URLComponents()
urlComponents.queryItems = []
let contentKeys1: [String] = Array(content.keys)
for contentKey in contentKeys1 {
if let contentValue = content[contentKey] {
urlComponents.queryItems?.append(URLQueryItem(name: contentKey, value: contentValue))
}
}
self.httpBody = urlComponents.query?.data(using: .utf8)
In Android, it's working fine and I used android created string in iOS to test and the payment page is launching without any error.
Following is the Android code snippet to create request body
val query = StringBuilder()
if (providerDataset != null) {
for (providerData: ProviderData in providerDataset) {
val key = providerData.key
var value: String? = ""
try {
if (providerData.value != null)
value = URLEncoder.encode(providerData.value, StandardCharsets.UTF_8.toString())
} catch (e: UnsupportedEncodingException) {
e.printStackTrace()
}
val str = "$key=$value"
query.append(str).append("&")
}
}
return query.deleteCharAt(query.length - 1).toString()
Do we have an encoding method in iOS that does the same job as Android in the above code?
Struggling for many days to figure this out. Any help is highly appreciable
