【发布时间】:2014-08-08 17:48:00
【问题描述】:
我是 android 新手,使用沙盒 id 完成了 paypal 集成,但是当我使用生产环境时,它会崩溃并出现,当我检查 logcat 时,我会收到如下错误
06-18 07:09:40.221: W/DefaultRequestDirector(3943): Authentication error: Unable to respond to any of these challenges: {}
06-18 07:09:40.591: W/paypal.sdk(3943): aa SN:35 PayPal Debug-ID: 7d7a3da2bf9aa [live, 2.2.2;release]
06-18 07:09:40.591: E/paypal.sdk(3943): request failure with http statusCode:401,exception:org.apache.http.client.HttpResponseException: Unauthorized
06-18 07:09:40.641: E/paypal.sdk(3943): request failed with server response:{"error":"invalid_client","error_description":"The client credentials are invalid"}
06-18 07:09:40.641: E/PayPalService(3943): invalid_client
但是我在这个应用程序中使用的客户端 ID 是正确的,但是我在使用 生产标识。谁能告诉我为什么会发生这种情况以及 paypal SDK 是如何工作的
支付宝代码
package com.coded.sandeep;
import java.math.BigDecimal;
import java.util.StringTokenizer;
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 com.paypal.android.sdk.payments.PayPalConfiguration;
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 PaypalActivity extends Activity {
private static final String CONFIG_ENVIRONMENT = PayPalConfiguration.ENVIRONMENT_PRODUCTION;
// note that these credentials will differ between live & sandbox environments.
private static final String CONFIG_CLIENT_ID = "AfZKkxA3Detdl4CgpOKoDMUVTSn3VHq633qkQp_F5hL520589653";
private static PayPalConfiguration config = new PayPalConfiguration()
.environment(CONFIG_ENVIRONMENT)
.clientId(CONFIG_CLIENT_ID);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.paypal_main);
Intent intent = new Intent(PaypalActivity.this, PayPalService.class);
intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config);
startService(intent);
}
public void onBuyPressed(View pressed) {
PayPalPayment thingToBuy = getThingToBuy(PayPalPayment.PAYMENT_INTENT_SALE);
Intent intent = new Intent(PaypalActivity.this, PaymentActivity.class);
intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy);
startActivityForResult(intent, 0);
}
private PayPalPayment getThingToBuy(String paymentIntent) {
Intent intent1 = getIntent();
String message = "people"
String amount = "1.26"
return new PayPalPayment(new BigDecimal(amount), "GBP", message,
paymentIntent);
}
@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));
} 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.");
}
}
@Override
public void onDestroy() {
stopService(new Intent(this, PayPalService.class));
super.onDestroy();
}
}
我正在为一个 Android 应用程序进行 Paypal 集成,但是当我使用 ENVIRONMENT_PRODUCTION 并添加我在 PayPal 中创建的实时 ID 时,我已在 Config_client_id 中添加,但添加后我的应用程序崩溃并弹出一个错误,如“商家 ID 无效”我该如何纠正这个我已经发布了我正在使用它的代码。
但是当我使用SANDBOX ENVIRONMENT 时,下面的代码工作正常,没有错误
【问题讨论】:
-
@Rutvij 你能告诉我客户 ID 有什么问题