Skip to content
Samuel Spencer edited this page Jan 22, 2021 · 1 revision

In order to provide a discount to your users when completing a purchase, you must supply an SKPaymentDiscount object formatted as a SwiftyStoreKit PaymentDiscount:

let discount = PaymentDiscount(discount: SKPaymentDiscount(...))

However, in order to generate an SKPaymentDiscount object (for now), you'll need to follow along with Apple's required setup. According to the SKPaymentDiscount documentation:

Include the signature that you generated [for the discount]. The App Store uses this signature and the parameters to validate the promotional offer. Keep in mind that the signature must correspond to the parameters in the payment for a transaction to be successful.

The link above explains the process for generating a signature.

Once you've accomplished this, you can simply supply your discount object as a parameter in the call to purchase(...) on SwiftyStoreKit.