I using CardIO and stripe for quick payment set for an app. I'm going through stripes documentation to find out how to validate quickly without setting up a full account.
My first question is what does textField.isValid confirm? Is there some call to stripe to confirm the card or is a simple content check?
func paymentCardTextFieldDidChange(_ textField: STPPaymentCardTextField) {
// Toggle buy button state
buyButton.enabled = textField.isValid
}
Second if it does confirm that the card is valid was is the difference between this and the code below? Is the token only to used when a purchase is about to be executed?
func userDidProvideCreditCardInfo(cardInfo: CardIOCreditCardInfo!, inPaymentViewController paymentViewController: CardIOPaymentViewController!) {
if let info = cardInfo {
let str = NSString(format: "Received card info.\n Number: %@\n expiry: %02lu/%lu\n cvv: %@.", info.redactedCardNumber, info.expiryMonth, info.expiryYear, info.cvv)
print(str)
//dismiss scanning controller
paymentViewController?.dismissViewControllerAnimated(true, completion: nil)
//create Stripe card
let card: STPCardParams = STPCardParams()
card.number = info.cardNumber
card.expMonth = info.expiryMonth
card.expYear = info.expiryYear
card.cvc = info.cvv
//Send to Stripe
getStripeToken(card)
}
}
Edit: I should add that I'm curious if I have to begin processing a payment to confirm a card or can I do that beforehand? (example: the exp date you entered is incorrect).
textField.isValid
in that case validates that each of the STPPaymentCardTextField
fields are valid ; that doesn't involve any API calls to Stripe.
The second example does make a 'create Token' API call to Stripe, though that also doesn't actually validate the Card; it's not until you use it to create a Customer or store it on an existing Customer , or to create a Charge , that it gets validated.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.