@@ -21,16 +21,18 @@ const (
21
21
HostSandBox = "https://api.storekit-sandbox.itunes.apple.com"
22
22
HostProduction = "https://api.storekit.itunes.apple.com"
23
23
24
- PathTransactionInfo = "/inApps/v1/transactions/{transactionId}"
25
- PathLookUp = "/inApps/v1/lookup/{orderId}"
26
- PathTransactionHistory = "/inApps/v1/history/{originalTransactionId}"
27
- PathRefundHistory = "/inApps/v2/refund/lookup/{originalTransactionId}"
28
- PathGetALLSubscriptionStatus = "/inApps/v1/subscriptions/{originalTransactionId}"
29
- PathConsumptionInfo = "/inApps/v1/transactions/consumption/{originalTransactionId}"
30
- PathExtendSubscriptionRenewalDate = "/inApps/v1/subscriptions/extend/{originalTransactionId}"
31
- PathGetNotificationHistory = "/inApps/v1/notifications/history"
32
- PathRequestTestNotification = "/inApps/v1/notifications/test"
33
- PathGetTestNotificationStatus = "/inApps/v1/notifications/test/{testNotificationToken}"
24
+ PathTransactionInfo = "/inApps/v1/transactions/{transactionId}"
25
+ PathLookUp = "/inApps/v1/lookup/{orderId}"
26
+ PathTransactionHistory = "/inApps/v1/history/{originalTransactionId}"
27
+ PathRefundHistory = "/inApps/v2/refund/lookup/{originalTransactionId}"
28
+ PathGetALLSubscriptionStatus = "/inApps/v1/subscriptions/{originalTransactionId}"
29
+ PathConsumptionInfo = "/inApps/v1/transactions/consumption/{originalTransactionId}"
30
+ PathExtendSubscriptionRenewalDate = "/inApps/v1/subscriptions/extend/{originalTransactionId}"
31
+ PathExtendSubscriptionRenewalDateForAll = "/inApps/v1/subscriptions/extend/mass/"
32
+ PathGetStatusOfSubscriptionRenewalDate = "/inApps/v1/subscriptions/extend/mass/{productId}/{requestIdentifier}"
33
+ PathGetNotificationHistory = "/inApps/v1/notifications/history"
34
+ PathRequestTestNotification = "/inApps/v1/notifications/test"
35
+ PathGetTestNotificationStatus = "/inApps/v1/notifications/test/{testNotificationToken}"
34
36
)
35
37
36
38
type StoreConfig struct {
@@ -265,6 +267,52 @@ func (c *StoreClient) ExtendSubscriptionRenewalDate(ctx context.Context, origina
265
267
return statusCode , nil
266
268
}
267
269
270
+ // ExtendSubscriptionRenewalDateForAll https://developer.apple.com/documentation/appstoreserverapi/extend_subscription_renewal_dates_for_all_active_subscribers
271
+ func (c * StoreClient ) ExtendSubscriptionRenewalDateForAll (ctx context.Context , body MassExtendRenewalDateRequest ) (statusCode int , err error ) {
272
+ URL := HostProduction + PathExtendSubscriptionRenewalDateForAll
273
+ if c .Token .Sandbox {
274
+ URL = HostSandBox + PathExtendSubscriptionRenewalDateForAll
275
+ }
276
+
277
+ bodyBuf := new (bytes.Buffer )
278
+ err = json .NewEncoder (bodyBuf ).Encode (body )
279
+ if err != nil {
280
+ return 0 , err
281
+ }
282
+
283
+ statusCode , _ , err = c .Do (ctx , http .MethodPost , URL , bodyBuf )
284
+ if err != nil {
285
+ return statusCode , err
286
+ }
287
+ return statusCode , nil
288
+ }
289
+
290
+ // GetSubscriptionRenewalDataStatus https://developer.apple.com/documentation/appstoreserverapi/get_status_of_subscription_renewal_date_extensions
291
+ func (c * StoreClient ) GetSubscriptionRenewalDataStatus (ctx context.Context , productId , requestIdentifier string ) (statusCode int , rsp * MassExtendRenewalDateStatusResponse , err error ) {
292
+ URL := HostProduction + PathGetStatusOfSubscriptionRenewalDate
293
+ if c .Token .Sandbox {
294
+ URL = HostSandBox + PathGetStatusOfSubscriptionRenewalDate
295
+ }
296
+ URL = strings .Replace (URL , "{productId}" , productId , - 1 )
297
+ URL = strings .Replace (URL , "{requestIdentifier}" , requestIdentifier , - 1 )
298
+
299
+ statusCode , body , err := c .Do (ctx , http .MethodGet , URL , nil )
300
+ if err != nil {
301
+ return statusCode , nil , err
302
+ }
303
+
304
+ if statusCode != http .StatusOK {
305
+ return statusCode , nil , fmt .Errorf ("appstore api: %v return status code %v" , URL , statusCode )
306
+ }
307
+
308
+ err = json .Unmarshal (body , & rsp )
309
+ if err != nil {
310
+ return statusCode , nil , err
311
+ }
312
+
313
+ return statusCode , rsp , nil
314
+ }
315
+
268
316
// GetNotificationHistory https://developer.apple.com/documentation/appstoreserverapi/get_notification_history
269
317
func (c * StoreClient ) GetNotificationHistory (ctx context.Context , body NotificationHistoryRequest ) (responses []NotificationHistoryResponseItem , err error ) {
270
318
baseURL := c .hostUrl + PathGetNotificationHistory
0 commit comments