private void SendAuthorizationToServer(PayPalAuthorization auth) { // TODO: Send Authorization to server Dbg.WriteLine("Here is your Authorization:\n\n{0}\n\nSend this to your server for further processing.", auth.ToJSONObject().ToString(4)); }
public void OnActivityResult(int requestCode, Result resultCode, global::Android.Content.Intent data) { if (requestCode == PayPalManager.REQUEST_CODE_PAYMENT) { if (resultCode == Result.Ok) { PaymentConfirmation confirm = (PaymentConfirmation)data.GetParcelableExtra(PaymentActivity.ExtraResultConfirmation); if (confirm != null) { try { OnSuccess?.Invoke(confirm.ToJSONObject().ToString()); OnSuccess = null; } catch (JSONException e) { OnError?.Invoke("an extremely unlikely failure occurred: " + e.Message); OnError = null; System.Diagnostics.Debug.WriteLine("an extremely unlikely failure occurred: " + e.Message); } } OnError?.Invoke("Unknown Error"); OnError = null; } else if (resultCode == Result.Canceled) { OnCancelled?.Invoke(); OnCancelled = null; System.Diagnostics.Debug.WriteLine("The user canceled."); } else if ((int)resultCode == PaymentActivity.ResultExtrasInvalid) { OnError?.Invoke("An invalid Payment or PayPalConfiguration was submitted. Please see the docs."); OnError = null; System.Diagnostics.Debug.WriteLine( "An invalid Payment or PayPalConfiguration was submitted. Please see the docs."); } } else if (requestCode == REQUEST_CODE_FUTURE_PAYMENT) { if (resultCode == Result.Ok) { PayPalAuthorization auth = (PayPalAuthorization)data.GetParcelableExtra(PayPalFuturePaymentActivity.ExtraResultAuthorization); if (auth != null) { try { OnSuccess?.Invoke(auth.ToJSONObject().ToString()); OnSuccess = null; } catch (JSONException e) { System.Diagnostics.Debug.WriteLine("an extremely unlikely failure occurred: " + e.Message); } } OnError?.Invoke("Unknown Error"); OnError = null; } else if (resultCode == Result.Canceled) { OnCancelled?.Invoke(); OnCancelled = null; System.Diagnostics.Debug.WriteLine("The user canceled."); } else if ((int)resultCode == PayPalFuturePaymentActivity.ResultExtrasInvalid) { OnError?.Invoke("Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs."); OnError = null; System.Diagnostics.Debug.WriteLine( "Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs."); } } else if (requestCode == REQUEST_CODE_PROFILE_SHARING) { if (resultCode == Result.Ok) { PayPalAuthorization auth = (PayPalAuthorization)data.GetParcelableExtra(PayPalProfileSharingActivity.ExtraResultAuthorization); if (auth != null) { try { OnSuccess?.Invoke(auth.ToJSONObject().ToString()); OnSuccess = null; } catch (JSONException e) { System.Diagnostics.Debug.WriteLine("an extremely unlikely failure occurred: " + e.Message); } } OnError?.Invoke("Unknown Error"); OnError = null; } else if (resultCode == Result.Canceled) { OnCancelled?.Invoke(); OnCancelled = null; System.Diagnostics.Debug.WriteLine("The user canceled."); } else if ((int)resultCode == PayPalFuturePaymentActivity.ResultExtrasInvalid) { OnError?.Invoke("Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs."); OnError = null; System.Diagnostics.Debug.WriteLine( "Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs."); } } else if (requestCode == REQUEST_CODE_CARD_SCAN) { if (data == null) { RetrieveCardCancelled?.Invoke(); RetrieveCardCancelled = null; System.Diagnostics.Debug.WriteLine("The user canceled."); return; } var card = (CreditCard)data.GetParcelableExtra(CardIOActivity.ExtraScanResult); if (card != null) { RetrieveCardSuccess?.Invoke(card, CardIOActivity.GetCapturedCardImage(data)); RetrieveCardSuccess = null; } else { RetrieveCardCancelled?.Invoke(); RetrieveCardCancelled = null; System.Diagnostics.Debug.WriteLine("The user canceled."); } } }
public void OnActivityResult(int requestCode, Result resultCode, Android.Content.Intent data) { if (requestCode == PayPalManager.REQUEST_CODE_PAYMENT) { if (resultCode == Result.Ok) { PaymentConfirmation confirm = (PaymentConfirmation)data.GetParcelableExtra(PaymentActivity.ExtraResultConfirmation); if (confirm != null) { try { System.Diagnostics.Debug.WriteLine(confirm.ToJSONObject().ToString(4)); System.Diagnostics.Debug.WriteLine(confirm.Payment.ToJSONObject().ToString(4)); /** * TODO: send 'confirm' (and possibly confirm.getPayment() to your server for verification * or consent completion. * See https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/ * for more details. * * For sample mobile backend interactions, see * https://github.com/paypal/rest-api-sdk-python/tree/master/samples/mobile_backend */ Toast.MakeText( Context.ApplicationContext, "PaymentConfirmation info received from PayPal", ToastLength.Short) .Show(); } catch (JSONException e) { System.Diagnostics.Debug.WriteLine("an extremely unlikely failure occurred: " + e.Message); } } } else if (resultCode == Result.Canceled) { System.Diagnostics.Debug.WriteLine("The user canceled."); } else if ((int)resultCode == PaymentActivity.ResultExtrasInvalid) { System.Diagnostics.Debug.WriteLine( "An invalid Payment or PayPalConfiguration was submitted. Please see the docs."); } } else if (requestCode == REQUEST_CODE_FUTURE_PAYMENT) { if (resultCode == Result.Ok) { PayPalAuthorization auth = (Xamarin.PayPal.Android.PayPalAuthorization)data.GetParcelableExtra(PayPalFuturePaymentActivity.ExtraResultAuthorization); if (auth != null) { try { System.Diagnostics.Debug.WriteLine(auth.ToJSONObject().ToString(4)); String authorization_code = auth.AuthorizationCode; System.Diagnostics.Debug.WriteLine(authorization_code); sendAuthorizationToServer(auth); Toast.MakeText( Context.ApplicationContext, "Future Payment code received from PayPal", ToastLength.Long) .Show(); } catch (JSONException e) { System.Diagnostics.Debug.WriteLine("an extremely unlikely failure occurred: " + e.Message); } } } else if (resultCode == Result.Ok) { System.Diagnostics.Debug.WriteLine("The user canceled."); } else if ((int)resultCode == PayPalFuturePaymentActivity.ResultExtrasInvalid) { System.Diagnostics.Debug.WriteLine( "Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs."); } } else if (requestCode == REQUEST_CODE_PROFILE_SHARING) { if (resultCode == Result.Ok) { PayPalAuthorization auth = (Xamarin.PayPal.Android.PayPalAuthorization)data.GetParcelableExtra(PayPalProfileSharingActivity.ExtraResultAuthorization); if (auth != null) { try { System.Diagnostics.Debug.WriteLine(auth.ToJSONObject().ToString(4)); String authorization_code = auth.AuthorizationCode; System.Diagnostics.Debug.WriteLine(authorization_code); sendAuthorizationToServer(auth); Toast.MakeText( Context.ApplicationContext, "Profile Sharing code received from PayPal", ToastLength.Short) .Show(); } catch (JSONException e) { System.Diagnostics.Debug.WriteLine("an extremely unlikely failure occurred: " + e.Message); } } } else if (resultCode == Result.Canceled) { System.Diagnostics.Debug.WriteLine("The user canceled."); } else if ((int)resultCode == PayPalFuturePaymentActivity.ResultExtrasInvalid) { System.Diagnostics.Debug.WriteLine( "Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs."); } } }
private void SendAuthorizationToServer(PayPalAuthorization auth) { // TODO: Send Authorization to server Dbg.WriteLine ("Here is your Authorization:\n\n{0}\n\nSend this to your server for further processing.", auth.ToJSONObject().ToString(4)); }