在 android 的 paypal 沙盒帐户中汇款时出错

Posted

技术标签:

【中文标题】在 android 的 paypal 沙盒帐户中汇款时出错【英文标题】:Error in sending money in paypal sandbox account in android 【发布时间】:2013-11-01 09:05:33 【问题描述】:

Following this paypal android examplehere 在沙盒中创建了企业帐户和个人帐户,尝试进行交易,但未从个人帐户中检测到金额,也未添加到企业帐户中。这是我的代码。

@Override
protected void onCreate(Bundle savedInstanceState) 
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    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);


public void onBuyPressed(View pressed) 
    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, "credential-from-developer.paypal.com");
    intent.putExtra(PaymentActivity.EXTRA_PAYER_ID, "your-customer-id-in-your-system");
    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("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.e("paymentExample", "an extremely unlikely failure occurred: ", e);
            
        
    
    else if (resultCode == Activity.RESULT_CANCELED) 
        Log.i("paymentExample", "The user canceled.");
    
    else if (resultCode == PaymentActivity.RESULT_PAYMENT_INVALID) 
        Log.i("paymentExample", "An invalid payment was submitted. Please see the docs.");
    

日志:

  10-23 01:06:05.979: I/paymentExample(10959): 
10-23 01:06:05.979: I/paymentExample(10959):     "payment": 
10-23 01:06:05.979: I/paymentExample(10959):         "short_description": "hipster jeans",
10-23 01:06:05.979: I/paymentExample(10959):         "amount": "1.75",
10-23 01:06:05.979: I/paymentExample(10959):         "currency_code": "USD"
10-23 01:06:05.979: I/paymentExample(10959):     ,
10-23 01:06:05.979: I/paymentExample(10959):     "client": 
10-23 01:06:05.979: I/paymentExample(10959):         "platform": "Android",
10-23 01:06:05.979: I/paymentExample(10959):         "paypal_sdk_version": "1.2.1",
10-23 01:06:05.979: I/paymentExample(10959):         "product_name": "PayPal Android SDK; ",
10-23 01:06:05.979: I/paymentExample(10959):         "environment": "mock"
10-23 01:06:05.979: I/paymentExample(10959):     ,
10-23 01:06:05.979: I/paymentExample(10959):     "proof_of_payment": 
10-23 01:06:05.979: I/paymentExample(10959):         "rest_api": 
10-23 01:06:05.979: I/paymentExample(10959):             "state": "approved",
10-23 01:06:05.979: I/paymentExample(10959):             "payment_id": "API-PAYMENT-ID-1843"
10-23 01:06:05.979: I/paymentExample(10959):         
10-23 01:06:05.979: I/paymentExample(10959):     
10-23 01:06:05.979: I/paymentExample(10959): 

它说国家批准但在沙盒控制台中没有扣除金额并且没有添加商业帐户金额,没有得到什么问题是帮助我。

【问题讨论】:

您好,如何在 paypal 中启用卡支付。 【参考方案1】:

您的EXTRA_PAYPAL_ENVIRONMENT 设置为ENVIRONMENT_NO_NETWORK。如果您想使用您的测试帐户,请尝试使用ENVIRONMENT_SANDBOX 或使用真钱使用ENVIRONMENT_PRODUCTION(请记住使用正确的 ID 和邮件)。

顺便说一句,我认为你应该在帖子中隐藏你的 CONFIG_CLIENT_IDCONFIG_RECEIVER_EMAIL,因为这是你的私人信息。

【讨论】:

如果我将 NO_NETWORK 更改为 SANDBOX,那么它会显示与贝宝服务器的连接错误,并且我所提及的凭据无效,它们将无法工作。 您是否在清单中添加了 INTERNET 权限?您是否使用沙盒帐户凭据?要查看您的沙盒帐户,请转到 PayPal 开发者页面 -> 应用程序 -> 沙盒帐户。 【参考方案2】:

在你的onBuyPressed方法中,你已经使用了

intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, CONFIG_CLIENT_ID);

然后再以同样的方法,你是这样使用的:

intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, "credential-from-developer.paypal.com");

用实际的CLIENT_ID 替换它。它会解决你的问题。

【讨论】:

将客户端 ID 替换为来自 paypal 开发者网站的客户端 ID,然后检查支付类型的响应:sale 并将 No_NETWORK 更改为 SANDBOX

以上是关于在 android 的 paypal 沙盒帐户中汇款时出错的主要内容,如果未能解决你的问题,请参考以下文章

无法登录 PayPal 沙盒帐户

Paypal 沙盒订阅按钮 - 测试没有 Paypal 帐户的买家?

如何在 PayPal 沙盒网站上测试“没有 PayPal 帐户的结帐”?

无法将PayPal沙盒帐户链接到第三方权限

如何在paypal买家沙箱帐户中创建eCheck帐户类型?而且,如何使用ebay沙盒订单进行测试?

付款错误:PayPal 错误:此商家沙盒帐户已禁用 DPRP