PayPalAndroidTest.PayPalManager.OnActivityResult C# (CSharp) 메소드

OnActivityResult() 공개 메소드

public OnActivityResult ( int requestCode, Result resultCode, Android data ) : void
requestCode int
resultCode Result
data Android
리턴 void
		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.");
				}
			}
		}
	}

Usage Example

 protected override void OnActivityResult(int requestCode, Result resultCode, Android.Content.Intent data)
 {
     base.OnActivityResult(requestCode, resultCode, data);
     MainManager.OnActivityResult(requestCode, resultCode, data);
 }