applyCheckoutCustomizationResponse static method

void applyCheckoutCustomizationResponse(
  1. PayorcSdk sdk,
  2. CheckoutCustomizationResponse response
)

Updates sdk from response when sdk is still the active instance.

Used by _loadCheckoutCustomization and PaymentOptionsSheetFlowBloc after PayOrcRepo.fetchCheckoutCustomization.

Implementation

static void applyCheckoutCustomizationResponse(
  PayorcSdk sdk,
  CheckoutCustomizationResponse response,
) {
  final current = _instance;
  if (current == null || !identical(current, sdk)) return;
  if (response.isSuccess && response.data != null) {
    current.checkoutCustomization = response.data;
    PayorcSdkUiConstants.applyFromMerchantDetails(
      response.data!.merchantDetails,
    );
    _apiInputBorderStyle = _inputBorderStyleFromCheckout(
      response.data!.merchantDetails?.fieldBorder,
    );
    _apiAppBarStyle = _appBarStyleFromCheckout(
      response.data!.merchantDetails?.appStyle,
    );
    _applyUiColorOverrides();
    checkoutCustomizationRevision.value++;
    uiCustomizationRevision.value++;
  } else if (kDebugMode) {
    debugPrint(
      'Payorc checkout customization failed: '
      '${response.code ?? ''} ${response.message ?? response.status ?? ''}',
    );
  }
}