How to embed a javascript code into a buy button?

Hi

Can someone here guide me on how to embed a javascript code into a buy button in Corona?

I am building a music player that allow user to purchase a music using buy button. I have a javascript code that can be embedded for a single digital download.

Any tutorials that can lead me to this method will be much appreciated. 

Technically speaking, you cannot embed JavaScript into a button in Corona SDK.  They are incompatible technologies.  However, what you can do is use native.newWebView() to include an HTML page that  has an HTML button with the javascript attached to it and clicking on the button can do whatever web-stuff the javascript does inside the webView.

If you’re planning to release on iOS, you should probably also consult the App Store Review Guidelines, because selling content other than through Apple’s in-app purchase mechanism is likely grounds for rejection: https://developer.apple.com/appstore/resources/approval/guidelines.html.

  • Andrew

Hi Andrew,

Thanks for the advice. And I’m planning to release on Android.

I see. Thanks for the trick anyway.

Technically speaking, you cannot embed JavaScript into a button in Corona SDK.  They are incompatible technologies.  However, what you can do is use native.newWebView() to include an HTML page that  has an HTML button with the javascript attached to it and clicking on the button can do whatever web-stuff the javascript does inside the webView.

If you’re planning to release on iOS, you should probably also consult the App Store Review Guidelines, because selling content other than through Apple’s in-app purchase mechanism is likely grounds for rejection: https://developer.apple.com/appstore/resources/approval/guidelines.html.

  • Andrew

Hi Andrew,

Thanks for the advice. And I’m planning to release on Android.

I see. Thanks for the trick anyway.