1

Android アプリケーションにペイパルを統合しましたが、機能していません。そのボタンをクリックするとボタンがあり、ペイパルに移動して支払いを要求します ペイパルのオンクリックをクリックすることはめったにありません ログイン画面を開くことはめったにありません 入力ログインレコードメッセージが表示された後にログイン画面が開く ログイン失敗が表示されます 誰でも私が間違っている私のコードを見てくださいこれは:-

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.
    }
}
4

0 に答える 0