付款创建错误PayPal SDK Android [英] payment creation error paypal sdk android

查看:346
本文介绍了付款创建错误PayPal SDK Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在paypal sdk集成中使用沙盒环境,任何人遇到此错误都会收到以下错误??

i am using sandbox environment in paypal sdk integration and getting the following error anyone came across the error??

请求失败,出现http statusCode:422,exception:org.apache.http.client.HttpResponseException:无法处理的实体

request failure with http statusCode:422,exception:org.apache.http.client.HttpResponseException: Unprocessable Entity

paypal.sdk:请求失败,服务器响应:{名称":"PAYMENT_CREATION_ERROR","debug_id":"968064d634e8e",消息":未创建结帐会话","information_link":" https://api-m.sandbox.paypal.com/docs/api/#PAYMENT_CREATION_ERROR }

paypal.sdk﹕ request failed with server response:{"name":"PAYMENT_CREATION_ERROR","debug_id":"968064d634e8e","message":"checkout-session not created","information_link":"https://api-m.sandbox.paypal.com/docs/api/#PAYMENT_CREATION_ERROR"}

/paypal.sdk:PAYMENT_CREATION_ERROR

/paypal.sdk﹕ PAYMENT_CREATION_ERROR

这是我的代码

private static final int REQUEST_PAYPAL_PAYMENT = 1;
private static final int REQUEST_CODE_FUTURE_PAYMENT = 2;
private static final String CONFIG_CLIENT_ID = "id";


private static PayPalConfiguration config = new PayPalConfiguration()
        .environment(PayPalConfiguration.ENVIRONMENT_SANDBOX)
        .acceptCreditCards(true)
        .clientId(CONFIG_CLIENT_ID);




@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_read);
    Intent intent = new Intent(Read.this, PayPalService.class);
    intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION,config);
  b1 = (Button) findViewById(R.id.button);
    startService(intent);
 b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
    PayPalPayment thingToBuy = new PayPalPayment(new BigDecimal(1),"USD", "androidhub4you.com",
            PayPalPayment.PAYMENT_INTENT_SALE);

    Intent intent = new Intent(Read.this, PaymentActivity.class);
    intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config);

    intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy);


    startActivityForResult(intent, REQUEST_PAYPAL_PAYMENT);
  }
 });

  }


@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_read, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}


@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.");
        }
    }



}
@Override
public void onDestroy() {
    stopService(new Intent(Read.this, PayPalService.class));
    super.onDestroy();


}

推荐答案

您可能已经解决了此问题,但是您知道我之前遇到了相同的错误响应.我的问题是,注册业务实体的货币和android应用程序的货币设置不同.

You might have already solved this, but just so you know I encountered the same error response before. My issue was that the the currency for the registered business entity and the android app currency settings was different.

这篇关于付款创建错误PayPal SDK Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆