我已经在我的 android 应用程序中集成了 paypal,但它不工作。点击该按钮有一个按钮移动到贝宝,要求支付贝宝按钮的点击付款很少登录屏幕很少打开,当单击登录屏幕时,输入登录记录消息后打开登录记录消息显示登录失败请任何人看到这个我错了我的代码这是:-
private LinearLayout mainLayout = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
System.out.println("inside");
callPayment();
setContentView(mainLayout);
}
private void initializePayPal()
{
}
private void callPayment()
{
mainLayout= new LinearLayout(this);
PayPal mpaypal = PayPal.initWithAppID(this, "APP-80W284485P519543T", PayPal.ENV_SANDBOX);
LinearLayout layoutSimplePayment = new LinearLayout(this);
layoutSimplePayment.setLayoutParams(new LayoutParams(130,100));
layoutSimplePayment.setOrientation(LinearLayout.VERTICAL);
CheckoutButton getpaypalbutton =mpaypal.getPaymentButton(PayPal.BUTTON_152x33,this,PayPal.PAYMENT_TYPE_HARD_GOODS);
getpaypalbutton.setOnClickListener(this);
layoutSimplePayment.addView(getpaypalbutton);
mainLayout.addView(layoutSimplePayment);
}
@Override
public void onClick(View v)
{
PayPalPayment mpaypalpayment = new PayPalPayment();
mpaypalpayment.setAmount(0.2f);
mpaypalpayment.setCurrency("USD");
mpaypalpayment.setRecipient("xyz@gmail.com");
mpaypalpayment.setItemDescription("mother board");
mpaypalpayment.setMerchantName("BidNear");
Intent checkoutIntent = new Intent(this, PayPalActivity.class);
checkoutIntent.putExtra(PayPalActivity.EXTRA_PAYMENT_INFO, mpaypalpayment);
this.startActivityForResult(checkoutIntent, 1);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
switch(resultCode) {
case Activity.RESULT_OK:
//The payment succeeded
String transactionID = data.getStringExtra(PayPalActivity.EXTRA_TRANSACTION_ID);
//Tell the user their payment succeeded
//Tel break;
Toast.makeText(this,"Success"+transactionID,Toast.LENGTH_LONG).show();
case Activity.RESULT_CANCELED:
//The payment was canceled
//Tell the user their payment was canceled
break;
case PayPalActivity.RESULT_FAILURE:
//The payment failed -- we get the error from the EXTRA_ERROR_ID and EXTRA_ERROR_MESSAGE
String errorID = data.getStringExtra(PayPalActivity.EXTRA_ERROR_ID);
String errorMessage = data.getStringExtra(PayPalActivity.EXTRA_ERROR_MESSAGE);
Toast.makeText(this,"Failure"+"errorid"+errorID+"errormessage"+errorMessage,Toast.LENGTH_LONG).show();
//Tell the user their payment was failed.
}
}