Updated 26 August 2021
In this blog, we will know about the implementation of the Stripe payment gateway.
And you will receive the payment online from the customer using this payment gateway
1 |
pod 'Stripe' |
1 |
import Stripe |
you need to add class STPPaymentCardTextField of the text field then you can able to use its funtionality
If you want to use zip field then use or remove the zip code using the below code
1 |
cardTextField.postalCodeEntryEnabled = false |
1 2 3 4 5 6 |
Stripe.setDefaultPublishableKey(testPublishableKey ?? "") var paymentIntentClientSecret: String? @IBOutlet weak var cardTextField: STPPaymentCardTextField! @IBOutlet weak var payBtn: UIButton! |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
guard let paymentIntentClientSecret = paymentIntentClientSecret else { return; } let cardParams = cardTextField.cardParams let paymentMethodParams = STPPaymentMethodParams(card: cardParams, billingDetails: nil, metadata: nil) let paymentIntentParams = STPPaymentIntentParams(clientSecret: paymentIntentClientSecret) paymentIntentParams.paymentMethodParams = paymentMethodParams // Submit the payment let paymentHandler = STPPaymentHandler.shared() paymentHandler.confirmPayment(withParams: paymentIntentParams, authenticationContext: self) { (status, paymentIntent, error) in switch (status) { case .failed: print("Payment failed") print(error) break case .canceled: print("Payment canceled") break case .succeeded: print("Payment succeeded") break @unknown default: fatalError() break } |
And then please handle the response from the payment gateway and perform an action after success or failure.
Now you can execute the above code and you can receive payment through Stripe payment gateway
Thanks for reading 🙂
Hope this blog helped you with a better understanding of Stripe payment method.
For more technical blogs please visit here.
Wants to know more about Stripe gateway please visit here.
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.