Last active
August 29, 2015 14:24
-
-
Save marchbold/0308d165524ebbeb6308 to your computer and use it in GitHub Desktop.
Making a Single Payment with the PayPal SDK
This file contains hidden or 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
if (PayPalSDK.isSupported) | |
{ | |
PayPalSDK.service.addEventListener( PayPalPaymentEvent.COMPLETE, paypal_paymentCompleteHandler ); | |
PayPalSDK.service.addEventListener( PayPalPaymentEvent.CANCELLED, paypal_paymentCancelledHandler ); | |
PayPalSDK.service.addEventListener( PayPalPaymentEvent.ERROR, paypal_paymentErrorHandler ); | |
// Can do this call anywhere before you make a payment, | |
// but PayPal suggest calling it close to the payment/consent calls | |
// as connection is 'short lived' | |
if (PayPalSDK.service.connect( PayPalEnvironment.SANDBOX )) | |
{ | |
var payment:PayPalPayment = new PayPalPayment( 10, "AUD", "A Test Payment", PayPalPayment.INTENT_SALE ); | |
PayPalSDK.service.makePayment( payment ); | |
} | |
} | |
... | |
private function paypal_paymentCompleteHandler( event:PayPalPaymentEvent ):void | |
{ | |
trace( "payment complete" ); | |
// send 'event.confirmation' to your server for verification | |
// more details: https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/ | |
} | |
private function paypal_paymentCancelledHandler( event:PayPalPaymentEvent ):void | |
{ | |
trace( "payment cancelled" ); | |
} | |
private function paypal_paymentErrorHandler( event:PayPalPaymentEvent ):void | |
{ | |
trace( "payment error" ); | |
} | |
// com.distriqt.PayPalSDK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment