@@ -291,12 +291,12 @@ + (SKPaymentDiscount *)getSKPaymentDiscountFromMap:(NSDictionary *)map
291
291
return discount;
292
292
}
293
293
294
- + (nullable SKPaymentTransactionMessage *)convertTransactionToPigeon :
294
+ + (nullable FIASKPaymentTransactionMessage *)convertTransactionToPigeon :
295
295
(nullable SKPaymentTransaction *)transaction API_AVAILABLE(ios(12.2 )) {
296
296
if (!transaction) {
297
297
return nil ;
298
298
}
299
- SKPaymentTransactionMessage *msg = [SKPaymentTransactionMessage
299
+ return [FIASKPaymentTransactionMessage
300
300
makeWithPayment: [self convertPaymentToPigeon: transaction.payment]
301
301
transactionState: [self convertTransactionStateToPigeon: transaction.transactionState]
302
302
originalTransaction: transaction.originalTransaction
@@ -306,10 +306,9 @@ + (nullable SKPaymentTransactionMessage *)convertTransactionToPigeon:
306
306
timeIntervalSince1970 ]]
307
307
transactionIdentifier: transaction.transactionIdentifier
308
308
error: [self convertSKErrorToPigeon: transaction.error]];
309
- return msg;
310
309
}
311
310
312
- + (nullable SKErrorMessage *)convertSKErrorToPigeon : (nullable NSError *)error {
311
+ + (nullable FIASKErrorMessage *)convertSKErrorToPigeon : (nullable NSError *)error {
313
312
if (!error) {
314
313
return nil ;
315
314
}
@@ -320,127 +319,117 @@ + (nullable SKErrorMessage *)convertSKErrorToPigeon:(nullable NSError *)error {
320
319
userInfo[key] = [FIAObjectTranslator encodeNSErrorUserInfo: value];
321
320
}
322
321
323
- SKErrorMessage *msg = [SKErrorMessage makeWithCode: error.code
324
- domain: error.domain
325
- userInfo: userInfo];
326
- return msg;
322
+ return [FIASKErrorMessage makeWithCode: error.code domain: error.domain userInfo: userInfo];
327
323
}
328
324
329
- + (SKPaymentTransactionStateMessage )convertTransactionStateToPigeon :
325
+ + (FIASKPaymentTransactionStateMessage )convertTransactionStateToPigeon :
330
326
(SKPaymentTransactionState)state {
331
327
switch (state) {
332
328
case SKPaymentTransactionStatePurchasing:
333
- return SKPaymentTransactionStateMessagePurchasing ;
329
+ return FIASKPaymentTransactionStateMessagePurchasing ;
334
330
case SKPaymentTransactionStatePurchased:
335
- return SKPaymentTransactionStateMessagePurchased ;
331
+ return FIASKPaymentTransactionStateMessagePurchased ;
336
332
case SKPaymentTransactionStateFailed:
337
- return SKPaymentTransactionStateMessageFailed ;
333
+ return FIASKPaymentTransactionStateMessageFailed ;
338
334
case SKPaymentTransactionStateRestored:
339
- return SKPaymentTransactionStateMessageRestored ;
335
+ return FIASKPaymentTransactionStateMessageRestored ;
340
336
case SKPaymentTransactionStateDeferred:
341
- return SKPaymentTransactionStateMessageDeferred ;
337
+ return FIASKPaymentTransactionStateMessageDeferred ;
342
338
}
343
339
}
344
340
345
- + (nullable SKPaymentMessage *)convertPaymentToPigeon : (nullable SKPayment *)payment
341
+ + (nullable FIASKPaymentMessage *)convertPaymentToPigeon : (nullable SKPayment *)payment
346
342
API_AVAILABLE(ios(12.2 )) {
347
343
if (!payment) {
348
344
return nil ;
349
345
}
350
- SKPaymentMessage *msg = [SKPaymentMessage
346
+ return [FIASKPaymentMessage
351
347
makeWithProductIdentifier: payment.productIdentifier
352
348
applicationUsername: payment.applicationUsername
353
349
requestData: [[NSString alloc ] initWithData: payment.requestData
354
350
encoding: NSUTF8StringEncoding]
355
351
quantity: payment.quantity
356
352
simulatesAskToBuyInSandbox: payment.simulatesAskToBuyInSandbox
357
353
paymentDiscount: [self convertPaymentDiscountToPigeon: payment.paymentDiscount]];
358
- return msg;
359
354
}
360
355
361
- + (nullable SKPaymentDiscountMessage *)convertPaymentDiscountToPigeon :
356
+ + (nullable FIASKPaymentDiscountMessage *)convertPaymentDiscountToPigeon :
362
357
(nullable SKPaymentDiscount *)discount API_AVAILABLE(ios(12.2 )) {
363
358
if (!discount) {
364
359
return nil ;
365
360
}
366
- SKPaymentDiscountMessage *msg =
367
- [SKPaymentDiscountMessage makeWithIdentifier: discount.identifier
368
- keyIdentifier: discount.keyIdentifier
369
- nonce: [discount.nonce UUIDString ]
370
- signature: discount.signature
371
- timestamp: [discount.timestamp intValue ]];
372
-
373
- return msg;
361
+ return [FIASKPaymentDiscountMessage makeWithIdentifier: discount.identifier
362
+ keyIdentifier: discount.keyIdentifier
363
+ nonce: [discount.nonce UUIDString ]
364
+ signature: discount.signature
365
+ timestamp: [discount.timestamp intValue ]];
374
366
}
375
367
376
- + (nullable SKStorefrontMessage *)convertStorefrontToPigeon : (nullable SKStorefront *)storefront
368
+ + (nullable FIASKStorefrontMessage *)convertStorefrontToPigeon : (nullable SKStorefront *)storefront
377
369
API_AVAILABLE(ios(13.0 )) {
378
370
if (!storefront) {
379
371
return nil ;
380
372
}
381
- SKStorefrontMessage *msg = [SKStorefrontMessage makeWithCountryCode: storefront.countryCode
382
- identifier: storefront.identifier];
383
- return msg;
373
+ return [FIASKStorefrontMessage makeWithCountryCode: storefront.countryCode
374
+ identifier: storefront.identifier];
384
375
}
385
376
386
- + (nullable SKProductSubscriptionPeriodMessage *)convertSKProductSubscriptionPeriodToPigeon :
377
+ + (nullable FIASKProductSubscriptionPeriodMessage *)convertSKProductSubscriptionPeriodToPigeon :
387
378
(nullable SKProductSubscriptionPeriod *)period API_AVAILABLE(ios(12.2 )) {
388
379
if (!period) {
389
380
return nil ;
390
381
}
391
382
392
- SKSubscriptionPeriodUnitMessage unit;
383
+ FIASKSubscriptionPeriodUnitMessage unit;
393
384
switch (period.unit ) {
394
385
case SKProductPeriodUnitDay:
395
- unit = SKSubscriptionPeriodUnitMessageDay ;
386
+ unit = FIASKSubscriptionPeriodUnitMessageDay ;
396
387
break ;
397
388
case SKProductPeriodUnitWeek:
398
- unit = SKSubscriptionPeriodUnitMessageWeek ;
389
+ unit = FIASKSubscriptionPeriodUnitMessageWeek ;
399
390
break ;
400
391
case SKProductPeriodUnitMonth:
401
- unit = SKSubscriptionPeriodUnitMessageMonth ;
392
+ unit = FIASKSubscriptionPeriodUnitMessageMonth ;
402
393
break ;
403
394
case SKProductPeriodUnitYear:
404
- unit = SKSubscriptionPeriodUnitMessageYear ;
395
+ unit = FIASKSubscriptionPeriodUnitMessageYear ;
405
396
break ;
406
397
}
407
398
408
- SKProductSubscriptionPeriodMessage *msg =
409
- [SKProductSubscriptionPeriodMessage makeWithNumberOfUnits: period.numberOfUnits unit: unit];
410
-
411
- return msg;
399
+ return [FIASKProductSubscriptionPeriodMessage makeWithNumberOfUnits: period.numberOfUnits
400
+ unit: unit];
412
401
}
413
402
414
- + (nullable SKProductDiscountMessage *)convertProductDiscountToPigeon :
403
+ + (nullable FIASKProductDiscountMessage *)convertProductDiscountToPigeon :
415
404
(nullable SKProductDiscount *)productDiscount API_AVAILABLE(ios(12.2 )) {
416
405
if (!productDiscount) {
417
406
return nil ;
418
407
}
419
408
420
- SKProductDiscountPaymentModeMessage paymentMode;
409
+ FIASKProductDiscountPaymentModeMessage paymentMode;
421
410
switch (productDiscount.paymentMode ) {
422
411
case SKProductDiscountPaymentModeFreeTrial:
423
- paymentMode = SKProductDiscountPaymentModeMessageFreeTrial ;
412
+ paymentMode = FIASKProductDiscountPaymentModeMessageFreeTrial ;
424
413
break ;
425
414
case SKProductDiscountPaymentModePayAsYouGo:
426
- paymentMode = SKProductDiscountPaymentModeMessagePayAsYouGo ;
415
+ paymentMode = FIASKProductDiscountPaymentModeMessagePayAsYouGo ;
427
416
break ;
428
417
case SKProductDiscountPaymentModePayUpFront:
429
- paymentMode = SKProductDiscountPaymentModeMessagePayUpFront ;
418
+ paymentMode = FIASKProductDiscountPaymentModeMessagePayUpFront ;
430
419
break ;
431
420
}
432
421
433
- SKProductDiscountTypeMessage type;
422
+ FIASKProductDiscountTypeMessage type;
434
423
switch (productDiscount.type ) {
435
424
case SKProductDiscountTypeIntroductory:
436
- type = SKProductDiscountTypeMessageIntroductory ;
425
+ type = FIASKProductDiscountTypeMessageIntroductory ;
437
426
break ;
438
427
case SKProductDiscountTypeSubscription:
439
- type = SKProductDiscountTypeMessageSubscription ;
428
+ type = FIASKProductDiscountTypeMessageSubscription ;
440
429
break ;
441
430
}
442
431
443
- SKProductDiscountMessage *msg = [SKProductDiscountMessage
432
+ return [FIASKProductDiscountMessage
444
433
makeWithPrice: productDiscount.price.description
445
434
priceLocale: [self convertNSLocaleToPigeon: productDiscount.priceLocale]
446
435
numberOfPeriods: productDiscount.numberOfPeriods
@@ -449,37 +438,33 @@ + (nullable SKProductDiscountMessage *)convertProductDiscountToPigeon:
449
438
.subscriptionPeriod]
450
439
identifier: productDiscount.identifier
451
440
type: type];
452
-
453
- return msg;
454
441
}
455
442
456
- + (nullable SKPriceLocaleMessage *)convertNSLocaleToPigeon : (nullable NSLocale *)locale
443
+ + (nullable FIASKPriceLocaleMessage *)convertNSLocaleToPigeon : (nullable NSLocale *)locale
457
444
API_AVAILABLE(ios(12.2 )) {
458
445
if (!locale) {
459
446
return nil ;
460
447
}
461
- SKPriceLocaleMessage *msg = [SKPriceLocaleMessage makeWithCurrencySymbol: locale.currencySymbol
462
- currencyCode: locale.currencyCode
463
- countryCode: locale.countryCode];
464
-
465
- return msg;
448
+ return [FIASKPriceLocaleMessage makeWithCurrencySymbol: locale.currencySymbol
449
+ currencyCode: locale.currencyCode
450
+ countryCode: locale.countryCode];
466
451
}
467
452
468
- + (nullable SKProductMessage *)convertProductToPigeon : (nullable SKProduct *)product
453
+ + (nullable FIASKProductMessage *)convertProductToPigeon : (nullable SKProduct *)product
469
454
API_AVAILABLE(ios(12.2 )) {
470
455
if (!product) {
471
456
return nil ;
472
457
}
473
458
474
459
NSArray <SKProductDiscount *> *skProductDiscounts = product.discounts ;
475
- NSMutableArray <SKProductDiscountMessage *> *pigeonProductDiscounts =
460
+ NSMutableArray <FIASKProductDiscountMessage *> *pigeonProductDiscounts =
476
461
[NSMutableArray arrayWithCapacity: skProductDiscounts.count];
477
462
478
463
for (SKProductDiscount *productDiscount in skProductDiscounts) {
479
464
[pigeonProductDiscounts addObject: [self convertProductDiscountToPigeon: productDiscount]];
480
465
};
481
466
482
- SKProductMessage *msg = [SKProductMessage
467
+ return [FIASKProductMessage
483
468
makeWithProductIdentifier: product.productIdentifier
484
469
localizedTitle: product.localizedTitle
485
470
localizedDescription: product.localizedDescription
@@ -490,27 +475,24 @@ + (nullable SKProductMessage *)convertProductToPigeon:(nullable SKProduct *)prod
490
475
[self convertSKProductSubscriptionPeriodToPigeon: product.subscriptionPeriod]
491
476
introductoryPrice: [self convertProductDiscountToPigeon: product.introductoryPrice]
492
477
discounts: pigeonProductDiscounts];
493
-
494
- return msg;
495
478
}
496
479
497
- + (nullable SKProductsResponseMessage *)convertProductsResponseToPigeon :
480
+ + (nullable FIASKProductsResponseMessage *)convertProductsResponseToPigeon :
498
481
(nullable SKProductsResponse *)productsResponse API_AVAILABLE(ios(12.2 )) {
499
482
if (!productsResponse) {
500
483
return nil ;
501
484
}
502
485
NSArray <SKProduct *> *skProducts = productsResponse.products ;
503
- NSMutableArray <SKProductMessage *> *pigeonProducts =
486
+ NSMutableArray <FIASKProductMessage *> *pigeonProducts =
504
487
[NSMutableArray arrayWithCapacity: skProducts.count];
505
488
506
489
for (SKProduct *product in skProducts) {
507
490
[pigeonProducts addObject: [self convertProductToPigeon: product]];
508
491
};
509
492
510
- SKProductsResponseMessage *msg = [SKProductsResponseMessage
493
+ return [FIASKProductsResponseMessage
511
494
makeWithProducts: pigeonProducts
512
495
invalidProductIdentifiers: productsResponse.invalidProductIdentifiers ?: @[]];
513
- return msg;
514
496
}
515
497
516
498
@end
0 commit comments