【问题标题】:paypal android SDK integration with my app is not workingpaypal android SDK 与我的应用程序的集成不起作用
【发布时间】:2013-12-13 15:22:24
【问题描述】:

您好,我正在尝试将 Paypal AndroidSDK 与我的 android 应用程序集成。我遵循了贝宝集成文档并尝试按照说明进行集成。但是当我按下 购买 按钮屏幕导航到下面显示的贝宝屏幕。

但是当我在完成后按下购买按钮而不是 RESULT_OK 时,onActivityResult 回调将立即以 resultCode 作为 0(RESULT_CANCELED)带有PaymentConfirmation结果的付款流程。

以下是我的代码 sn-p。

  public void initPaymentService() {
    try {
        Intent intent = new Intent(this, PayPalService.class);

        intent.putExtra(PaymentActivity.EXTRA_PAYPAL_ENVIRONMENT, CONFIG_ENVIRONMENT);
        intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, CONFIG_CLIENT_ID);

    //  intent.putExtra(PaymentActivity.EXTRA_RECEIVER_EMAIL, CONFIG_RECEIVER_EMAIL);

        startService(intent);
    } catch (Exception e) {
    }
}

public void onBuyPressed(String amount) {
    PayPalPayment thingToBuy = new PayPalPayment(new BigDecimal("1.75"), "USD", "hipster jeans");

    Intent intent = new Intent(this, PaymentActivity.class);

    intent.putExtra(PaymentActivity.EXTRA_PAYPAL_ENVIRONMENT, CONFIG_ENVIRONMENT);
    intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, CONFIG_CLIENT_ID);
    intent.putExtra(PaymentActivity.EXTRA_RECEIVER_EMAIL, CONFIG_RECEIVER_EMAIL);

    // It's important to repeat the clientId here so that the SDK has it if Android restarts your 
    // app midway through the payment UI flow.
    intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, "AL7neK4uQk1xTc-YsELHpTAvdkjscvGNJDGHhashc8BLL8nkaTesRWkHOczSmqMkKT"); // **Clientid** from **developer.paypal.com**
    intent.putExtra(PaymentActivity.EXTRA_PAYER_ID, "testpaypal@gmail.com");

    intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy);

    startActivityForResult(intent, 0);
}

@Override
protected void onActivityResult (int requestCode, int resultCode, Intent data) {

     if (resultCode == Activity.RESULT_OK) {
        PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
        if (confirm != null) {
            try {
                Log.i("PaypalTestActivity", 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.e("PaypalTestActivity", "an extremely unlikely failure occurred: ", e);
            }
        }
    }
    else if (resultCode == Activity.RESULT_CANCELED) {
        Log.i("PaypalTestActivity", "The user canceled the Transaction.");
    }
    else if (resultCode == PaymentActivity.RESULT_PAYMENT_INVALID) {
        Log.i("PaypalTestActivity", "An invalid payment was submitted. Please see the docs.");
    }
}

initPaymentService() 方法调用来自 onCreate 如果我的 Activity。 我的按钮在一个片段中,并且活动是从 v4 支持库中的 FragmentActivity 继承的。

请让我知道我做错了什么,为什么会立即调用 onActivityResult 而不是 onCompletion 支付过程的确认信息。

如果您知道我的问题的解决方案,请告诉我。 任何帮助将不胜感激。

【问题讨论】:

  • 哥们找到解决方案了吗?

标签: android android-fragments paypal paypal-sandbox


【解决方案1】:

我终于找到了解决办法。

如果当前(我放置购买按钮的位置)活动的 android:launchMode="singleInstance",则

PayPal androidSDK 集成不起作用。当我将 launchMode 删除到该活动时,它工作正常。

【讨论】:

  • 非常感谢。我去找狼。关于我的环境,我改用“SingleTop”。
  • raj 如果您找到了解决方案,请帮助我,我还计划将 pay pal 帐户集成到 android 应用程序以进行在线业务。来自 India.where 的企业帐户可以整合详细信息并获取客户 ID 和机密信息。
  • @Raj 请检查here
猜你喜欢
  • 2020-11-12
  • 2016-05-05
  • 2013-08-18
  • 2013-09-09
  • 2016-12-06
  • 2014-01-29
  • 2019-10-04
  • 2016-03-23
  • 2018-08-13
相关资源
最近更新 更多