private async void ApiGetPaymentInstrument() { if (DistributorSubscriberNo == "" || DistributorSubscriberNo.Length != 12) { MessageBox.Show( "To pay using M-Money options, the Distributor Subscriber No (MSISDN)" + " must be provided from distributors primary contacts." + "\nPlease make sure you have entered the correct mobile phone number with the correct country code.", "Distributr: Payment Module", MessageBoxButton.OKCancel); CanMakePaymentRequest = false; return; } using (var c = NestedContainer) { //PGBResponse response = new PGBResponse() { Success = false }; PaymentOptionsLoaded = false; PaymentInstrumentResponse response = await Using<IPaymentGatewayProxy>(c).GetPaymentInstrumentListAsync( new PaymentInstrumentRequest { ClientRequestResponseType = ClientRequestResponseType.PaymentInstrument, DistributorCostCenterId = GetConfigParams().CostCentreId, DateCreated = DateTime.Now, TransactionRefId = Guid.NewGuid().ToString(), Id = Guid.NewGuid(), SubscriberId = "tel:" + DistributorSubscriberNo, paymentInstrumentType = PaymentInstrumentType.all }); var pir = response; MMoneyOptions.Clear(); var defaultOption = new PaymentInstrumentLookup { Name = GetLocalText("sl.payment.selectMmoney"), /*"--Select MMoney Option--"*/ AccountId = "-1-" }; SelectedMMoneyOption = defaultOption; MMoneyOptions.Add(defaultOption); if (pir.StatusDetail.ToLower().StartsWith("error")) { ReportPaymentInstError(pir.StatusDetail); return; } if (pir.StatusCode.ToLower().StartsWith("e")) { ReportPaymentInstError(pir.StatusDetail); return; } if (pir.PaymentInstrumentList != null) { foreach (SDPPaymentInstrument option in pir.PaymentInstrumentList) { PaymentInstrumentLookup mmo = new PaymentInstrumentLookup { Type = option.type, Name = option.name, AccountId = option.accountId ?? "" }; if (!MMoneyOptions.Any(n => n.Name == mmo.Name)) MMoneyOptions.Add(mmo); } _clientRequestResponses.Add(pir); } PaymentOptionsLoaded = true; SelectedMMoneyOption = MMoneyOptions.First(n => n.AccountId == "-1-"); } }
private void wc_UploadPaymentInstReqCompleted(object sender, UploadStringCompletedEventArgs e) { try { if (e.Error == null) { if (PaymentOptionsLoaded) return; string jsonResponse = e.Result; if (!ValidateResponse(jsonResponse)) { ReportPaymentInstError(""); return; } MMoneyOptions.Clear(); var defaultOption = new PaymentInstrumentLookup { Name = GetLocalText("sl.payment.selectMmoney"), /*"--Select MMoney Option--"*/ AccountId = "-1-" }; SelectedMMoneyOption = defaultOption; MMoneyOptions.Add(defaultOption); PaymentInstrumentResponse pir = null; if (MessageSerializer.CanDeserializeMessage(jsonResponse, out pir)) { if (pir.StatusDetail.StartsWith("error")) { ReportPaymentInstError(pir.StatusDetail); return; } if (pir.StatusCode.StartsWith("E")) { ReportPaymentInstError(pir.StatusDetail); return; } if (pir.PaymentInstrumentList != null) { foreach (SDPPaymentInstrument option in pir.PaymentInstrumentList) { PaymentInstrumentLookup mmo = new PaymentInstrumentLookup { Type = option.type, Name = option.name, AccountId = option.accountId ?? "" }; if (!MMoneyOptions.Any(n => n.Name == mmo.Name)) MMoneyOptions.Add(mmo); } } _clientRequestResponses.Add(pir); } PaymentOptionsLoaded = true; SelectedMMoneyOption = MMoneyOptions.First(n => n.AccountId == "-1-"); } else { ReportPaymentInstError(e.Error.Message); } } catch (Exception ex) { ReportPaymentInstError(ex.Message); } }