付款创建错误 paypal sdk android
Posted
技术标签:
【中文标题】付款创建错误 paypal sdk android【英文标题】:payment creation error paypal sdk android 【发布时间】:2015-09-24 07:44:27 【问题描述】:我在 paypal sdk 集成中使用沙盒环境并收到以下错误有人遇到错误吗??
请求失败,http statusCode:422,exception:org.apache.http.client.HttpResponseException: Unprocessable Entity
paypal.sdk:请求失败,服务器响应:"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
这是我的代码
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();
【问题讨论】:
你为什么使用:if (requestCode == REQUEST_PAYPAL_PAYMENT)
?这不是必需的。
我也遇到同样的错误
大家好,你们找到解决方案了吗?
【参考方案1】:
请从贝宝获取您应用的客户端 ID。以下链接详细介绍了获取客户端 ID 的方法。然后将其替换为代码库以下行的 ID。
私有静态最终字符串 CONFIG_CLIENT_ID = "id";
【讨论】:
我在 -private static final String CONFIG_CLIENT_ID = "id" 中添加了秘密,但是还有其他 REST 凭据,例如与 REST 凭据关联的 SECRET ID 和 SANDBOX 电子邮件;想法?【参考方案2】:您可能已经解决了这个问题,但是您知道我之前遇到过相同的错误响应。我的问题是注册企业实体的货币和安卓应用货币设置不同。
【讨论】:
以上是关于付款创建错误 paypal sdk android的主要内容,如果未能解决你的问题,请参考以下文章
无需 PayPal 帐户或信用卡的 PayPal Android SDK 付款
PayPal Android SDK 实时模式中的身份验证请求失败
PayPal 信用卡交易错误:付款失败。系统错误。请稍后再试[关闭]
Paypal IPN,在哪里将我的订单 ID 放在 paypal sdk (android) 中以通过我的服务器验证付款?