通过开发者用户名密码无法登录paypal
Posted
技术标签:
【中文标题】通过开发者用户名密码无法登录paypal【英文标题】:Unable to login in paypal through developers username password 【发布时间】:2014-05-16 14:21:16 【问题描述】:我在 Paypal 中注册了帐户,并下载了 Paypal sdk。我已经提出了申请,并从网站上获得了客户 ID。现在我在集成到我的应用程序后无法通过开发者 ID 登录 Paypal 网关。
请帮我看看哪里出错了
我的代码
try
Double amount=Double.parseDouble(amnt.getText().toString());
if(amount>=62 && amount!=null && amount!=0.0)
amount=amount/62;
PayPalPayment thingToBuy = new PayPalPayment(new BigDecimal(""+amount), "USD", "Cab Rent");
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, "AXJjcRB6yUtJghGBgdDHmOgkL8a9Jnd0RVARU9XPGqZ_lSstEhDSkh7D9AL2");
intent.putExtra(PaymentActivity.EXTRA_PAYER_ID, "");//from ui we have to design
intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy);
startActivityForResult(intent, 0);
else
Toast.makeText(getApplicationContext(), " An invalid payment was submitted. 1$ minimum", Toast.LENGTH_LONG).show();
catch(Exception e)
Log.d("Paypal_Activity", ""+e); //BLUE
关于活动结果
@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.");
【问题讨论】:
您使用的似乎不是当前版本的 SDK。我建议您这样做(对您的集成稍作更改)。 【参考方案1】:嘿,这是我的工作代码,具有我的应用程序的给定凭据...
BuyActivity.java
package com.example.paypalintegration;
import java.math.BigDecimal;
import org.json.JSONException;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import com.paypal.android.sdk.payments.PayPalPayment;
import com.paypal.android.sdk.payments.PayPalService;
import com.paypal.android.sdk.payments.PaymentActivity;
import com.paypal.android.sdk.payments.PaymentConfirmation;
public class BuyActivity extends Activity
private static final String CONFIG_ENVIRONMENT = PaymentActivity.ENVIRONMENT_NO_NETWORK;
private static final String CONFIG_CLIENT_ID = "AFcWxV21C7fd0v3bYYYRCps-s-rl31AR.aAFjBsPf7PzEUNdhcCM3xDQBN";
private static final String CONFIG_RECEIVER_EMAIL = "claudia.burnett-facilitator@pushnd.com";
private EditText amnt;
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_buy);
amnt=(EditText)findViewById(R.id.editText1);
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)
Double amount=Double.parseDouble(amnt.getText().toString());
if(amount>=62 && amount!=null && amount!=0.0)
amount=amount/62;
PayPalPayment thingToBuy = new PayPalPayment(new BigDecimal(String.valueOf(amount)), "NOK","Cab Rent");
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);
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.
Toast.makeText(this,confirm.toJSONObject().toString(4),Toast.LENGTH_LONG).show();
catch (JSONException e)
Log.e("paymentExample", "an extremely unlikely failure occurred: ", e);
else if (resultCode == Activity.RESULT_CANCELED)
Log.i("paymentExample", "The user canceled.");
Toast.makeText(this,"The user canceled.",Toast.LENGTH_LONG).show();
else if (resultCode == PaymentActivity.RESULT_PAYMENT_INVALID)
Log.i("paymentExample", "An invalid payment was submitted. Please see the docs.");
Toast.makeText(this,"An invalid payment was submitted. Please see the docs.",Toast.LENGTH_LONG).show();
@Override
public void onDestroy()
stopService(new Intent(this, PayPalService.class));
super.onDestroy();
XML 文件 activity_buy.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_
android:layout_ >
<Button
android:id="@+id/buyItBtn"
android:layout_
android:layout_
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:onClick="onBuyPressed"
android:text="Buy this product" />
<EditText
android:id="@+id/editText1"
android:layout_
android:layout_
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="147dp"
android:ems="10"
android:inputType="number" >
<requestFocus />
</EditText>
</RelativeLayout>
and the Manifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.paypalintegration"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".BuyActivity"
android:label="@string/title_activity_pay_pal_integration" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name="com.paypal.android.sdk.payments.PayPalService"
android:exported="false" />
<activity android:name="com.paypal.android.sdk.payments.PaymentActivity" />
<activity android:name="com.paypal.android.sdk.payments.LoginActivity" />
<activity android:name="com.paypal.android.sdk.payments.PaymentMethodActivity" />
<activity android:name="com.paypal.android.sdk.payments.PaymentConfirmActivity" />
<activity
android:name="io.card.payment.CardIOActivity"
android:configChanges="keyboardHidden|orientation" />
<activity android:name="io.card.payment.DataEntryActivity" />
</application>
</manifest>
你可以用 logine is 测试我的代码
personal_sandbox@pushnd.com
密码..
个人沙盒
完整的代码在这里
https://www.dropbox.com/s/f88rean6mpfaibs/PayPalIntegration.zip?m=
【讨论】:
【参考方案2】:从此页面:PayPal MPL for android returns error ID 589023
PayPal 错误 589023 尤其具有以下含义:
If a fractional amount is rounded due to currency conversion, funds could be lost
也许您没有四舍五入到货币的最小单位或美分。
例如:
(amount* fee_multiplier).round(2)
更新: Paypal 不接受 1.1 美元和 1.111 美元等价值。我们需要确保在 thingToBuy 中收到的值已经四舍五入到最接近的美分和货币的最低单位。
另一个例子:
DecimalFormat df = new DecimalFormat("#.00");
df.format(amount);
结果:
amount: 1.3333333 (double) -> df.format: 1.33 (new DecimalFormat)
像印尼盾 (IDR) 这样的货币没有小数点,因为它们的最小单位是 25 印尼盾
【讨论】:
早些时候(8 个月前)我使用相同的代码,交易成功完成 您是否尝试过在发送到贝宝之前显示真实金额? Paypal 不接受 12.909 美元(例如)这样的价格。 沙盒模式测试的 CVV 是多少? @ManishYadav 是的。 1 挪威克朗 / 1 挪威克朗兑美元 = 0.17 美元。 贝宝不接受 1.1 美元和 1.111 美元之类的值。我们需要确保在 thingToBuy 中收到的值已经四舍五入到最接近的美分和货币的最低单位。示例:DecimalFormat df = new DecimalFormat("#.00");
df.format(amount);
amount: 1.3333333 (double) -> df.format: 1.33
。像印尼盾 (IDR) 这样的货币没有小数点,因为它们的最小单位是 25 印尼盾以上是关于通过开发者用户名密码无法登录paypal的主要内容,如果未能解决你的问题,请参考以下文章