Created
July 18, 2011 21:21
-
-
Save dawsontoth/1090694 to your computer and use it in GitHub Desktop.
??
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Appcelerator Titanium Mobile | |
* Copyright (c) 2009-2010 by Appcelerator, Inc. All Rights Reserved. | |
*/ | |
package ti.modules.titanium.paypal; | |
import java.math.BigDecimal; | |
import org.appcelerator.kroll.KrollDict; | |
import org.appcelerator.titanium.proxy.TiViewProxy; | |
import org.appcelerator.titanium.util.Log; | |
import org.appcelerator.titanium.util.TiActivityResultHandler; | |
import org.appcelerator.titanium.util.TiConfig; | |
import org.appcelerator.titanium.util.TiConvert; | |
import org.appcelerator.titanium.view.TiUIView; | |
import org.appcelerator.titanium.TiC; | |
import android.app.Activity; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.view.View; | |
import android.view.View.OnClickListener; | |
import com.paypal.android.MEP.CheckoutButton; | |
import com.paypal.android.MEP.PayPal; | |
import com.paypal.android.MEP.PayPalPayment; | |
public class PaypalButton extends TiUIView implements OnClickListener | |
{ | |
// Debug helpers | |
private static final String LCAT = "PaypalButton"; | |
private static final boolean DBG = TiConfig.DEBUG; | |
Activity activity; | |
// Module vars | |
CheckoutButton button; | |
public PaypalButton(TiViewProxy proxy) { | |
super(proxy); | |
activity = proxy.getTiContext().getActivity(); | |
PayPal pp = PayPal.getInstance(); | |
if (pp == null) { | |
pp = PayPal.initWithAppID(activity, "APP-80W284485P519543T", PayPal.ENV_SANDBOX); | |
pp.setLanguage("en_US"); | |
pp.setFeesPayer(PayPal.FEEPAYER_EACHRECEIVER); | |
} | |
if (pp.isLibraryInitialized()) { | |
button = pp.getCheckoutButton(activity, | |
PayPal.BUTTON_194x37, CheckoutButton.TEXT_PAY); | |
setNativeView(button); | |
} | |
} | |
@Override | |
public boolean fireEvent(String eventName, KrollDict data) { | |
if (eventName.equals(TiC.EVENT_CLICK)) { | |
Log.d(LCAT, "onClick fired!"); | |
} | |
return super.fireEvent(eventName, data); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment