Hi all, The in-app payments JavaScript API (a shim provided by the Marketplace for apps) has been incubating for a while but since more than a few people are following it now, I'll start posting changes as they happen for feedback and consideration.
Docs: https://developer.mozilla.org/en/Apps/In-app_payments The biggest change recently is we switched from an iframe flow to using a popup window for security purposes. (The B2G flow is still in flux so this just applies to desktop.) This required us to make a slight API change to work around popup blockers. The new API looks like this: var request = mozmarket.buy(onPaySuccess, onPayFailure); request.sign(signedRequest); This gets us past popup blockers but also has a nice side effect of acting more asynchronously so the user does not have to wait while the app fetches a JWT anymore. In a more realistic app the JS flow would look something like this: $('button.buy').click(function(event) { event.preventDefault(); var $button = $(this); var onSuccess = function() { alert('payment completed'); }; var onError = function() { alert('payment canceled'); }; // Start the payment flow for the buyer. var request = mozmarket.buy(onSuccess, onError); $.post('/sign-request', {productId: $button.data('product-id')}, function(data) { // Set the signed request (JWT) from a server POST that returns JSON. request.sign(data.signedRequest); }, 'json'); }); Let me know if you have questions or concerns about the API change. -Kumar _______________________________________________ dev-webapps mailing list [email protected] https://lists.mozilla.org/listinfo/dev-webapps
