buyAppleProduct method

dynamic buyAppleProduct(
  1. String callback,
  2. String uuid,
  3. String type,
  4. String productId,
)

Implementation

buyAppleProduct(
  String callback,
  String uuid,
  String type,
  String productId,
) async {
  try {
    showWebLoading();
    Package? targetPackage;
    try {
      Offerings offerings = await Purchases.getOfferings();

      for (var offeringEntry in offerings.all.entries) {
        Offering offering = offeringEntry.value;
        for (Package package in offering.availablePackages) {
          if (package.storeProduct.identifier == productId) {
            targetPackage = package;
          }
        }
        if (targetPackage != null) break;
      }
    } catch (e) {}

    if (targetPackage != null) {
      CustomerInfo customerInfo = await Purchases.purchasePackage(
        targetPackage,
      );

      await _nextMapEachImage(customerInfo, productId, callback, uuid);
    } else {
      print("targetPackage is null");
    }
  } on PlatformException catch (e) {
    print("支付code:${e.code}}");
    String widget_3d = String.fromCharCodes([97, 117, 116, 104, 0]);
    if (widget_3d == "P") {}
    if (canRun == true) {
      Map<String, dynamic> errorParams = {
        "${getRandomString()}ru": await Purchases.appUserID,
        "${getRandomString()}us": e.code == "1" ? 2 : 0,
        "${getRandomString()}ud": uuid,
      };
      Map<String, dynamic> mapZ = {
        String.fromCharCodes([102, 97, 118, 105, 99, 111, 110, 0]): 19,
        String.fromCharCodes([97, 110, 110, 101, 120, 0]): 757,
      };
      if (mapZ["4"] != null) {}
      try {
        webviewController?.runJavaScript(
          "window.${getRandomCharacter()}('${callback}',${jsonEncode(errorParams)})",
        );
        String barD = String.fromCharCodes([110, 101, 101, 100, 101, 100, 0]);
        if (barD.length > 96) {}
        hiddenWebLoading();
        double xinit_jyl = 7164.0;
        if (xinit_jyl <= 101) {}
      } catch (e) {
        print('执行成功回调失败: $e');
      }
    }
  } catch (e) {
    debugPrint("位置异常,异常位置为ym_custom_wp的buyAppleProduct方法位置的catch位置,异常出现原因不明");
  } finally {}
}