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

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

问题描述

我试图整合贝宝API 来使我的应用程序捐赠为主。我有两个问题:

  1. 我可以看到按钮,我点击它,但它不会做任何事情! (对于checkoutIntent活动不火?)

  2. 你有什么用捐款为主Android应用经验?我想打250 $一个月的这件事情是,即使可能吗?


 公共类捐赠扩展活动实现OnClickListener {

     贝ppObj = PayPal.initWithAppID(this.getBaseContext(),APP-80W284485P519543T,PayPal.ENV_SANDBOX);

     @覆盖
     公共无效的onCreate(包savedInstanceState){
      super.onCreate(savedInstanceState);
      的setContentView(R.layout.donate);
      的LinearLayout mainLayout =(的LinearLayout)findViewById(R.id.LinearLayout01);
      如果(ppObj == NULL)ppObj = PayPal.initWithAppID(this.getBaseContext(),APP-80W284485P519543T,PayPal.ENV_SANDBOX);
      CheckoutButton payPalButton =(CheckoutButton)ppObj.getPaymentButton(PayPal.BUTTON_294x45,这一点,PayPal.PAYMENT_TYPE_HARD_GOODS);
      payPalButton.setOnClickListener(本);
      mainLayout.addView(payPalButton);
     }

     公共无效的onClick(查看为arg0){
      PayPalPayment newPayment =新PayPalPayment();
      newPayment.setAmount((浮点)1.00);
      newPayment.setCurrency(美元);
      newPayment.setRecipient(example@example.com);
      意图checkoutIntent =新的意图(这一点,PayPalActivity.class);
      checkoutIntent.putExtra(PayPalActivity.EXTRA_PAYMENT_INFO,newPayment);

      this.startActivityForResult(checkoutIntent,1);
     }

     @覆盖
        公共无效onBack pressed(){
      意图menuIntent =新的意图(Donate.this,MTGTools.class);
         this.startActivity(menu​​Intent);
        }
    }
 

解决方案

的onclick

  PP = PayPal.getInstance();

//应该像这样开始贝宝活动
PayPalPayment newPayment =新PayPalPayment();
newPayment.setCurrencyType(美元);

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

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

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

  2. 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和贝宝API集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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