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 Intents | |
class IntentHandler: INExtension { | |
override func handler(for intent: INIntent) -> Any { | |
// This is the default implementation. If you want different objects to handle different intents, | |
// you can override this and return the handler you want for that particular intent. | |
if intent is OrderPizzaIntent { | |
return OrderPizzaIntentHandler() | |
} |
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 IntentsUI | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view. | |
let addShortcutButton = INUIAddVoiceShortcutButton(style: .blackOutline) | |
let intent = OrderPizzaIntent() |
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
@IBAction func showButtonTapped(_ sender: Any) { | |
guard let newMessage = messageField.text else { | |
return | |
} | |
messageLabel.text = newMessage | |
let intent = IntentManager.shared.intent(withMessage: newMessage) | |
IntentManager.shared.donateShortcuts(withIntent: intent) | |
} |
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 Foundation | |
import Intents | |
class IntentManager { | |
static let shared = IntentManager() | |
func intent(withMessage message:String) -> ShowMessageIntent { | |
let intent = ShowMessageIntent() | |
intent.message = message | |
return intent |
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
class ViewController: UIViewController { | |
@IBOutlet weak var messageLabel: UILabel! | |
@IBOutlet weak var messageField: UITextField! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
} |
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
func paymentAuthorizationViewController(_ controller: PKPaymentAuthorizationViewController, didAuthorizePayment payment: PKPayment, handler completion: @escaping (PKPaymentAuthorizationResult) -> Void) { | |
// Use Stripe to charge the user | |
STPAPIClient.shared().createToken(with: payment) { (stripeToken, error) in | |
guard error == nil, let stripeToken = stripeToken else { | |
print(error!) | |
return | |
} | |
let url = URL(string:"http://localhost:3000/pay") | |
guard let apiUrl = url else { |
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
// Add packages we need | |
const express = require('express') | |
const bodyParser = require('body-parser') | |
var stripe = require('stripe')('YOUR SECRET KEY FROM STRIPE') | |
// Create an express app | |
const app = express() | |
// Use body parser so we can parse the body of requests | |
app.use(bodyParser.json()) |
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
class UIViewController: UIViewController, PKPaymentAuthorizationViewControllerDelegate { | |
@objc private func applePayButtonTapped(sender: UIButton) { | |
// Cards that should be accepted | |
let paymentNetworks:[PKPaymentNetwork] = [.amex,.masterCard,.visa] | |
if PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: paymentNetworks) { | |
let request = PKPaymentRequest() | |
request.merchantIdentifier = "merchant.com.shiningdevelopers" | |
request.countryCode = "CA" |
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. | |
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 Stripe | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
// Override point for customization after application launch. |
NewerOlder