1

在此处输入图像描述

这是我的主要活动课程:

 package your.in.paypal;

 import java.math.BigDecimal;
 import android.app.Activity;
 import android.content.Intent;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
 import android.view.ViewGroup.LayoutParams;
 import android.widget.LinearLayout;

 import com.paypal.android.MEP.CheckoutButton;
 import com.paypal.android.MEP.PayPal;
 import com.paypal.android.MEP.PayPalActivity;
 import com.paypal.android.MEP.PayPalPayment;

 public class SimplePayPalIntegration extends Activity implements OnClickListener {
 private ViewGroup content;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    invokeSimplePayment();
}

private void invokeSimplePayment(){

    try{


        PayPal pp = PayPal.getInstance();

        if(pp==null)

        pp = PayPal.initWithAppID(this, "APP-80W284485P519543T", PayPal.ENV_SANDBOX);

        LinearLayout layoutSimplePayment = new LinearLayout(this);

        layoutSimplePayment.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));

        layoutSimplePayment.setOrientation(LinearLayout.VERTICAL);

        CheckoutButton launchSimplePayment = pp.getCheckoutButton(this, PayPal.BUTTON_194x37, CheckoutButton.TEXT_PAY);

        launchSimplePayment.setOnClickListener(this);

        layoutSimplePayment.addView(launchSimplePayment);

        setContentView(layoutSimplePayment);


    }catch(Exception e)
    {
        e.printStackTrace();
    }
}

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

          case Activity.RESULT_OK:

              Log.d("", "RESULT_OK");
              break;

           case Activity.RESULT_CANCELED:
               Log.d("", "RESULT_CANCELED");
               break;

           case PayPalActivity.RESULT_FAILURE:
               Log.d("", "RESULT_FAILURE");
               break;
      }
}

    @Override
    public void onClick(View v) {

        PayPalPayment payment = new PayPalPayment();

        payment.setSubtotal(new BigDecimal("8.25"));

        payment.setCurrencyType("USD");

        payment.setRecipient("mymail@gmail.com");

        payment.setPaymentType(PayPal.PAYMENT_TYPE_GOODS);

        Intent checkoutIntent = PayPal.getInstance().checkout(payment, this);

        startActivityForResult(checkoutIntent, 1);

        Log.d("", "clicked");

    }
}

这是我的AndroidManifest.xml

 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="your.in.paypal"
 android:versionCode="1"
 android:versionName="1.0" >

<uses-sdk android:minSdkVersion="8" />

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>


<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".SimplePayPalIntegration"

     android:configChanges="keyboardHidden|orientation">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
      <activity android:name="com.paypal.android.MEP.PayPalActivity" 
                android:theme="@android:style/Theme.Translucent.NoTitleBar"
                android:configChanges="keyboardHidden|orientation"/>
</application>

我已经将 The 添加PayPal_MPL.jar到项目中。当我运行项目时,我成功地转到了 paypal 按钮,当我单击该按钮时,我得到了登录页面,但是当我输入沙箱登录 ID 和密码时,我得到了错误Login failed. Please try again.,为什么?请告诉我我做错了什么。

4

2 回答 2

3

问题是您正试图在沙盒模式下进行真正的支付。PayPal 仅允许您在他们的实时服务器上进行实际付款(在他们有机会审查和批准您的应用程序之后)。当您准备好尝试付款时,在 X.com 上注册并提交您的应用程序。或者,您可以通过贝宝网站设置沙盒帐户。

于 2012-08-16T06:48:26.913 回答
0

您需要访问https://www.sandbox.paypal.com并创建一个帐户,以便您可以在沙盒模式下使用它。我收到了完全相同的消息,“登录失败。请重试。” 注册我的沙盒账户后,我可以成功测试,你不必担心从你的真实账户中花钱。

于 2017-03-03T22:13:55.363 回答