Integrate Braintree Payment Gateway in iOS Swift 4
Posted By : Vasu Saini | 24-Nov-2017
Braintree is a very useful payment gateway especially for USA
Step 1. Most of the work of brain tree payment gateway is to be
Step 2. Create a new project in which
Step 3. Install following pod if
pod 'BraintreeDropIn'
If
pod 'Braintree', '~> 3.9'
Let us consider is above 9.0
Step 4. Import following 2 modules class in which
import BraintreeDropIn
import Braintree
Step 5.After Setup
Step 6. Hit the URL and get and save the token
Step 7. After Getting token Call Braintree Method by passing token provided by your backend as shown below
//Brain Tree Method
func showDropIn(clientTokenOrTokenizationKey: String) {
let request = BTDropInRequest()
let dropIn = BTDropInController(authorization: clientTokenOrTokenizationKey, request: request)
{ (controller, result, error) in
if (error != nil) {
print("ERROR")
} else if (result?.isCancelled == true) {
print("CANCELLED")
} else if let result = result {
//Save Nounce and call api provide by your backend passing amount and nounce string (nounce strin can be get from result.paymentMethod?.nounce)
}
controller.dismiss(animated: true, completion: nil)
}
self.present(dropIn!, animated: true, completion: nil)
}
Step 8. Here an options is asked for payment method , select any payment method and fill details which is to asked for ex. card details, cvv, expiry date etc.
Step 9. After calling this method you will get result dictionary from which you can get a string named as
Step 9. Ask backed for web service
1.Amount to be deduct
2.
Step 10. This API will give u status of transaction in response whether is it successful or not
All done with
for reference -https://developers.braintreepayments.com/start/hello-client/ios/v4
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Vasu Saini
Vasu Saini is Passionate to deploy ideas into real world, Have zeal to learn new technologies. working as iOS Developer in Oodles Technologies. Sports Freak, Calisthenics ,Parkour, Love to play football, swimmer, athletics etc