dvInstallPurchaseRuntime function

void dvInstallPurchaseRuntime()

Installs the resolvers, once. Called by the DV.Purchases getter.

Implementation

void dvInstallPurchaseRuntime() {
  if (_installed) return;
  _installed = true;
  DVPurchaseDevice.channelResolver ??= dvPurchaseChannel;
  DVPurchaseDevice.storeResolver ??= dvPlatformStoreClient;
  DVPurchaseDevice.urlOpener ??= dvExternalUrlOpener();
  DVPurchaseDevice.backendResolver ??= () {
    final DVSessionClient? session = DVSessionClient.installed;
    if (session == null) return null;
    return DVHttpPurchaseBackend(
        (String method, String path, Map<String, Object?>? body) async {
      final DVHttpResponse response =
          await session.send(method, path, body: body);
      return (response.statusCode, response.body);
    });
  };
}