On Friday, June 15, 2012 3:58:45 PM UTC-7, Kumar McMillan wrote:
> 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

Hi Kumar,

Has this idea been tested with the recent implementation of 
https://bugzilla.mozilla.org/show_bug.cgi?id=752666? This implementation change 
affects if a pop-up would open as a separate app window (i.e. no target equals 
blank) vs. open in the browser (i.e. target equals blank). This change also 
just recently landed on 6/12.

Sincerely,
Jason Smith
_______________________________________________
dev-webapps mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-webapps

Reply via email to