public void TestCreateVirtualAccount() { string filepath = "dummy_virtual_account.json"; Client client = new Client(ACCESSID, SECRETKEY, Helper.GetMockRequestFactory(filepath, virtualAccountURL)); IDictionary <string, object> upi = new Dictionary <string, object> (); upi.Add("amount", 1000); IDictionary <string, object> collectionMethod = new Dictionary <string, object> (); collectionMethod.Add("bank_account", ""); collectionMethod.Add("upi", upi); IDictionary <string, object> options = new Dictionary <string, object> (); options.Add("invoice_id", "invt_srxOZZk6dIgWTVls"); options.Add("collection_methods", collectionMethod); options.Add("customer_id", "cust_2WmsQoSRZMWWkcZg"); options.Add("email", "*****@*****.**"); options.Add("notification_method", "both"); options.Add("customer_notification_by", "platform"); VirtualAccount virtualAccount = client.VirtualAccount.Create(options); string expectedJsonString = Helper.GetJsonString(filepath); Helper.AssertEntity(virtualAccount, expectedJsonString); }
public VirtualAccount CreateVirtualAccountIfNotExists(IWeChatCardKey cardKey) { var session = this.OS.TransactionManager.GetSession(); var criteria = session.CreateCriteria <VirtualAccount>(); criteria.Add(Expression.Eq("AppId", cardKey.AppId)); criteria.Add(Expression.Eq("OpenId", cardKey.OpenId)); criteria.Add(Expression.Eq("CardId", cardKey.CardId)); criteria.Add(Expression.Eq("Code", cardKey.Code)); var va = criteria.UniqueResult <VirtualAccount>(); if (va == null) { va = new VirtualAccount() { AppId = cardKey.AppId, OpenId = cardKey.OpenId, CardId = cardKey.CardId, LastUpdatedTime = DateTime.Now.ToUnixStampDateTime(), LastTrading = null, State = VAStates.Normal, Code = cardKey.Code, Money = 0, }; } return(va); }
private PurchaseErrorCode ValidatePurchaseRequest(CustomerKey customerKey, Money totalCost) { VirtualAccount account = _virtualAccountServiceGateway.GetAccount(customerKey); if (account.Balance.AvailableAmount < totalCost) { return(PurchaseErrorCode.NotEnoughFunds); } BetLimitStatusAfterBet betPeriodSummary = _bettingServiceGateway.GetBetLimitStatusForAmount(customerKey, totalCost); if (betPeriodSummary.AffectedLimit == BetLimit.LimitNotSet) { return(PurchaseErrorCode.LimitNotSet); } if (betPeriodSummary.Exceeded) { switch (betPeriodSummary.AffectedLimit) { case BetLimit.Daily: return(PurchaseErrorCode.ExceededDailyBetLimit); case BetLimit.Weekly: return(PurchaseErrorCode.ExceededWeeklyBetLimit); case BetLimit.Monthly: return(PurchaseErrorCode.ExceededMonthlyBetLimit); default: return(PurchaseErrorCode.ExceededDailyBetLimit); } } return(PurchaseErrorCode.NotSet); }
public static List <Payment> FetchAllPaymentsFromVa() { VirtualAccount va = VirtualAccountCreateTest(); VirtualAccount va1 = new VirtualAccount((string)va["id"]); return(va1.Payments()); }
public static VirtualAccount VirtualAccountCloseTest() { VirtualAccount va = VirtualAccountCreateTest(); VirtualAccount va1 = new VirtualAccount((string)va["id"]); return(va1.Close()); }
public void TestGetVirtualAccountById() { string filepath = "dummy_virtual_account.json"; string url = string.Format("{0}/{1}", virtualAccountURL, VIRTUALACCOUNTID); Client client = new Client(ACCESSID, SECRETKEY, Helper.GetMockRequestFactory(filepath, url)); VirtualAccount virtualAccount = client.VirtualAccount.Retrieve(VIRTUALACCOUNTID); string expectedJsonString = Helper.GetJsonString(filepath); Helper.AssertEntity(virtualAccount, expectedJsonString); }
public static VirtualAccount VirtualAccountFetchTest() { VirtualAccount va = VirtualAccountCreateTest(); VirtualAccount va2 = Helper.client.VirtualAccount.Fetch((string)va["id"]); Assert.AreEqual(va["id"], va2["id"]); return(va2); }
public void VirtualDurationAccountTest() { var virtuala = new VirtualAccount(); var virtualaccountparams = new VirtualAccountParams(1, 2, "TEST-C-ACCOUNT", ScKey, "*****@*****.**", "TRF-SHDJß", "100"); var chargeResponse = virtuala.CreateTransactionVirtualAccount(virtualaccountparams); System.Console.WriteLine("chargeResponse:" + chargeResponse.ToString()); JObject json = JObject.Parse(chargeResponse); // Assert.IsNotNull(chargeResponse.Data); Assert.AreEqual("success", (string)json.SelectToken("status")); }
public IHttpActionResult GetCredit() { CustomerKey customerKey = _customerProvider.FindCurrentCustomerKey(); BetLimitStatusAfterBet betLimitStatus = _bettingServiceGateway.GetBetLimitStatusForAmount(customerKey, Money.FromKroner(0)); VirtualAccount account = _virtualAccountServiceGateway.GetAccount(customerKey); var model = new Credit { Balance = account.Balance.AvailableAmount.Amount, RemainingBetLimit = betLimitStatus.LowestLimitRemainder.Amount, HasBetLimit = betLimitStatus.AffectedLimit != BetLimit.LimitNotSet }; return(Ok(RestResult <Credit> .CreateSuccess(model))); }
public static VirtualAccount VirtualAccountEditTest() { VirtualAccount va = VirtualAccountCreateTest(); Dictionary <string, object> data = new Dictionary <string, object>(); using (StreamReader r = new StreamReader("./test/data/virtualaccount-edit.json")) { string json = r.ReadToEnd(); data = JsonConvert.DeserializeObject <Dictionary <string, object> >(json); } VirtualAccount va1 = new VirtualAccount((string)va["id"]); return(va1.Edit(data)); }
public void TestGetAllPaymentsForVirtualAccount() { string filepath = "dummy_virtual_account.json"; string url = string.Format("{0}/{1}", virtualAccountURL, VIRTUALACCOUNTID); Client client = new Client(ACCESSID, SECRETKEY, Helper.GetMockRequestFactory(filepath, url)); VirtualAccount virtualAccount = client.VirtualAccount.Retrieve(VIRTUALACCOUNTID); string expectedJsonString = Helper.GetJsonString(filepath); Helper.AssertEntity(virtualAccount, expectedJsonString); string filepath2 = "dummy_payment_collection.json"; string payments_url = string.Format("{0}/payments", url); client = new Client(ACCESSID, SECRETKEY, Helper.GetMockRequestFactory(filepath2, payments_url)); var result = virtualAccount.Payments(); expectedJsonString = Helper.GetJsonString(filepath2); Helper.AssertEntity(result, expectedJsonString); }
public static void CloseVirtualAccountTest() { VirtualAccount va = Helper.VirtualAccountCloseTest(); Assert.NotNull(va); }
public static void EditVirtualAccountTest() { VirtualAccount va = Helper.VirtualAccountEditTest(); Assert.NotNull(va); }
public static void FetchVirtualAccountTest() { VirtualAccount va = Helper.VirtualAccountFetchTest(); Assert.NotNull(va); }