File tree 1 file changed +21
-5
lines changed
1 file changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -37,9 +37,6 @@ function validateWithAppStore(url, receipt) {
37
37
return fulfill ( ) ;
38
38
}
39
39
// receipt is from test and should go to test
40
- if ( status == 21007 ) {
41
- return validateWithAppStore ( IAP_SANDBOX_URL ) ;
42
- }
43
40
return reject ( body ) ;
44
41
} ) ;
45
42
} ) ;
@@ -82,11 +79,30 @@ export class IAPValidationRouter extends PromiseRouter {
82
79
if ( process . env . NODE_ENV == "test" && req . body . bypassAppStoreValidation ) {
83
80
return getFileForProductIdentifier ( productIdentifier , req ) ;
84
81
}
82
+
83
+ function successCallback ( ) {
84
+ return getFileForProductIdentifier ( productIdentifier , req ) ;
85
+ } ;
86
+
87
+ function errorCallback ( error ) {
88
+ return Promise . resolve ( { response : appStoreError ( error . status ) } ) ;
89
+ }
85
90
86
91
return validateWithAppStore ( IAP_PRODUCTION_URL , receipt ) . then ( ( ) => {
87
- return getFileForProductIdentifier ( productIdentifier , req ) ;
92
+
93
+ return successCallback ( ) ;
94
+
88
95
} , ( error ) => {
89
- return Promise . resolve ( { response : appStoreError ( error . status ) } ) ;
96
+ if ( error . status == 21007 ) {
97
+ return validateWithAppStore ( IAP_SANDBOX_URL , receipt ) . then ( ( ) => {
98
+ return successCallback ( ) ;
99
+ } , ( error ) => {
100
+ return errorCallback ( error ) ;
101
+ }
102
+ ) ;
103
+ }
104
+
105
+ return errorCallback ( error ) ;
90
106
} ) ;
91
107
}
92
108
You can’t perform that action at this time.
0 commit comments