Skip to content

Instantly share code, notes, and snippets.

@vivdub
Created April 4, 2011 14:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vivdub/901708 to your computer and use it in GitHub Desktop.
Save vivdub/901708 to your computer and use it in GitHub Desktop.
Sample file to demonstatrate simple paypal integration
package com.paypal;
import java.math.BigDecimal;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import com.paypal.android.MEP.PayPal;
import com.paypal.android.MEP.PayPalPayment;
public class Paypal extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Intent i = new Intent(this, PaypalExpressCheckout.class);
//this.startActivity(i);
invokeSimplePayment();
}
//===============================================================
private void invokeSimplePayment(){
try{
PayPalPayment newPayment = new PayPalPayment();
newPayment.setSubtotal(BigDecimal.valueOf(10));
newPayment.setCurrencyType("USD");
//.setCurrency("USD");
newPayment.setRecipient("my@email.com");
newPayment.setMerchantName("My Company");
PayPal pp = PayPal.getInstance();
if(pp==null)
pp = PayPal.initWithAppID(this, "APP-80W284485P519543T", PayPal.ENV_SANDBOX);
Intent paypalIntent = pp.checkout(newPayment, this);
this.startActivityForResult(paypalIntent, 1);
}catch(Exception e){e.printStackTrace();}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment