android - 从 PayPal lib 获取支付配置

标签 android paypal xamarin.android parcelable

我在我的 monodroid 应用程序中使用 PayPal。我使用了本主题中共享的库:http://forums.xamarin.com/discussion/comment/15331/#Comment_15331

但是我在 OnActivityResult 方法中获取 PaymentConfirmation 对象时遇到问题。这是我的代码:

protected override void OnActivityResult (int requestCode, Result resultCode, Intent data)
    {
        if (resultCode == Result.Ok ) {
            var confirm =  data.GetParcelableExtra ("com.paypal.android.sdk.paymentConfirmation") ;

            PaymentConfirmation pc = (PaymentConfirmation)confirm;
        if (confirm != null) {
            try {
                //Log.Info ("paymentExample", confirm.ToJSONObject ().ToString (4));
                // TODO: send 'confirm' to your server for verification.
                // see https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/
                // for more details.\
            } catch (JSONException e) {
                Log.Error ("paymentExample", "an extremely unlikely failure occurred: ", e);
            }
        }
    }else if (resultCode == Result.Canceled ) {
        Log.Info ("paymentExample", "The user canceled.");
    }else {
        Log.Info ("paymentExample", "An invalid payment was submitted. Please see the docs.");
    }
}

在方法的第三行。编译器无法将确认转换为 PaymentConfirmation。我是否需要任何其他类或代码才能使用 data.GetParcelableExtra

最佳答案

如评论中所述,在这种情况下应使用 JavaCast。我认为当为类型生成的绑定(bind)不包含 GetType 方法时会发生这种情况。因此 .NET 不知道将其转换为什么。

所以你的台词:

PaymentConfirmation pc = (PaymentConfirmation)confirm;

将需要:

PaymentConfirmation pc = confirm.JavaCast<PaymentConfirmation>();

关于android - 从 PayPal lib 获取支付配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19333406/

相关文章:

android - 如何处理android服务中的保持连接

cocoa-touch - 新的 PayPal iOS SDK(测试版)- 无法连接到沙箱

paypal - 使用 PayPal 订阅按钮传递订阅 PayPal 的开始日期?

c# - 为什么 Xamarin Debugger 会跳过断点/代码?

android - 如何在 Xamarin 中获取 ActivityManager 的实例?

java.lang.NoClassDefFoundError : Failed resolution Failed resolution of: Lcom/google/android/gms/common/internal/zzab;

android - 类 'Application' 不是抽象的,没有实现抽象成员 public abstract fun registerWith(p0 : PluginRegistry):

android - FragmentPagerAdapter 和 FragmentStatePagerAdapter 有什么区别?

Paypal 数字商品,交易不显示

c# - 如何将不可见的ViewModel添加到MvvmCross中的导航堆栈中