gpt4 book ai didi

Android 和 Paypal API 集成

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:45:52 26 4
gpt4 key购买 nike

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

  1. 我可以看到按钮,我点击它但没有任何反应! (checkoutIntent 的 Activity 没有触发?)

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


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

最佳答案

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 集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3587060/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com