Skip to content

Instantly share code, notes, and snippets.

@shiningabdul
Last active January 9, 2018 05:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shiningabdul/9583b5bfcb3e2e37c6ea3e107804c36c to your computer and use it in GitHub Desktop.
Save shiningabdul/9583b5bfcb3e2e37c6ea3e107804c36c to your computer and use it in GitHub Desktop.
import UIKit
import PassKit
import Stripe
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
addApplePayPaymentButtonToView()
}
private func addApplePayPaymentButtonToView() {
let paymentButton = PKPaymentButton(paymentButtonType: .buy, paymentButtonStyle: .black)
paymentButton.translatesAutoresizingMaskIntoConstraints = false
paymentButton.addTarget(self, action: #selector(applePayButtonTapped(sender:)), for: .touchUpInside)
view.addSubview(paymentButton)
view.addConstraint(NSLayoutConstraint(item: paymentButton, attribute: .centerX, relatedBy: .equal, toItem: view, attribute: .centerX, multiplier: 1, constant: 0))
view.addConstraint(NSLayoutConstraint(item: paymentButton, attribute: .centerY, relatedBy: .equal, toItem: view, attribute: .centerY, multiplier: 1, constant: 0))
}
@objc private func applePayButtonTapped(sender: UIButton) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment