PayPal Woes (Solved)

I’ve gotten PayPal up and running. I had to submit the api to their site. That was a joy; but it’s now up and live! Now I just need to update the orientation handler so I can set api 18 as the target. I don’t think it will take me more than a day to figure out. So If I get it done tomorrow then I can release a Sunday update! So stoked

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 public class DonateView extends Activity implements OnClickListener {

	private PayPal pp;
	private AdView adView;
	private ProgressDialog ppDialog;
	private CheckoutButton payButton, payButton2;
	private EditText amount;
	private String aString;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

		initLibrary();

		ScrollView scroller = new ScrollView(this);
		scroller.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
				LayoutParams.MATCH_PARENT));

		amount = new EditText(this);
		amount.setText(".99");
		amount.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
		amount.setGravity(Gravity.CENTER_HORIZONTAL);
		amount.setHint("Donation Amount");
		amount.setTextSize(20f);
		amount.setPadding(40, 10, 40, 0);
		amount.setInputType(InputType.TYPE_CLASS_PHONE);

		LinearLayout simplePay = new LinearLayout(this);
		simplePay.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
				LayoutParams.MATCH_PARENT));
		simplePay.setBackgroundColor(Color.TRANSPARENT);
		simplePay.setGravity(Gravity.CENTER_HORIZONTAL);
		simplePay.setPadding(10, 10, 10, 10);
		simplePay.setOrientation(LinearLayout.VERTICAL);
		simplePay.setBackgroundResource(R.drawable.pp_bg2);

		RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		params.addRule(RelativeLayout.ALIGN_BOTTOM);
		params.topMargin = 20;
		payButton = pp.getCheckoutButton(this, PayPal.BUTTON_194x37,
				CheckoutButton.TEXT_DONATE);
		payButton.setOnClickListener(this);
		payButton.setLayoutParams(params);

		TextView btnLabel = new TextView(this);
		btnLabel.setGravity(Gravity.CENTER_HORIZONTAL);
		btnLabel.setText("Donate to DBZ-HD Stream");
		btnLabel.setTextSize(16f);
		btnLabel.setTypeface(null, Typeface.BOLD);
		btnLabel.setTextColor(Color.BLACK);

		LinearLayout btnHolder = new LinearLayout(this);
		btnHolder.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
				LayoutParams.WRAP_CONTENT));
		btnHolder.setGravity(Gravity.CENTER_HORIZONTAL);
		btnHolder.setOrientation(LinearLayout.VERTICAL);
		btnHolder.setBackgroundColor(Color.TRANSPARENT);
		btnHolder.setPadding(0, 40, 0, 40);
		btnHolder.addView(payButton);
		btnHolder.addView(btnLabel);

		RelativeLayout.LayoutParams params2 = new RelativeLayout.LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		params2.addRule(RelativeLayout.ALIGN_BOTTOM);
		params2.topMargin = 20;
		payButton2 = pp.getCheckoutButton(this, PayPal.BUTTON_194x37,
				CheckoutButton.TEXT_DONATE);
		payButton2.setOnClickListener(this);
		payButton2.setLayoutParams(params2);

		TextView btnLabel2 = new TextView(this);
		btnLabel2.setGravity(Gravity.CENTER_HORIZONTAL);
		btnLabel2.setText("Donate to DBZ-HD App");
		btnLabel2.setTypeface(null, Typeface.BOLD);
		btnLabel2.setTextSize(16f);
		btnLabel2.setTextColor(Color.BLACK);

		LinearLayout btnHolder2 = new LinearLayout(this);
		btnHolder2.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
				LayoutParams.WRAP_CONTENT));
		btnHolder2.setGravity(Gravity.CENTER_HORIZONTAL);
		btnHolder2.setOrientation(LinearLayout.VERTICAL);
		btnHolder2.setBackgroundColor(Color.TRANSPARENT);
		btnHolder2.setPadding(0, 20, 0, 20);
		btnHolder2.addView(payButton2);
		btnHolder2.addView(btnLabel2);
		
		adView = new AdView(this, AdSize.BANNER, "Put a key here");
		adView.loadAd(new AdRequest());

		simplePay.addView(amount);
		//simplePay.addView(btnHolder);
		simplePay.addView(btnHolder2);
		simplePay.addView(adView);
		scroller.addView(simplePay);
		setContentView(scroller);
	}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s