Android和Paypal API集成

时间:2010-08-27 18:24:35

标签: android integration paypal

我正在尝试集成Paypal API以进行我的应用捐赠。我有两个问题:

  1. 我可以看到按钮,我点击它但它什么也没做! (checkoutIntent的活动不会触发?)

  2. 您对基于捐款的Android应用有什么经验?我想每个月赚250美元这个东西,甚至可能吗?


  3. public class Donate extends Activity implements OnClickListener {
    
         PayPal ppObj = PayPal.initWithAppID(this.getBaseContext(), "APP-80W284485P519543T", PayPal.ENV_SANDBOX);
    
         @Override
         public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.donate);
          LinearLayout mainLayout = (LinearLayout)findViewById(R.id.LinearLayout01);
          if (ppObj == null) ppObj = PayPal.initWithAppID(this.getBaseContext(), "APP-80W284485P519543T", PayPal.ENV_SANDBOX);
          CheckoutButton payPalButton = (CheckoutButton) ppObj.getPaymentButton(PayPal.BUTTON_294x45, this, PayPal.PAYMENT_TYPE_HARD_GOODS);
          payPalButton.setOnClickListener(this);
          mainLayout.addView(payPalButton);
         }
    
         public void onClick(View arg0) {
          PayPalPayment newPayment = new PayPalPayment();
          newPayment.setAmount((float) 1.00);
          newPayment.setCurrency("USD");
          newPayment.setRecipient("example@example.com");
          Intent checkoutIntent = new Intent(this, PayPalActivity.class);
          checkoutIntent.putExtra(PayPalActivity.EXTRA_PAYMENT_INFO, newPayment);
    
          this.startActivityForResult(checkoutIntent, 1);
         }
    
         @Override
            public void onBackPressed() {
          Intent menuIntent = new Intent(Donate.this, MTGTools.class);
             this.startActivity(menuIntent);
            }
        }
    

1 个答案:

答案 0 :(得分:0)

onclick

pp=PayPal.getInstance();

// Should do like this to start paypal activity
PayPalPayment newPayment = new PayPalPayment();
newPayment.setCurrencyType("USD");

Intent paypalIntent=pp.checkout(newPayment, test.this);
startActivityForResult(paypalIntent, 1);