android - 支付宝支付安卓

标签 android paypal

我正在尝试将 paypal 与我的 android 应用程序集成,但出现错误 paypal android error_description":"Invalid client_id" 因为它清楚地表明 Client_id 无效但我看不到任何错误我刚刚从这个页面复制。 ![在此处输入图片描述][1]

代码是这样的

public class MainActivity extends Activity implements OnClickListener{

private Button btnPay;
//set the environment for production/sandbox/no netowrk
private static final String CONFIG_ENVIRONMENT = PayPalConfiguration.ENVIRONMENT_PRODUCTION;

private static final String CONFIG_CLIENT_ID = "nsdkjansdknaskd7415150U";

private static final int REQUEST_PAYPAL_PAYMENT = 1;

private static PayPalConfiguration config = new PayPalConfiguration()
        .environment(CONFIG_ENVIRONMENT)
        .clientId(CONFIG_CLIENT_ID)
        // The following are only used in PayPalFuturePaymentActivity.
        .merchantName("Android Hub 4 You")
        .merchantPrivacyPolicyUri(Uri.parse("https://www.example.com/privacy"))
        .merchantUserAgreementUri(Uri.parse("https://www.example.com/legal"));



@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    btnPay=(Button)findViewById(R.id.button1);
    btnPay.setOnClickListener(this);

    /**
     * call pay pal services
     */

    Intent intent = new Intent(this, PayPalService.class);
    intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config);
    startService(intent);
}



@Override
public void onClick(View v) {
    // TODO Auto-generated method stub
    switch(v.getId()){
    case R.id.button1 :
         PayPalPayment thingToBuy = new PayPalPayment(new BigDecimal(1),"USD", "androidhub4you.com",
                    PayPalPayment.PAYMENT_INTENT_SALE);

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

                intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy);

                startActivityForResult(intent, REQUEST_PAYPAL_PAYMENT); 
        break;
    }

}

  @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == REQUEST_PAYPAL_PAYMENT) {
            if (resultCode == Activity.RESULT_OK) {
                PaymentConfirmation confirm = data
                        .getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
                if (confirm != null) {
                    try {
                        System.out.println("Responseeee"+confirm);
                        Log.i("paymentExample", confirm.toJSONObject().toString());


                        JSONObject jsonObj=new JSONObject(confirm.toJSONObject().toString());

                        String paymentId=jsonObj.getJSONObject("response").getString("id");
                        System.out.println("payment id:-=="+paymentId);
                        Toast.makeText(getApplicationContext(), paymentId, 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.");
            } else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) {
                Log.i("paymentExample", "An invalid Payment was submitted. Please see the docs.");
            }
        } 


  }




  }

最佳答案

您没有使用正确的凭据。您当前使用的“App ID”用于 PayPal 自适应支付 API 和旧版 MPL。对于 Android mSDK,您需要按照说明进行操作 here创建 REST API 应用程序。这将向您展示如何在开发人员门户上创建应用程序,以便为您提供客户端 ID 和密码。此客户端 ID 是您需要在上面的 Android mSDK 代码中使用的。

关于android - 支付宝支付安卓,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29841098/

相关文章:

java - 在 Android 中将 JSONObject 上传到 Iris CouchDb

android - 应用程序名称未显示在 Android Studio 中

Android:从导航列表中获取项目actionbarsherlock

api - Paypal 隐式付款,无需在 paypal api c#asp.net 中重定向到 Paypal

php - Paypal SetExpressCheckout 是否需要 DoExpressCheckout?

php - Paypal 与 php 中的 socialEngine4.0 集成

paypal - 购物车保留产品

android - 在 GLSurfaceView 之上绘制 Android UI

安卓 - javax.crypto.AEADBadTagException

licensing - PHP 中的 RSA_sign 或 DSA_sign!