Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Need help? How can i get retry billing field? or how can i get just receipt json data?

Discussion in 'Unity IAP' started by luong_pham, Jul 23, 2019.

  1. luong_pham

    luong_pham

    Joined:
    Jan 2, 2019
    Posts:
    16
    Hi everyone,

    I have some problem with Unity IAP. My goal is to get Subscription Retry Flag (iOS), or is_in_billing_retry_period, but it seems like Unity IAP missing many field in receipt.

    How can i get that field? or how can i get full json data for the receipt?

    the farthest i can go is to get receipt data like this:
    byte[] receiptData = System.Convert.FromBase64String(builder.Configure<IAppleConfiguration>().appReceipt);

    but still i dont know how to parse to json? do anyone have any ideas?
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    You should be able to read JSON yourself and should be in English clear text, can you visually inspect the string to find the field you are looking for? Can you post the JSON string here?
     
  3. luong_pham

    luong_pham

    Joined:
    Jan 2, 2019
    Posts:
    16
    Sorry to ask this stupid question but can you be more specific which json i could read? or with data/struct/class

    Because when i get a receipt it's just a string encoded string.
    If i try to get this receipt builder.Configure<IAppleConfiguration>().appReceipt -> it's encoded, too

    Edit: just ignore what i say here, i just want to know if the user is in billing retry period, can you just show me an example of that. You can check Apple ReceiptFields to know more

    How can i get info from field Subscription Expiration Intent or Subscription Retry Flag


    p/s: i'm talking about iOS, not android
     
    Last edited: Jul 24, 2019
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  5. luong_pham

    luong_pham

    Joined:
    Jan 2, 2019
    Posts:
    16
    Thanks for your reply.

    I'm trying to but i cannot print out to normal string, all the character is unreadable

    Code (CSharp):
    1. byte[] receiptData = System.Convert.FromBase64String(receiptCode);
    2.         var ascii = System.Text.ASCIIEncoding.ASCII.GetString(receiptData);
    3.         var utf = System.Text.UTF8Encoding.UTF8.GetString(receiptData);
    4.         var unicode = System.Text.UnicodeEncoding.Unicode.GetString(receiptData);
    5.         Debug.Log("xxx ascii: " + ascii);
    6.         Debug.Log("xxx utf8: " + utf);
    7.        /Debug.Log("xxx unicode: " + unicode);
    Afaik, the byte convert from base64 is encode with another code (ASN.1) but i'm not really sure about that. Unity IAP Api can parse it means we can decode this data, but there is no public api to do that? can you check with api team for this matter?

    Thanks in advance!
     
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    We are looking into this, and should be able to provide you with sample code within a few days.