Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating new fields added in App Store Server API v1.10\n\nhttps://de… #33

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions models/JWSTransactionDecodedPayload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { DecodedSignedData } from "./DecodedSignedData"
import { Environment, EnvironmentValidator } from "./Environment"
import { InAppOwnershipType, InAppOwnershipTypeValidator } from "./InAppOwnershipType"
import { OfferDiscountType, OfferDiscountTypeValidator } from "./OfferDiscountType"
import { OfferType, OfferTypeValidator } from "./OfferType"
import { RevocationReason, RevocationReasonValidator } from "./RevocationReason"
import { TransactionReason, TransactionReasonValidator } from "./TransactionReason"
Expand Down Expand Up @@ -176,6 +177,27 @@ export interface JWSTransactionDecodedPayload extends DecodedSignedData {
* {@link https://developer.apple.com/documentation/appstoreserverapi/transactionreason transactionReason}
**/
transactionReason?: TransactionReason

/**
* The three-letter ISO 4217 currency code for the price of the product.
*
* {@link https://developer.apple.com/documentation/appstoreserverapi/currency currency}
**/
currency?: string

/**
* The price of the in-app purchase or subscription offer that you configured in App Store Connect, as an integer.
*
* {@link https://developer.apple.com/documentation/appstoreserverapi/price price}
**/
price?: number

/**
* The payment mode you configure for an introductory offer, promotional offer, or offer code on an auto-renewable subscription.
*
* {@link https://developer.apple.com/documentation/appstoreserverapi/offerdiscounttype offerDiscountType}
**/
offerDiscountType?: OfferDiscountType
}


Expand All @@ -186,6 +208,7 @@ export class JWSTransactionDecodedPayloadValidator implements Validator<JWSTrans
static readonly inAppOwnershipTypeValidator = new InAppOwnershipTypeValidator()
static readonly typeValidator = new TypeValidator()
static readonly transactionReasonValidator = new TransactionReasonValidator()
static readonly offerDiscountTypeValidator = new OfferDiscountTypeValidator()
validate(obj: any): obj is JWSTransactionDecodedPayload {
if ((typeof obj['originalTransactionId'] !== 'undefined') && !(typeof obj['originalTransactionId'] === "string" || obj['originalTransactionId'] instanceof String)) {
return false
Expand Down Expand Up @@ -256,6 +279,15 @@ export class JWSTransactionDecodedPayloadValidator implements Validator<JWSTrans
if ((typeof obj['transactionReason'] !== 'undefined') && !(JWSTransactionDecodedPayloadValidator.transactionReasonValidator.validate(obj['transactionReason']))) {
return false
}
if ((typeof obj['currency'] !== 'undefined') && !(typeof obj['currency'] === "string" || obj['currency'] instanceof String)) {
return false
}
if ((typeof obj['price'] !== 'undefined') && !(typeof obj['price'] === "number")) {
return false
}
if ((typeof obj['offerDiscountType'] !== 'undefined') && !(JWSTransactionDecodedPayloadValidator.offerDiscountTypeValidator.validate(obj['offerDiscountType']))) {
return false
}
return true
}
}
20 changes: 20 additions & 0 deletions models/OfferDiscountType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) 2023 Apple Inc. Licensed under MIT License.

import { Validator } from "./Validator";

/**
* The payment mode you configure for an introductory offer, promotional offer, or offer code on an auto-renewable subscription.
*
* {@link https://developer.apple.com/documentation/appstoreserverapi/offerdiscounttype offerDiscountType}
*/
export enum OfferDiscountType {
FREE_TRIAL = "FREE_TRIAL",
PAY_AS_YOU_GO = "PAY_AS_YOU_GO",
PAY_UP_FRONT = "PAY_UP_FRONT"
}

export class OfferDiscountTypeValidator implements Validator<OfferDiscountType> {
validate(obj: any): obj is OfferDiscountType {
return Object.values(OfferDiscountType).includes(obj)
}
}