Android 和 Paypal API 集成 [英] Android and Paypal API integration

查看:23
本文介绍了Android 和 Paypal API 集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试集成 Paypal API 以使我的应用程序捐赠基于.我有两个问题:

I'm trying to integrate the Paypal API to make my app donation based. I have two questions:

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

  1. I can see the button, I click it but it doesn't do anything! (the activity for checkoutIntent doesn't fire?)

您对基于捐赠的 Android 应用程序有何体验?我想通过这件事每月赚 250 美元左右,这可能吗?

What are your experiences with donation based android apps? I want to make about $250 a month of this thing, is that even possible?


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);
        }
    }

推荐答案

In 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);

这篇关于Android 和 Paypal API 集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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