Reputation: 1
According to the documentation and WWDC sessions, applicationUsername can be get in verify an App Store receipt with UUID. using Xcode 13.4.1, iOS 15.5
["receipt": {
"adam_id" = 0;
"app_item_id" = 0;
"application_version" = 2;
"bundle_id" = "com.***";
"download_id" = 0;
"in_app" = (
{
"in_app_ownership_type" = PURCHASED;
"is_trial_period" = false;
"original_purchase_date" = "2022-07-25 07:04:58 Etc/GMT";
"original_purchase_date_ms" = 1658732698000;
"original_purchase_date_pst" = "2022-07-25 00:04:58 America/Los_Angeles";
"original_transaction_id" = 2000000113747893;
"product_id" = "com.item_consumable1.test";
"purchase_date" = "2022-07-25 07:04:58 Etc/GMT";
"purchase_date_ms" = 1658732698000;
"purchase_date_pst" = "2022-07-25 00:04:58 America/Los_Angeles";
quantity = 1;
"transaction_id" = 2000000113747893;
}
);
"original_application_version" = "1.0";
"original_purchase_date" = "2013-08-01 07:00:00 Etc/GMT";
"original_purchase_date_ms" = 1375340400000;
"original_purchase_date_pst" = "2013-08-01 00:00:00 America/Los_Angeles";
"receipt_creation_date" = "2022-07-25 07:04:58 Etc/GMT";
"receipt_creation_date_ms" = 1658732698000;
"receipt_creation_date_pst" = "2022-07-25 00:04:58 America/Los_Angeles";
"receipt_type" = ProductionSandbox;
"request_date" = "2022-07-25 07:05:30 Etc/GMT";
"request_date_ms" = 1658732730724;
"request_date_pst" = "2022-07-25 00:05:30 America/Los_Angeles";
"version_external_identifier" = 0;
}, "environment": Sandbox, "status": 0]
Upvotes: 0
Views: 827
Reputation: 10416
Got it! Indeed hard to make work.
So you use applicationUsername
on the client side (link):
A string that associates the transaction with a user account on your service.
A major thing to watch out for is the following snippet:
Important
An applicationUsername property that isn’t a UUID isn’t guaranteed to persist between the time when you add the payment transaction to the queue and when the queue updates the transaction.
So initially I was sending sha256 but it didn't come through. Once I formatted the applicationUsername
to UUID format it started working. i.e.:
"00112233-4455-6677-8899-AABBCCDDEEFF"
(including the dashes)
You receive it back in an Appstore Server notification -> signedPayload -> data -> signedTransactionInfo -> appAccountToken
Decoding is also a bit challenging, and you'll find other answers here to help with that :)
Good luck!
Upvotes: 0