Repository navigation
6.0.0
Added
- New
ReceiptValidator\AppleAppStorenamespace for Apple's App Store Server API and App Store
Server Notifications V2 (merged through
#192 and
#193):AppleAppStore\Validatorwith__construct(string $signingKey, string $keyId, string $issuerId, string $bundleId, Environment $environment = Environment::PRODUCTION),setTransactionId(string $transactionId): selfandvalidate(?string $transactionId = null): AppleAppStore\Response. It
signs an ES256 JWT with your App Store Connect API key and callsGET /inApps/v2/history/{transactionId}onENDPOINT_PRODUCTION
(https://api.storekit.itunes.apple.com) orENDPOINT_SANDBOX
(https://api.storekit-sandbox.itunes.apple.com); a missing transaction ID, transport failure,
non-200 status or JWT generation failure throwsValidationException.AppleAppStore\Response(ArrayAccess) withgetRevision(),getBundleId(),
getAppAppleId(),hasMore(),getSignedTransactions()plus the inherited
getTransactions(),getRawData()andgetEnvironment(). Each entry ofsignedTransactions
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\ServerNotificationfor Server Notifications V2:__construct(array $data)takes
the decoded request body, requires asignedPayloadkey, verifies its signature (throwing
ValidationExceptionotherwise) and exposesgetNotificationType(): ServerNotificationType,
getSubtype(): ?ServerNotificationSubtype,getNotificationUUID(),getSignedDate(),
getBundleId(),getEnvironment(),getTransaction(): ?TransactionandgetRenewalInfo(): ?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 underJWT/and
could not be autoloaded; see 6.0.2. AppleAppStore\ReceiptUtilitywith staticextractTransactionIdFromAppReceipt(string $appReceipt): ?stringandextractTransactionIdFromTransactionReceipt(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, staticdecodeToken(string $signedPayload): Token),TokenGeneratorConfig(forAppStore(TokenIssuer, ?Clock),
config(),issuer(),clock()),TokenIssuer(id(),bundle(),key(),signer()),
TokenKey(kid(),contents(),passphrase()) andTokenVerifier::verify(Token): bool,
which requiresalgES256, a three-certificatex5cchain whose intermediate and root SHA-1
fingerprints match Apple's, a valid chain, and a signature that verifies against the leaf
certificate.
iTunes\ServerNotificationfor the legacy (V1) server-to-server notifications:__construct(array $data, ?string $sharedSecret = null)throwsValidationExceptionunless the payload'spassword
equals the shared secret, then exposesgetNotificationType(): iTunes\ServerNotificationType,
getEnvironment(),getAutoRenewProductId(),getAutoRenewStatus(),
getAutoRenewStatusChangeDate(),getBundleId(),getBvrs(),getOriginalTransactionId(),
getPassword(),getLatestReceipt(): iTunes\ResponseandgetPendingRenewalInfo(): ?iTunes\RenewalInfo. String-backed enumiTunes\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\Environmentenum (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$clientproperty for injecting a Guzzle client),AbstractResponse
(getTransactions(),getRawData(),getEnvironment(),setEnvironment(), abstractparse())
andAbstractTransaction(getRawData(),getQuantity()/setQuantity(),
getProductId()/setProductId(),getTransactionId()/setTransactionId(), abstractparse()). iTunes\Transaction::hasExpired(): boolandwasCanceled(): boolconvenience checks.Amazon\Transaction::getGracePeriodEndDate(),getFreeTrialEndDate(),isAutoRenewing(),
getTerm()andgetTermSku(), exposing the remaining fields of Amazon's RVS response.
Changed
- Breaking: composer.json: PHP requirement raised from
^8.2to^8.3;guzzlehttp/guzzle
narrowed from^6.3|^7.0to^7.0(Guzzle 6 dropped);nesbot/carbonnarrowed from
^1.0|^2.0|^3.0to^2.72.6|^3.0; new requirementslcobucci/jwt ^5.5,lcobucci/clock ^3.3,
phpseclib/phpseclib ^3.0andext-openssl;google/apiclient ^2.10and
google/apiclient-services ~0.249removed. - Breaking:
iTunes\Validatorconstructor is now__construct(?string $sharedSecret = null, Environment $environment = Environment::PRODUCTION)(was__construct(string $endpoint = self::ENDPOINT_PRODUCTION)), andvalidate()is nowvalidate(?string $receiptData = null): iTunes\Response(wasvalidate(?string $receipt_data = null, ?string $shared_secret = null): ResponseInterface).setReceiptData(string $receiptData = '')no longer acceptsnull. The
RESULT_*status constants moved fromiTunes\ResponseInterfaceontoiTunes\Validator, with
RESULT_VALID_NO_PURCHASE(2) added. - Breaking:
iTunes\Validatornow throwsValidationExceptionfor every Apple status other
than 0 and 21006 (expired subscription) instead of returning a response whoseisValid()is
false. When running against production and Apple returns 21007 (sandbox receipt sent to
production) it transparently retries against the sandbox endpoint and returns aResponsewhose
getEnvironment()isEnvironment::SANDBOX. Theexclude-old-transactionsflag is no longer
sent (see Removed). - Breaking: the iTunes response hierarchy is collapsed into a single
iTunes\Responseclass
(constructor(?array $data = [], Environment $environment = Environment::PRODUCTION)). Compared
with the oldAbstractResponse/ResponseInterface:getPurchases()is nowgetTransactions()
(returningiTunes\Transaction[]),isSandbox()/isProduction()are replaced by
getEnvironment(): Environment,parseData()isparse(), andgetBundleId()/getAppItemId()
now return?stringinstead ofstring.isRetryable(),getLatestReceipt(),
getLatestReceiptInfo(),getPendingRenewalInfo(),getOriginalPurchaseDate(),
getRequestDate(),getReceiptCreationDate()andgetRawData()are kept. - Breaking:
iTunes\PurchaseItemis renamediTunes\Transaction(now extends
AbstractTransaction);getRawResponse()is nowgetRawData()andparseData()isparse().
All other getters keep their names. - Breaking:
iTunes\PendingRenewalInfois renamediTunes\RenewalInfo; the getters and the
EXPIRATION_INTENT_*,RETRY_PERIOD_*,AUTO_RENEW_*andSTATUS_*constants are unchanged. - Breaking:
Amazon\Validatorconstructor is now__construct(string $developerSecret, Environment $environment)(was__construct(string $endpoint = self::ENDPOINT_PRODUCTION)).
ENDPOINT_SANDBOXchanged fromhttp://localhost:8080/RVSSandbox/to
https://appstore-sdk.amazon.com/sandboxandENDPOINT_PRODUCTIONfrom
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\Responsenow throwsValidationException(code = HTTP status)
on any non-200 reply instead of returning a response with a result code. - Breaking:
Amazon\PurchaseItemis renamedAmazon\Transaction(extends
AbstractTransaction, implementsArrayAccess);getRawResponse()is nowgetRawData()and
parseJsonResponse()isparse(). - Breaking:
Amazon\Responsenow extendsAbstractResponsewith constructor(?array $data = [], Environment $environment = Environment::PRODUCTION)(was(int $httpStatusCode = 200, ?array $jsonResponse = [])).getPurchases()is nowgetTransactions()(a single
Amazon\Transaction),parseJsonResponse()isparse(), and the receipt fields are available
throughgetRawData().
Removed
- Breaking: Google Play support is gone:
GooglePlay\Validator,GooglePlay\Acknowledger,
GooglePlay\AbstractResponse,GooglePlay\PurchaseResponse,GooglePlay\SubscriptionResponse
andGooglePlay\SubscriptionV2Responsewere deleted along with thegoogle/apiclient
dependencies. - Breaking:
iTunes\AbstractResponse,iTunes\ProductionResponse,iTunes\SandboxResponse,
iTunes\ResponseInterfaceandiTunes\EnvironmentResponseInterfacewere removed in favour of
iTunes\Response; with them wentgetResultCode(),setResultCode(),isValid(),
getReceipt(),getPurchases(),isSandbox()andisProduction(). - Breaking:
iTunes\Validator::getEndpoint(),setEndpoint(),getExcludeOldTransactions(),
setExcludeOldTransactions(),getRequestOptions()andsetRequestOptions()were removed; the
environment is chosen viaEnvironment, and custom Guzzle options can only be applied by
assigning your own client to the public$clientproperty. - Breaking:
Amazon\Validator::getEndpoint()/setEndpoint()andAmazon\Response::RESULT_OK,
RESULT_INVALID_RECEIPT,RESULT_INVALID_DEVELOPER_SECRET,RESULT_INVALID_USER_ID,
RESULT_INTERNAL_ERROR,getResultCode(),getReceipt(),getPurchases()andisValid()were
removed (the four error codes live onAmazon\ValidatorasRESULT_INVALID_RECEIPT,
RESULT_INVALID_DEVELOPER_SECRET,RESULT_INVALID_USER_ID,RESULT_INTERNAL_ERRORuntil 6.1.0). - Breaking:
ReceiptValidator\RunTimeExceptionwas removed; all errors are now
ReceiptValidator\Exceptions\ValidationException.
Notes written from the code diff for this release; see CHANGELOG.md.