Skip to content

Commit

Permalink
make product non nil in send(receipt) method
Browse files Browse the repository at this point in the history
  • Loading branch information
Gio2018 committed May 3, 2023
1 parent ab306c1 commit 226c6d9
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import SharedPocketKit

/// Generic type to send subscription receipt to a server
public protocol ReceiptService {
func send(_ product: Product?) async throws
func send(_ product: Product) async throws
}

public enum ReceiptError: LoggableError {
Expand Down Expand Up @@ -36,7 +36,7 @@ class AppStoreReceiptService: NSObject, ReceiptService {
super.init()
}

func send(_ product: Product?) async throws {
func send(_ product: Product) async throws {
// on simulators, we typically use a local test environment, and don't want
// to send the receipt to the backend
#if targetEnvironment(simulator)
Expand All @@ -52,10 +52,10 @@ class AppStoreReceiptService: NSObject, ReceiptService {

let transactionInfo = try getReceipt()
let source = "itunes"
let productId = product?.id ?? ""
let amount = product?.price != nil ? "\(product!.price)" : ""
let transactionType = product != nil ? "purchase" : "restore"
let currency = product?.priceFormatStyle.currencyCode ?? ""
let productId = product.id
let amount = "\(product.price)"
let transactionType = "purchase"
let currency = product.priceFormatStyle.currencyCode

try await client.sendAppstoreReceipt(
source: source,
Expand Down

0 comments on commit 226c6d9

Please sign in to comment.