iOS Question Store Question

tufanv

Expert
Licensed User
Longtime User
Hello,

Previously I was using app store receipt validation without a problem. I need the transactionReceipt column.

I am using the code below to get it :
B4X:
Dim no As NativeObject = Product
        Dim b() As Byte = no.NSDataToArray(no.GetField("transactionReceipt"))
        LogColor(b,Colors.Magenta)
        'Dim sos As String = convert.StringFromBytes(b,"UTF-8")

It was previosuly giving a very long receipt id which you could verify with appstore but now the log shows me :
<B4IArray: 0x16169090>

instead of this long receipt id.
Using store 1.1

What may be the problem ?
 

tufanv

Expert
Licensed User
Longtime User
What is the output of:
B4X:
Dim bc As ByteConverter 'iRandomAccessFile library
Log(bc.HexFromBytes(b))
it is stg like :
B4X:
7B0A09227369676E617475726522203D20224179536B357A685633547778483074594D3476517A6E6C2F62615550334339546C583363495470474D5462514C696637376E6A645876615A6E5A344C5473344C4C75713642363453596A65792B34485A57704C47484B6B4A32386E67732F765446594955447369654441485072507979346B7538364164424C4B6E74506C53596C32626B3972484D34547A396C68373742445164415274477A36674B6B2B38396456757532474168707A6E6C7872347359397371476B7053626A6E644E3077733565417872467850774262593742595A4C50715A5539305732306C4E336F6B334C43793058344250747A6654574253775745582B572B654868507A4C5844616532684D5653785233507A51376568334768356D494774654A427739784472375874706F4E3466463844654D693574476D7258305044516A794464525153363575696A63712B73595732754D3444594552564A726638524941414157414D4949466644434342475367417749424167494944757458682B6565435930774451594A4B6F5A496876634E4151454642514177675A5978437A414A42674E5642415954416C56544D524D77455159445651514B44417042634842735A53424A626D4D754D5377774B6759445651514C44434E42634842735A53425862334A735A4864705A475567524756325A5778766347567949464A6C6247463061573975637A46454D4549474131554541777737515842776247556756323979624752336157526C4945526C646D56736233426C636942535A57786864476C76626E4D675132567964476C6D61574E6864476C76626942426458526F62334A7064486B774868634E4D5455784D54457A4D4449784E5441355768634E4D6A4D774D6A41334D6A45304F445133576A4342695445334D44554741315545417777755457466A4945467763434254644739795A534268626D516761565231626D567A49464E3062334A6C49464A6C593256706348516755326C6E626D6C755A7A45734D436F47413155454377776A515842776247556756323979624752336157526C4945526C646D56736233426C636942535A57786864476C76626E4D78457A415242674E5642416F4D436B46776347786C49456C7559793478437A414A42674E5642415954416C56544D494942496A414E42676B71686B6947397730424151454641414F43415138414D49494243674B434151454170632B422F53576967567657682B306A326A4D636A75496A774B58454A73733978702F735367315668762B6B41746558796A6C556258312F736C51596E635173556E474F5A4875437A6F6D3653645949356253496363382F573059757873516475414F70574B49455069463431647533304934536A594E4D5779706F4E35504338723065784E4B684445705955717353342B3364483567566B44557477737753796F31496766645965465272364977784E68394B4267784856504D336B4C69796B6F6C3958365346537548416E4F4336704C75436C3250304B3550422F54357679734831504B6D50556872414A5170324474372B6D66372F776D7631573136736331464A4346614A7A454F517A493642417443676C375A6373614670615965514547676D4A6A6D344852427A7341706478585051333359373243335A6942376A37416650346F3751302F6F6D5659487634674E4A49774944415141426F344942317A434341644D77507759494B77594242515548415145454D7A41784D4338474343734741515546427A414268694E6F644852774F69387662324E7A63433568634842735A53356A6232307662324E7A6344417A4C5864335A4849774E44416442674E5648513445466751556B6153632F4D523274352B676976524E39593832586530724249557744415944565230544151482F424149774144416642674E5648534D4547444157674253494A78634A71625959594976733637723252316E46556C536A747A434341523447413155644941534341525577676745524D4949424451594B4B6F5A496876646A5A415547415443422F6A4342777759494B77594242515548416749776762594D67624E535A5778705957356A5A5342766269423061476C7A49474E6C636E52705A6D6C6A5958526C49474A35494746756553427759584A306553426863334E316257567A4947466A593256776447467559325567623259676447686C4948526F5A5734675958427762476C6A59574A735A53427A644746755A4746795A4342305A584A7463794268626D5167593239755A476C3061573975637942765A6942316332557349474E6C636E52705A6D6C6A5958526C4948427662476C6A65534268626D51675932567964476C6D61574E6864476C7662694277636D466A64476C6A5A53427A644746305A57316C626E527A4C6A4132426767724267454642516343415259716148523063446F764C33643364793568634842735A53356A623230765932567964476C6D61574E68644756686458526F62334A7064486B764D41344741315564447745422F775145417749486744415142676F71686B694739324E6B42677342424149464144414E42676B71686B6947397730424151554641414F4341514541446159623079343934317372423235436C6D7A54364978444D494A6634467A526A623639443730612F435753323479467734425A332B506931793446464B774E323761342F7677314C6E7A4C725264726A6E3866354865357357655674424E657068 (message truncated)...

but this is not what i need , it was with lower and upper chars and not a very very long thing like this , I have to use it for script validation.
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
This is an array of bytes. Based on this link: https://developer.apple.com/library...html#//apple_ref/doc/uid/TP40010573-CH104-SW1
You need to encode it with base64 string encoding (StringUtils.EncodeBase64).
It was too early to be happy , now i can validate the script at first purchase and get all the data as json with sending the transactionreceipt , but the problem is if i rrestoretranscations on another device using same itunes username i only get transaction identifier that is like : 1000000325282122 , and it is useless because i cant validate anything with this , I need the transactionreceipt , is it possible to make this return also with restoretransactions ( which means purchase completed ? )

at first purchase
B4X:
        Dim no As NativeObject = Product
        Dim b() As Byte = no.NSDataToArray(no.GetField("transactionReceipt"))
        LogColor(b,Colors.Magenta)
       
        Log(stringu.EncodeBase64(b))

this returns the receiipt but if i restore on another device this code doesnt work it triggers an error :

object not initialized for this line:
Dim b() As Byte = no.NSDataToArray(no.GetField("transactionReceipt"))

it only returns Product: premiumbtc, date=14:49:16, Transaction identifier=1000000325282122

As we are not required to hold any data for auto renewing subscriptions according to apple document and it is only enough to call restoretransactions to make users restore on another device , we should be getting some more information on purchasecompleted sub i think . Am I Wrong ?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

tufanv

Expert
Licensed User
Longtime User
to be more clear, this is the line that needs to be restored for auto renewing, and this is the receipt we are thinking about implementing right ?:
B4X:
{"auto_renew_status":1,"status":0,"auto_renew_product_id":"premiumbtc","receipt":{"original_purchase_date_pst":"2017-08-17 04:49:16 America\/Los_Angeles","unique_identifier":"c5ba6811d92f969b009538361f992aba4c4a1051","original_transaction_id":"1000000325282122","expires_date":"1503053968876","transaction_id":"1000000325639342","quantity":"1","product_id":"premiumbtc","item_id":"1272649539","bid":"com.ctmobilesoft.bmi674342","unique_vendor_identifier":"5CD72583-5174-4D81-A81F-F15DBBB27BB0","web_order_line_item_id":"1000000035974446","bvrs":"2.4.0","expires_date_formatted":"2017-08-18 10:59:28 Etc\/GMT","purchase_date":"2017-08-18 10:54:28 Etc\/GMT","purchase_date_ms":"1503053668876","expires_date_formatted_pst":"2017-08-18 03:59:28 America\/Los_Angeles","purchase_date_pst":"2017-08-18 03:54:28 America\/Los_Angeles","original_purchase_date":"2017-08-17 11:49:16 Etc\/GMT","original_purchase_date_ms":"1502970556000"},"latest_receipt_info":{"original_purchase_date_pst":"2017-08-17 04:49:16 America\/Los_Angeles","unique_identifier":"c5ba6811d92f969b009538361f992aba4c4a1051","original_transaction_id":"1000000325282122","expires_date":"1503053968000","transaction_id":"1000000325639342","quantity":"1","product_id":"premiumbtc","item_id":"1272649539","bid":"com.ctmobilesoft.bmi674342","unique_vendor_identifier":"5CD72583-5174-4D81-A81F-F15DBBB27BB0","web_order_line_item_id":"1000000035974446","bvrs":"2.4.0","expires_date_formatted":"2017-08-18 10:59:28 Etc\/GMT","purchase_date":"2017-08-18 10:54:28 Etc\/GMT","purchase_date_ms":"1503053668000","expires_date_formatted_pst":"2017-08-18 03:59:28 America\/Los_Angeles","purchase_date_pst":"2017-08-18 03:54:28 America\/Los_Angeles","original_purchase_date":"2017-08-17 11:49:16 Etc\/GMT","original_purchase_date_ms":"1502970556000"},"latest_receipt":"ewoJInNpZ25hdHVyZSIgPSAiQXlrUnhKVUVBREQ3dzgrei9KTkUvWWQvT29Qckp5S0ZBMmh4bi9pemNJUGJ3MThjUXFI...............

The value comes directly from the native SDK so it is an internal change.

Relevant discussion: https://stackoverflow.com/questions...ransactionreceipt-nil-for-restore-on/18857214

iStore library currently returns the originalTransaction when purchase is restored. I will update it next week to copy the receipt if it is empty.
 
Upvote 0
Top