getTradeResult static method

TradeResult getTradeResult(
  1. Map result
)

Implementation

static TradeResult getTradeResult(Map result) {
  // 如果失败
  if (result[AlibcConstKey.errorCode] != "0") {
    return TradeResult(
      result[AlibcConstKey.errorCode],
      result[AlibcConstKey.errorMessage],
    );
  }

  // 判断类型
  if (result[AlibcConstKey.data]["type"] ==
      TradeResultType.AlibcTradeResultTypePaySuccess) {
    // 付款成功
    return TradeResult(
        result[AlibcConstKey.errorCode], result[AlibcConstKey.errorMessage],
        type: TradeResultType.AlibcTradeResultTypePaySuccess,
        payResult: PayResult(
          result[AlibcConstKey.data]["paySuccessOrders"],
          result[AlibcConstKey.data]["payFailedOrders"],
        ));
  } else {
    // 添加购物车成功
    return TradeResult(
      result[AlibcConstKey.errorCode],
      result[AlibcConstKey.errorMessage],
      type: TradeResultType.AlibcTradeResultTypeAddCard,
    );
  }
}