当我进入最后阶段并希望使用Android应用程序中的Android Paypal SDK向Paypal付款时,我将收到错误
"Merchant does not Accept payments of this type"
我正在使用实时身份凭证,但在最后阶段付款没有发生
我使用的代码如下
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 = "ASAHYxANvUGbBcXaLdhQWoDrO38JkUkYObXRaOF2FuOfa";
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 = "Freiends";
String amount = "1.29";
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();
}
}
如何纠正上述错误并使付款成功到商家ID . 我正在使用商家商家ID
使用卡付款后的Logcat:
06-20 01:10:22.402: W/DefaultRequestDirector(1295): Authentication error: Unable to respond to any of these challenges: {}
06-20 01:10:22.502: W/paypal.sdk(1295): U SN:14 PayPal Debug-ID: 406bd412549f4 [live, 2.2.2;release]
06-20 01:10:22.512: E/paypal.sdk(1295): request failure with http statusCode:401,exception:org.apache.http.client.HttpResponseException: Unauthorized
06-20 01:10:22.512: E/paypal.sdk(1295): request failed with server response:{"name":"UNAUTHORIZED_PAYMENT","message":"Unauthorized payment","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#UNAUTHORIZED_PAYMENT","debug_id":"406bd412549f4"}
06-20 01:10:22.732: I/Choreographer(1295): Skipped 61 frames! The application may be doing too much work on its main thread.
06-20 01:10:22.842: E/PayPalService(1295): UNAUTHORIZED_PAYMENT