I am trying to integrate WorldPay's "AccessCheckoutSDK" in my IOS Application using Swift by following
https://developer.worldpay.com/docs/access-worldpay/checkout/ios/card-only
while generating session it give me "Identity is invalid" error . Here is the code i tried
func initializedSDK() -> AccessCheckoutClient? {
let accessCheckoutClient = try?
AccessCheckoutClientBuilder().accessBaseUrl(WORLDPAY_BASE_URL)
.merchantId(WORLDPAY_MERCHANT_ID)
.build()
return accessCheckoutClient
}
func createCardDetails(CardNumber : String , CardExpiry : String , CardCVC : String) -> CardDetails? {
let cardDetails = try? CardDetailsBuilder().pan(CardNumber)
.expiryDate(CardExpiry)
.cvc(CardCVC)
.build()
return cardDetails
}
func CreateSession(CardNumber : String , CardExpiry : String , CardCVC : String) {
guard let accessCheckoutClient = initializedSDK() else {
// not going here so accessCheckoutClient is initialized
return
}
guard let cardDetails = createCardDetails(CardNumber: CardNumber, CardExpiry: CardExpiry, CardCVC: CardCVC) else {
// Not going here , so card details are valid
return
}
try? accessCheckoutClient.generateSessions(cardDetails: cardDetails, sessionTypes: [SessionType.card , .cvc ]) { result in
DispatchQueue.main.async {
switch result {
case .success(let sessions):
// The session is returned in a Dictionary[SessionType:String]
//not going here
let cardSession = sessions[SessionType.card]
let cvcSession = sessions[SessionType.cvc]
case .failure(let error):
// The error returned is of type AccessCheckoutError
print("error \(error)")
// It is going here and prints this error below
}
}
}
}
I am getting this error
AccessCheckoutError(errorName: "bodyDoesNotMatchSchema", message: "bodyDoesNotMatchSchema : The json body provided does not match the expected schema", validationErrors: [AccessCheckoutSDK.AccessCheckoutError.AccessCheckoutValidationError(errorName: "fieldHasInvalidValue", message: "Identity is invalid", jsonPath: "$.identity")])
WORLDPAY_BASE_URL = "https://try.access.worldpay.com/"
Note : I am using worldPay in testMode and didn't activated live mode yet and made sure that WORLDPAY_MERCHANT_ID is correct.
After all the research on worldPay , i decide to mail to worldPay support, After a brief chat with them and after they went through my worldPay account, this was their final reply :
"Your account status, "basic", "free tier" does not permit you to have access to this endpoint."
I decided to answer my own question so that if anyone have the same problem while integrating WorldPay with test Account, This would help them. I still think WorldPay developer can handle this scenario better by returning this exact string straightforward in the api response instead of throwing a 500 server error.
I welcome other answers and information on this post as well. If you have something informative about worldPay integration to IOS, please feel free to comment or answer this question.