private async Task<Result<GTokenTransactionModel>> CreateGTokenTransaction(GoEatApi goEatApi, decimal discountRate, string orderId, decimal originalPrice, string username, string description, decimal original_tax, decimal original_service_charge) { decimal amountAfterDiscount = originalPrice * (1 - discountRate); decimal amountServiceCharge = amountAfterDiscount * original_service_charge; decimal amountGst = (amountAfterDiscount + amountServiceCharge) * original_tax; var gTokenTransaction = goEatApi.CreateGTokenTransaction(new GTokenTransaction { currency = ConstantValues.S_CURRENCY_SGD, discount_percentage = discountRate, order_id = orderId, original_currency = ConstantValues.S_CURRENCY_SGD, original_price = originalPrice, original_final_amount = originalPrice * (1 - discountRate), username = username, status = ConstantValues.S_PENDING, payment_method = ConstantValues.S_PAYMENT_METHOD, description = description, is_venvici_applicable = true, original_tax = amountGst, original_service_charge = amountServiceCharge }); if (!gTokenTransaction.Succeeded) { return gTokenTransaction; } return gTokenTransaction; }
// Call CreateGtoken to Gtoken api in cases we use cash in transaction private async Task<Result<GTokenTransactionModel>> CreateGToken(GoEatApi goEatApi, decimal discountRate, string orderId, decimal originalPrice, decimal cash, string username, string description, decimal orginal_tax, decimal original_service_charge) { var gTokenTransaction = goEatApi.CreateGTokenTransaction(new GTokenTransaction { currency = ConstantValues.S_CURRENCY_SGD, discount_percentage = discountRate, order_id = orderId, original_currency = ConstantValues.S_CURRENCY_SGD, original_price = originalPrice, original_final_amount = cash, username = username, status = ConstantValues.S_PENDING, payment_method = ConstantValues.S_PAYMENT_METHOD, description = description, is_venvici_applicable = true, original_tax = orginal_tax, original_service_charge = original_service_charge }); if (!gTokenTransaction.Succeeded) { return gTokenTransaction; } //execute transaction gTokenTransaction.Data.transaction.status = ConstantValues.S_SUCCESS; gTokenTransaction = await goEatApi.ExecuteGTokenTransaction(gTokenTransaction.Data.transaction); return gTokenTransaction; }