Skip to content

6.0.0

Choose a tag to compare

@aporat aporat released this 19 Apr 16:50
· 157 commits to main since this release

Added

  • New ReceiptValidator\AppleAppStore namespace for Apple's App Store Server API and App Store
    Server Notifications V2 (merged through
    #192 and
    #193):
    • AppleAppStore\Validator with __construct(string $signingKey, string $keyId, string $issuerId, string $bundleId, Environment $environment = Environment::PRODUCTION), setTransactionId(string $transactionId): self and validate(?string $transactionId = null): AppleAppStore\Response. It
      signs an ES256 JWT with your App Store Connect API key and calls GET /inApps/v2/history/{transactionId} on ENDPOINT_PRODUCTION
      (https://api.storekit.itunes.apple.com) or ENDPOINT_SANDBOX
      (https://api.storekit-sandbox.itunes.apple.com); a missing transaction ID, transport failure,
      non-200 status or JWT generation failure throws ValidationException.
    • AppleAppStore\Response (ArrayAccess) with getRevision(), getBundleId(),
      getAppAppleId(), hasMore(), getSignedTransactions() plus the inherited
      getTransactions(), getRawData() and getEnvironment(). Each entry of signedTransactions
      is decoded and its signature and x5c certificate chain verified before it becomes a
      Transaction.
    • AppleAppStore\Transaction (ArrayAccess) exposing the decoded JWS transaction payload:
      getOriginalTransactionId(), getTransactionId(), getWebOrderLineItemId(), getBundleId(),
      getProductId(), getSubscriptionGroupIdentifier(), getPurchaseDate(),
      getOriginalPurchaseDate(), getExpiresDate(), getQuantity(), getType(),
      getAppAccountToken(), getInAppOwnershipType(), getSignedDate(), getRevocationReason(),
      getRevocationDate(), getIsUpgraded(), getOfferType(), getOfferIdentifier(),
      getStorefront(), getStorefrontId(), getTransactionReason(), getCurrency(), getPrice(),
      getOfferDiscountType(), getAppTransactionId(), getOfferPeriod().
    • AppleAppStore\RenewalInfo (ArrayAccess) exposing the decoded JWS renewal-info payload:
      getAutoRenewProductId(), getAutoRenewStatus(), getExpirationIntentDate(),
      isInBillingRetryPeriod(), isUpgraded(), getOriginalTransactionId(),
      getPriceConsentStatus(), getGracePeriodExpiresDate(), getRenewalPrice(), getCurrency(),
      getOfferIdentifier(), getOfferType(), getOfferDiscountType(), getOfferPeriod(),
      getAppTransactionId(), getAppAccountToken(), getEligibleWinBackOfferIds(),
      getSignedDate(), getRecentSubscriptionStartDate(), getRenewalDate().
    • AppleAppStore\ServerNotification for Server Notifications V2: __construct(array $data) takes
      the decoded request body, requires a signedPayload key, verifies its signature (throwing
      ValidationException otherwise) and exposes getNotificationType(): ServerNotificationType,
      getSubtype(): ?ServerNotificationSubtype, getNotificationUUID(), getSignedDate(),
      getBundleId(), getEnvironment(), getTransaction(): ?Transaction and getRenewalInfo(): ?RenewalInfo.
    • String-backed enums AppleAppStore\ServerNotificationType (SUBSCRIBED,
      DID_CHANGE_RENEWAL_PREF, DID_CHANGE_RENEWAL_STATUS, OFFER_REDEEMED, DID_RENEW,
      EXPIRED, DID_FAIL_TO_RENEW, GRACE_PERIOD_EXPIRED, PRICE_INCREASE, REFUND,
      REFUND_DECLINED, CONSUMPTION_REQUEST, RENEWAL_EXTENDED, REVOKE, TEST,
      RENEWAL_EXTENSION, REFUND_REVERSED, EXTERNAL_PURCHASE_TOKEN, ONE_TIME_CHARGE) and
      AppleAppStore\ServerNotificationSubtype (INITIAL_BUY, RESUBSCRIBE, DOWNGRADE, UPGRADE,
      AUTO_RENEW_ENABLED, AUTO_RENEW_DISABLED, VOLUNTARY, BILLING_RETRY, PRICE_INCREASE,
      GRACE_PERIOD, PENDING, ACCEPTED, BILLING_RECOVERY, PRODUCT_NOT_FOR_SALE, SUMMARY,
      FAILURE, UNREPORTED). In this release the subtype enum's file was misplaced under JWT/ and
      could not be autoloaded; see 6.0.2.
    • AppleAppStore\ReceiptUtility with static extractTransactionIdFromAppReceipt(string $appReceipt): ?string and extractTransactionIdFromTransactionReceipt(string $transactionReceipt): ?string, for pulling a transaction ID out of a legacy receipt so it can
      be looked up through the new API.
    • AppleAppStore\JWT\TokenGenerator (generate(): Token, static decodeToken(string $signedPayload): Token), TokenGeneratorConfig (forAppStore(TokenIssuer, ?Clock),
      config(), issuer(), clock()), TokenIssuer (id(), bundle(), key(), signer()),
      TokenKey (kid(), contents(), passphrase()) and TokenVerifier::verify(Token): bool,
      which requires alg ES256, a three-certificate x5c chain whose intermediate and root SHA-1
      fingerprints match Apple's, a valid chain, and a signature that verifies against the leaf
      certificate.
  • iTunes\ServerNotification for the legacy (V1) server-to-server notifications: __construct(array $data, ?string $sharedSecret = null) throws ValidationException unless the payload's password
    equals the shared secret, then exposes getNotificationType(): iTunes\ServerNotificationType,
    getEnvironment(), getAutoRenewProductId(), getAutoRenewStatus(),
    getAutoRenewStatusChangeDate(), getBundleId(), getBvrs(), getOriginalTransactionId(),
    getPassword(), getLatestReceipt(): iTunes\Response and getPendingRenewalInfo(): ?iTunes\RenewalInfo. String-backed enum iTunes\ServerNotificationType (CANCEL,
    CONSUMPTION_REQUEST, DID_CHANGE_RENEWAL_PREF, DID_CHANGE_RENEWAL_STATUS,
    DID_FAIL_TO_RENEW, DID_RECOVER, DID_RENEW, INITIAL_BUY, INTERACTIVE_RENEWAL,
    PRICE_INCREASE_CONSENT, REFUND, REVOKE, TEST).
  • ReceiptValidator\Environment enum (SANDBOX, PRODUCTION), used by every validator, response
    and notification instead of endpoint strings.
  • ReceiptValidator\Exceptions\ValidationException, the single exception type thrown by all
    validators and parsers.
  • Shared base classes: AbstractValidator (getEnvironment(), setEnvironment(), abstract
    validate(), and a public $client property for injecting a Guzzle client), AbstractResponse
    (getTransactions(), getRawData(), getEnvironment(), setEnvironment(), abstract parse())
    and AbstractTransaction (getRawData(), getQuantity()/setQuantity(),
    getProductId()/setProductId(), getTransactionId()/setTransactionId(), abstract parse()).
  • iTunes\Transaction::hasExpired(): bool and wasCanceled(): bool convenience checks.
  • Amazon\Transaction::getGracePeriodEndDate(), getFreeTrialEndDate(), isAutoRenewing(),
    getTerm() and getTermSku(), exposing the remaining fields of Amazon's RVS response.

Changed

  • Breaking: composer.json: PHP requirement raised from ^8.2 to ^8.3; guzzlehttp/guzzle
    narrowed from ^6.3|^7.0 to ^7.0 (Guzzle 6 dropped); nesbot/carbon narrowed from
    ^1.0|^2.0|^3.0 to ^2.72.6|^3.0; new requirements lcobucci/jwt ^5.5, lcobucci/clock ^3.3,
    phpseclib/phpseclib ^3.0 and ext-openssl; google/apiclient ^2.10 and
    google/apiclient-services ~0.249 removed.
  • Breaking: iTunes\Validator constructor is now __construct(?string $sharedSecret = null, Environment $environment = Environment::PRODUCTION) (was __construct(string $endpoint = self::ENDPOINT_PRODUCTION)), and validate() is now validate(?string $receiptData = null): iTunes\Response (was validate(?string $receipt_data = null, ?string $shared_secret = null): ResponseInterface). setReceiptData(string $receiptData = '') no longer accepts null. The
    RESULT_* status constants moved from iTunes\ResponseInterface onto iTunes\Validator, with
    RESULT_VALID_NO_PURCHASE (2) added.
  • Breaking: iTunes\Validator now throws ValidationException for every Apple status other
    than 0 and 21006 (expired subscription) instead of returning a response whose isValid() is
    false. When running against production and Apple returns 21007 (sandbox receipt sent to
    production) it transparently retries against the sandbox endpoint and returns a Response whose
    getEnvironment() is Environment::SANDBOX. The exclude-old-transactions flag is no longer
    sent (see Removed).
  • Breaking: the iTunes response hierarchy is collapsed into a single iTunes\Response class
    (constructor (?array $data = [], Environment $environment = Environment::PRODUCTION)). Compared
    with the old AbstractResponse/ResponseInterface: getPurchases() is now getTransactions()
    (returning iTunes\Transaction[]), isSandbox()/isProduction() are replaced by
    getEnvironment(): Environment, parseData() is parse(), and getBundleId()/getAppItemId()
    now return ?string instead of string. isRetryable(), getLatestReceipt(),
    getLatestReceiptInfo(), getPendingRenewalInfo(), getOriginalPurchaseDate(),
    getRequestDate(), getReceiptCreationDate() and getRawData() are kept.
  • Breaking: iTunes\PurchaseItem is renamed iTunes\Transaction (now extends
    AbstractTransaction); getRawResponse() is now getRawData() and parseData() is parse().
    All other getters keep their names.
  • Breaking: iTunes\PendingRenewalInfo is renamed iTunes\RenewalInfo; the getters and the
    EXPIRATION_INTENT_*, RETRY_PERIOD_*, AUTO_RENEW_* and STATUS_* constants are unchanged.
  • Breaking: Amazon\Validator constructor is now __construct(string $developerSecret, Environment $environment) (was __construct(string $endpoint = self::ENDPOINT_PRODUCTION)).
    ENDPOINT_SANDBOX changed from http://localhost:8080/RVSSandbox/ to
    https://appstore-sdk.amazon.com/sandbox and ENDPOINT_PRODUCTION from
    https://appstore-sdk.amazon.com/version/1.0/verifyReceiptId/ to
    https://appstore-sdk.amazon.com (the
    /version/1.0/verifyReceiptId/developer/{secret}/user/{user}/receiptId/{id} path is built
    internally). validate(): Amazon\Response now throws ValidationException (code = HTTP status)
    on any non-200 reply instead of returning a response with a result code.
  • Breaking: Amazon\PurchaseItem is renamed Amazon\Transaction (extends
    AbstractTransaction, implements ArrayAccess); getRawResponse() is now getRawData() and
    parseJsonResponse() is parse().
  • Breaking: Amazon\Response now extends AbstractResponse with constructor (?array $data = [], Environment $environment = Environment::PRODUCTION) (was (int $httpStatusCode = 200, ?array $jsonResponse = [])). getPurchases() is now getTransactions() (a single
    Amazon\Transaction), parseJsonResponse() is parse(), and the receipt fields are available
    through getRawData().

Removed

  • Breaking: Google Play support is gone: GooglePlay\Validator, GooglePlay\Acknowledger,
    GooglePlay\AbstractResponse, GooglePlay\PurchaseResponse, GooglePlay\SubscriptionResponse
    and GooglePlay\SubscriptionV2Response were deleted along with the google/apiclient
    dependencies.
  • Breaking: iTunes\AbstractResponse, iTunes\ProductionResponse, iTunes\SandboxResponse,
    iTunes\ResponseInterface and iTunes\EnvironmentResponseInterface were removed in favour of
    iTunes\Response; with them went getResultCode(), setResultCode(), isValid(),
    getReceipt(), getPurchases(), isSandbox() and isProduction().
  • Breaking: iTunes\Validator::getEndpoint(), setEndpoint(), getExcludeOldTransactions(),
    setExcludeOldTransactions(), getRequestOptions() and setRequestOptions() were removed; the
    environment is chosen via Environment, and custom Guzzle options can only be applied by
    assigning your own client to the public $client property.
  • Breaking: Amazon\Validator::getEndpoint()/setEndpoint() and Amazon\Response::RESULT_OK,
    RESULT_INVALID_RECEIPT, RESULT_INVALID_DEVELOPER_SECRET, RESULT_INVALID_USER_ID,
    RESULT_INTERNAL_ERROR, getResultCode(), getReceipt(), getPurchases() and isValid() were
    removed (the four error codes live on Amazon\Validator as RESULT_INVALID_RECEIPT,
    RESULT_INVALID_DEVELOPER_SECRET, RESULT_INVALID_USER_ID, RESULT_INTERNAL_ERROR until 6.1.0).
  • Breaking: ReceiptValidator\RunTimeException was removed; all errors are now
    ReceiptValidator\Exceptions\ValidationException.

Notes written from the code diff for this release; see CHANGELOG.md.