Search Unity

C# to unityscript

Discussion in 'Scripting' started by psycocrusher, Nov 7, 2014.

  1. psycocrusher

    psycocrusher

    Joined:
    Jul 24, 2011
    Posts:
    71
    Can anyone help me with this, i am trying to implement canvas payments in facebook and i' am almost there.

    Code (CSharp):
    1. void PayCallback(FBResult result){
    2.  
    3.     if (result != null){
    4.  
    5.         var response = Json.Deserialize(result.Text) as Dictionary<string, object>;
    6.      
    7.         if(Convert.ToString(response["status"]) == "completed"){
    8.  
    9.             GiveItem();
    10.         }
    11.  
    12.         else{
    13.  
    14.         // Payment Failed
    15.         }
    16.     }
    17. }
    18.  
    19. void GiveItem(){
    20.  
    21.     // Implement your give item here
    22. }
    I' am having problems with this part:

    if(Convert.ToString(response["status"]) == "completed"){

    Thank you.
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It's exactly the same in Unityscript and C#.

    --Eric
     
  3. psycocrusher

    psycocrusher

    Joined:
    Jul 24, 2011
    Posts:
    71
    Hi Eric,

    It's giving me this error:

    Assets/Scripts/Plugs/Engagement/FaceBook/Payments.js(67,28): BCE0005: Unknown identifier: 'Convert'.
     
  4. psycocrusher

    psycocrusher

    Joined:
    Jul 24, 2011
    Posts:
    71
    This one worked, in case anyone wanted to know:

    if(response["status"].ToString() == "completed"){
    }
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Convert is in the System namespace.

    --Eric
     
  6. Abhijit-Mukherjee

    Abhijit-Mukherjee

    Joined:
    Jan 9, 2015
    Posts:
    193
    Hey I am doing the same thing . I just want to know is this issue resolved ??? ... Please let me know ..
     
  7. Abhijit-Mukherjee

    Abhijit-Mukherjee

    Joined:
    Jan 9, 2015
    Posts:
    193
    I am not able to understand what data is going to return from response . How can i debug it .. Do i need to need to deserialize it ??