handlePaymentQueueDelegateCallbacks method
Triage a method channel call from the platform and triggers the correct payment queue delegate method.
This method is public for testing purposes only and should not be used outside this class.
Implementation
@visibleForTesting
Future<dynamic> handlePaymentQueueDelegateCallbacks(MethodCall call) async {
assert(_paymentQueueDelegate != null,
'[in_app_purchase]: (Fatal)The payment queue delegate has not been set but we received a payment queue notification. Please ensure the payment queue has been set using `setDelegate`.');
final SKPaymentQueueDelegateWrapper delegate = _paymentQueueDelegate!;
switch (call.method) {
case 'shouldContinueTransaction':
final Map<Object?, Object?> arguments =
call.arguments as Map<Object?, Object?>;
final SKPaymentTransactionWrapper transaction =
SKPaymentTransactionWrapper.fromJson(
(arguments['transaction']! as Map<dynamic, dynamic>)
.cast<String, dynamic>());
final SKStorefrontWrapper storefront = SKStorefrontWrapper.fromJson(
(arguments['storefront']! as Map<dynamic, dynamic>)
.cast<String, dynamic>());
return delegate.shouldContinueTransaction(transaction, storefront);
case 'shouldShowPriceConsent':
return delegate.shouldShowPriceConsent();
default:
break;
}
throw PlatformException(
code: 'no_such_callback',
message:
'Did not recognize the payment queue delegate callback ${call.method}.');
}