Skip to content

Instantly share code, notes, and snippets.

@marchbold
Last active August 29, 2015 14:24
Show Gist options
  • Save marchbold/b028622eae838cbfecff to your computer and use it in GitHub Desktop.
Save marchbold/b028622eae838cbfecff to your computer and use it in GitHub Desktop.
Obtain consent for profile sharing with the PayPal SDK
if (PayPalSDK.isSupported)
{
PayPalSDK.service.addEventListener( PayPalProfileSharingEvent.COMPLETE, paypal_profileSharingCompleteHandler );
PayPalSDK.service.addEventListener( PayPalProfileSharingEvent.CANCELLED, paypal_profileSharingCancelledHandler );
PayPalSDK.service.addEventListener( PayPalProfileSharingEvent.ERROR, paypal_profileSharingErrorHandler );
if (PayPalSDK.service.connect( PayPalEnvironment.NO_NETWORK ))
{
var scopes:Vector.<String> = Vector.<String>( [ PayPalAuthScopes.SCOPE_EMAIL, PayPalAuthScopes.SCOPE_ADDRESS ] );
PayPalSDK.service.obtainConsentForProfileSharing( scopes );
}
}
...
private function paypal_profileSharingCompleteHandler( event:PayPalPaymentEvent ):void
{
trace( "complete" );
trace( "authorisation code = " + event.auth.code );
// TODO:
// Send the authorization response to your server, where it can exchange the authorization code
// for OAuth access and refresh tokens.
//
// Your server must then store these tokens, so that your server code can use it
// for getting user profile data in the future.
}
private function paypal_profileSharingCancelledHandler( event:PayPalPaymentEvent ):void
{
trace( "cancelled" );
}
private function paypal_profileSharingErrorHandler( event:PayPalPaymentEvent ):void
{
trace( "error" );
}
// com.distriqt.PayPalSDK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment