@@ -22,15 +22,20 @@ define('install',
2222 z . apps [ product . manifest_url ] . launch ( ) ;
2323 tracking . trackEvent (
2424 'Launch app' ,
25- product . payment_required ? 'Paid' : 'Free' ,
25+ product . receipt_required ? 'Paid' : 'Free' ,
2626 product . slug
2727 ) ;
2828 } ) ;
2929
3030 var installHandler = _handler ( startInstall ) ;
3131
3232 function startInstall ( product ) {
33- if ( product . payment_required && ! user . logged_in ( ) ) {
33+ // TODO: Have the API possibly return this (bug 889501).
34+ product . receipt_required = premium_type != 'free' && premium_type != 'free-inapp' ;
35+
36+ // If we have a premium app (even if it's '$0.00'), require the user
37+ // to first log so we can record the purchase and generate a receipt.
38+ if ( product . receipt_required && ! user . logged_in ( ) ) {
3439 console . log ( 'Install suspended; user needs to log in' ) ;
3540 return login . login ( ) . done ( function ( ) {
3641 startInstall ( product ) ;
@@ -41,7 +46,7 @@ define('install',
4146 }
4247
4348 console . log ( 'Starting app installation' ) ;
44- if ( product . payment_required ) {
49+ if ( product . receipt_required ) {
4550 return purchase ( product ) ;
4651 } else {
4752 return install ( product ) ;
@@ -105,9 +110,9 @@ define('install',
105110
106111 var def = defer . Deferred ( ) ;
107112 // NOTE: We don't want to check `payment_required` because
108- // even a paid app with a price of '0.00' should still hit the
113+ // even a paid app with a price of '$ 0.00' should still hit the
109114 // API endpoint for receipt creation (bug 886568).
110- requests . post ( urls . api . url ( 'record_' + ( product . price == null ? 'free ' : 'paid ' ) ) ,
115+ requests . post ( urls . api . url ( 'record_' + ( product . receipt_required ? 'paid ' : 'free ' ) ) ,
111116 post_data ) . done ( function ( response ) {
112117 if ( response . error ) {
113118 $ ( '#pay-error' ) . show ( ) . find ( 'div' ) . text ( response . error ) ;
0 commit comments