You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/Orders/Orders.docc/GettingStarted.md
+8-6
Original file line number
Diff line number
Diff line change
@@ -147,8 +147,6 @@ final class OrderDelegate: OrdersDelegate {
147
147
148
148
Next, initialize the ``OrdersService`` inside the `configure.swift` file.
149
149
This will implement all of the routes that Apple Wallet expects to exist on your server.
150
-
In the `signingFilesDirectory` you specify there must be the `WWDR.pem`, `certificate.pem` and `key.pem` files.
151
-
If they are named like that you're good to go, otherwise you have to specify the custom name.
152
150
153
151
> Tip: Obtaining the three certificates files could be a bit tricky. You could get some guidance from [this guide](https://github.com/alexandercerutti/passkit-generator/wiki/Generating-Certificates) and [this video](https://www.youtube.com/watch?v=rJZdPoXHtzI). Those guides are for Wallet passes, but the process is similar for Wallet orders.
> Note: You'll have to register the `OrdersController` in the `configure.swift` file, in order to pass it the ``OrdersService`` object.
286
288
287
-
Then use the object inside your route handlers to generate the order bundle with the ``OrdersService/generateOrderContent(for:on:)`` method and distribute it with the "`application/vnd.apple.order`" MIME type.
289
+
Then use the object inside your route handlers to generate the order bundle with the ``OrdersService/build(order:on:)`` method and distribute it with the "`application/vnd.apple.order`" MIME type.
Copy file name to clipboardExpand all lines: Sources/Orders/OrdersService.swift
+18-30
Original file line number
Diff line number
Diff line change
@@ -17,37 +17,34 @@ public final class OrdersService: Sendable {
17
17
/// - Parameters:
18
18
/// - app: The `Vapor.Application` to use in route handlers and APNs.
19
19
/// - delegate: The ``OrdersDelegate`` to use for order generation.
20
-
/// - signingFilesDirectory: The path of the directory where the signing files (`wwdrCertificate`, `pemCertificate`, `pemPrivateKey`) are located.
21
-
/// - wwdrCertificate: The name of Apple's WWDR.pem certificate as contained in `signingFilesDirectory` path. Defaults to `WWDR.pem`.
22
-
/// - pemCertificate: The name of the PEM Certificate for signing the pass as contained in `signingFilesDirectory` path. Defaults to `certificate.pem`.
23
-
/// - pemPrivateKey: The name of the PEM Certificate's private key for signing the pass as contained in `signingFilesDirectory` path. Defaults to `key.pem`.
24
-
/// - pemPrivateKeyPassword: The password to the private key file. If the key is not encrypted it must be `nil`. Defaults to `nil`.
25
-
/// - sslBinary: The location of the `openssl` command as a file path.
26
20
/// - pushRoutesMiddleware: The `Middleware` to use for push notification routes. If `nil`, push routes will not be registered.
27
21
/// - logger: The `Logger` to use.
22
+
/// - pemWWDRCertificate: Apple's WWDR.pem certificate in PEM format.
23
+
/// - pemCertificate: The PEM Certificate for signing orders.
24
+
/// - pemPrivateKey: The PEM Certificate's private key for signing orders.
25
+
/// - pemPrivateKeyPassword: The password to the private key. If the key is not encrypted it must be `nil`. Defaults to `nil`.
26
+
/// - openSSLPath: The location of the `openssl` command as a file path.
28
27
publicinit(
29
28
app:Application,
30
29
delegate:anyOrdersDelegate,
31
-
signingFilesDirectory:String,
32
-
wwdrCertificate:String="WWDR.pem",
33
-
pemCertificate:String="certificate.pem",
34
-
pemPrivateKey:String="key.pem",
35
-
pemPrivateKeyPassword:String?=nil,
36
-
sslBinary:String="/usr/bin/openssl",
37
30
pushRoutesMiddleware:(anyMiddleware)?=nil,
38
-
logger:Logger?=nil
31
+
logger:Logger?=nil,
32
+
pemWWDRCertificate:String,
33
+
pemCertificate:String,
34
+
pemPrivateKey:String,
35
+
pemPrivateKeyPassword:String?=nil,
36
+
openSSLPath:String="/usr/bin/openssl"
39
37
)throws{
40
38
self.service =try.init(
41
39
app: app,
42
40
delegate: delegate,
43
-
signingFilesDirectory: signingFilesDirectory,
44
-
wwdrCertificate: wwdrCertificate,
41
+
pushRoutesMiddleware: pushRoutesMiddleware,
42
+
logger: logger,
43
+
pemWWDRCertificate: pemWWDRCertificate,
45
44
pemCertificate: pemCertificate,
46
45
pemPrivateKey: pemPrivateKey,
47
46
pemPrivateKeyPassword: pemPrivateKeyPassword,
48
-
sslBinary: sslBinary,
49
-
pushRoutesMiddleware: pushRoutesMiddleware,
50
-
logger: logger
47
+
openSSLPath: openSSLPath
51
48
)
52
49
}
53
50
@@ -56,9 +53,10 @@ public final class OrdersService: Sendable {
56
53
/// - Parameters:
57
54
/// - order: The order to generate the content for.
58
55
/// - db: The `Database` to use.
56
+
///
59
57
/// - Returns: The generated order content.
60
-
publicfuncgenerateOrderContent(for order:Order, on db:anyDatabase)asyncthrows->Data{
61
-
tryawait service.generateOrderContent(for: order, on: db)
58
+
publicfuncbuild(order:Order, on db:anyDatabase)asyncthrows->Data{
59
+
tryawait service.build(order: order, on: db)
62
60
}
63
61
64
62
/// Adds the migrations for Wallet orders models.
@@ -71,16 +69,6 @@ public final class OrdersService: Sendable {
71
69
migrations.add(OrdersErrorLog())
72
70
}
73
71
74
-
/// Sends push notifications for a given order.
75
-
///
76
-
/// - Parameters:
77
-
/// - id: The `UUID` of the order to send the notifications for.
78
-
/// - typeIdentifier: The type identifier of the order.
79
-
/// - db: The `Database` to use.
80
-
publicfunc sendPushNotificationsForOrder(id:UUID, of typeIdentifier:String, on db:anyDatabase)asyncthrows{
81
-
tryawait service.sendPushNotificationsForOrder(id: id, of: typeIdentifier, on: db)
0 commit comments