Это полный код, который поможет вам выполнить эту функцию PayPal. Оставшаяся задача только для вас - создать аккаунт на https://developer.paypal.com/
{
CheckoutButton launchSimplePayment;
PayPal pp;
pp = PayPal.getInstance();
if (pp == null)
{
createPaypalObject();
//pp = PayPal.initWithAppID(this, "APP-80W284485P519543T",PayPal.ENV_SANDBOX);
}
else
{
pp.setShippingEnabled(false);
launchSimplePayment = pp.getCheckoutButton(this,PayPal.BUTTON_118x24, CheckoutButton.TEXT_PAY);
launchSimplePayment.setOnClickListener( this);
yourLayout.addView(launchSimplePayment);
}
}
public void createPaypalObject()
{
pp = PayPal.initWithAppID(this, "APP-80W284485P519543T",PayPal.ENV_SANDBOX);
pp.setShippingEnabled(false);
launchSimplePayment = pp.getCheckoutButton(this,PayPal.BUTTON_118x24, CheckoutButton.TEXT_PAY);
launchSimplePayment.setOnClickListener( this);
handler1.sendEmptyMessage(0);
}
//do this onClick of that payment button
{
PayPalPayment payment = new PayPalPayment();
payment.setSubtotal(new BigDecimal(price_of_song));
payment.setCurrencyType("USD");
payment.setRecipient("abc@gmail.com"); //this id must be created by you on payment.paypal.com, this is trial id.
payment.setPaymentType(PayPal.PAYMENT_TYPE_GOODS);
Intent checkoutIntent = PayPal.getInstance().checkout(payment, this);
startActivityForResult(checkoutIntent, 1);
}
/**This function shows the action by payment paypal*/
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch(resultCode) {
case Activity.RESULT_OK:
//The payment succeeded
Toast.makeText(this,"Payment has done successfully",Toast.LENGTH_SHORT).show();
break;
case Activity.RESULT_CANCELED:
Toast.makeText(this,"Payment has cancled",Toast.LENGTH_SHORT).show();
//The payment was canceled
break;
case PayPalActivity.RESULT_FAILURE:
Toast.makeText(this,"Sorry Payment failed",Toast.LENGTH_SHORT).show();
//The payment failed -- we get the error from the EXTRA_ERROR_ID and EXTRA_ERROR_MESSAGE
}
super.onActivityResult(requestCode, resultCode, data);
}
Если какой-либо запрос, не стесняйтесь спрашивать меня в любое время.