Last active
January 9, 2018 05:22
-
-
Save shiningabdul/9583b5bfcb3e2e37c6ea3e107804c36c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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