I am implementing stripe paymentSDK and after implementing my code I am getting error in my console, here my code:
View Controller Class
func stripPayment(CVC:String){
// Initiate the card
let stripCard = STPCardParams()
if cardMM == "" && cardYY == "" {
// Send the card info to Strip to get the token
stripCard.number=card_number
stripCard.name=card_name
stripCard.cvc=CVC
stripCard.expYear=UInt(cardYY)!
stripCard.expMonth=UInt(cardMM)!
}
print("card_number:",card_number)
print("card_name:",card_name)
print("CVC:",CVC)
print("cardYY:",cardYY)
print("cardMM:",cardMM)
STPAPIClient.shared.createToken(withCard: stripCard) { (token: STPToken?, error: Error?) in
print("Printing Strip response:\(String(describing: token?.allResponseFields))\n\n")
print("Printing Strip Token:\(String(describing: token?.tokenId))")
if error != nil {
print(error)
print(error?.localizedDescription ?? "")
}
if token != nil{
print("Token:",token!.tokenId)
self.placeOrderApi(tokenStripe: token!.tokenId, completion: {
self.pushVC(id: "PaymentConfirmationVCID")
})
}
}
}
App Delegate DidFinishLaunch
STPAPIClient.shared.publishableKey = "pk_test_51KuLPhJ4jB1YaTRoUayoteEXbtl5QvbayNeDDhjv4Nto9UvdM4LcTsP2EXAbU0IuOoKsIsOAk565HzvjLRPVP9wY00Ro5T3PYq"
Error I am getting in console
Printing Strip Token:nil Optional(Error Domain=com.stripe.lib Code=50 "There was an unexpected error -- try again in a few seconds" UserInfo={com.stripe.lib:ErrorParameterKey=card[number], NSLocalizedDescription=There was an unexpected error -- try again in a few seconds, com.stripe.lib:ErrorMessageKey=Missing required param: card[number]., com.stripe.lib:StripeErrorTypeKey=invalid_request_error, com.stripe.lib:StripeErrorCodeKey=parameter_missing}) There was an unexpected error -- try again in a few seconds