Paypal on unity don't work in iOS
BaltaKid
Contributor
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on
Nov-28-2018
10:49 AM
Hello,
I'm trying to make paypal work with unity 3d. And this code work in Android and MacOS but when i try in iOS for some reasons appears error 400
public string clientID; public string secret; //[HideInInspector] public PayPalGetAccessTokenJsonResponse API_SuccessResponse; //[HideInInspector] public PayPalErrorJsonResponse API_ErrorResponse; // Use this for initialization void Start () { Debug.Log("calling coroutine"); StartCoroutine (MakePayAPIcall ()); } void handleSuccessResponse(string responseText) { //attempt to parse reponse text API_SuccessResponse = JsonUtility.FromJson<PayPalGetAccessTokenJsonResponse>(responseText); Debug.Log ("parsed response"); } void handleErrorResponse(string responseText, string errorText) { //attempt to parse error response API_ErrorResponse = JsonUtility.FromJson<PayPalErrorJsonResponse>(responseText); //if no responseText and only error text if (API_ErrorResponse == null) { API_ErrorResponse = new PayPalErrorJsonResponse (); API_ErrorResponse.message = errorText; } Debug.Log ("parsed response"); } IEnumerator MakePayAPIcall() { Dictionary<string,string> headers = new Dictionary<string, string >(); headers.Add("Accept","application/json"); headers.Add("Accept-Language","en_US"); headers.Add("Authorization","Basic " + System.Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes( clientID + ":" + secret))); WWWForm postData = new WWWForm(); postData.AddField("grant_type", "client_credentials"); string endpointURL = StoreProperties.INSTANCE.isUsingSandbox () ? "https://api.sandbox.paypal.com/v1/oauth2/token" : "https://api.paypal.com/v1/oauth2/token"; WWW www = new WWW(endpointURL, postData.data, headers); yield return www; //if ok response if (www.error == null) { Debug.Log("WWW Ok! Full Text: " + www.text); handleSuccessResponse (www.text); } else { Debug.Log("WWW Error: "+ www.error); handleErrorResponse (www.text, www.error); } }
Labels:
Login to Me Too
- Labels:
-
REST SDK
1 REPLY 1
esportslabs
Contributor
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May-07-2019
07:49 AM
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
Related Content
- Platform Marketplace integration approval in Sandbox Environment
- rest api > list plan > does query parameter plan_ids exist? in REST APIs
- Marketplace Solution in UAE in PayPal Payments Standard
- paypal recurring payments and ipn management in REST APIs
- Profile issue - Profile keep hanging, unable to access Developer side, unable to update/change API in REST APIs