public FundAccountOTPPage(DebitAnyBankCard model, string paymentId)
 {
     InitializeComponent();
     fundModel   = model;
     paymentID   = paymentId;
     dbcOTPMOdel = new DebitAnyBankCardWithOTP();
 }
Beispiel #2
0
        private async void FundWithCard()
        {
            Device.BeginInvokeOnMainThread(async() =>
            {
                try
                {
                    Random r = new Random();
                    r.Next(1000, 9999);

                    var pd = await ProgressDialog.Show("Processing... Please Wait");

                    //string month ="", Date ="", year = "";
                    string referenceId = "00055" + DateTime.Now.ToString("yymmddHHmmss") + r.Next().ToString();

                    string mobile      = customer.PhoneNumber;
                    string convertedNo = ConvertMobile234(mobile);

                    if (expiry_year.Contains("/"))
                    {
                        expiry_year = expiry_year.ToString().Remove(2, 1);
                    }

                    var fundacct = new DebitAnyBankCard()
                    {
                        amount        = amount.ToString(),
                        currency      = "NGN",
                        customerId    = customer.Email,
                        cvv           = cvv,
                        expiry_date   = expiry_year,
                        pan           = CardPan,
                        pin           = pin,
                        Referenceid   = referenceId,
                        RequestType   = "200",
                        Translocation = GlobalStaticFields.GetUserLocation,
                        CreditAccount = AccountToFund
                    };

                    if (string.IsNullOrEmpty(fundacct.cvv))
                    {
                        MessageDialog.Show("Fund Account", "CVV is Required", DialogType.Info, "OK", null);
                        return;
                    }
                    else if (string.IsNullOrEmpty(fundacct.pan))
                    {
                        MessageDialog.Show("Fund Account", "Card Number is Required", DialogType.Info, "OK", null);
                        return;
                    }
                    else if (string.IsNullOrEmpty(fundacct.pin))
                    {
                        MessageDialog.Show("Fund Account", "Card Pin is Required", DialogType.Info, "OK", null);
                        return;
                    }
                    else if (string.IsNullOrEmpty(fundacct.expiry_date))
                    {
                        MessageDialog.Show("Fund Account", "Expiry Year and Month is Required", DialogType.Info, "OK", null);
                        return;
                    }
                    else if (string.IsNullOrEmpty(fundacct.amount.ToString()))
                    {
                        MessageDialog.Show("Fund Account", "Fund Amount is Required", DialogType.Info, "OK", null);
                        return;
                    }
                    else
                    {
                        string endpoint = "Spay/DebitAnyBankCard";
                        string url      = BaseURL + endpoint;

                        try
                        {
                            var response = await apiRequest.Post(fundacct, "", BaseURL, endpoint, "FundAccountPage", true);

                            if (response.StatusCode == HttpStatusCode.OK)
                            {
                                var jsonString = await response.Content.ReadAsStringAsync();

                                if (!jsonString.Contains("invalid"))
                                {
                                    jsonString = jsonString.JsonCleanUp();
                                    var json   = JsonConvert.DeserializeObject <FundAccountResp>(jsonString);
                                    if (json.message.ToLower().Contains("approved"))
                                    {
                                        await pd.Dismiss();
                                        Navigation.PushAsync(new Dashboard.Dashboard());
                                        MessageDialog.Show("Transaction Successful", "Transaction completed successfully.", DialogType.Success, "OK", null);
                                        await Navigation.PopAsync();
                                    }
                                    else if (json.responseCode == "T0")
                                    {
                                        await pd.Dismiss();
                                        await Navigation.PushAsync(new FundAccountOTPPage(fundacct, json.paymentId));
                                    }
                                    else if (json.responseCode == "S0")
                                    {
                                        // call method to debit visa
                                        var modelVISA = new DebitAnyBankCardVISA()
                                        {
                                            amount        = amount.ToString(),
                                            cvv           = cvv,
                                            expiry_date   = expiry_year,
                                            paymentId     = json.paymentId,
                                            eciFlag       = "07",
                                            pan           = CardPan,
                                            pin           = pin,
                                            transactionId = Utilities.GenerateReferenceId(),
                                            CreditAccount = AccountToFund
                                        };

                                        endpoint = "Spay/DebitVISAcardOnly";
                                        url      = BaseURL + endpoint;

                                        var rspVisa = await apiRequest.Post(modelVISA, "", BaseURL, endpoint, "FundAccountPage", true);

                                        if (rspVisa.StatusCode == HttpStatusCode.OK)
                                        {
                                            var respString = await rspVisa.Content.ReadAsStringAsync();
                                            respString     = respString.JsonCleanUp();

                                            var jsonVISA = JsonConvert.DeserializeObject <FundAccountResp>(respString);

                                            if (jsonVISA.message.ToLower().Contains("approved") || jsonVISA.message.ToLower().Contains("successful"))
                                            {
                                                await pd.Dismiss();
                                                Navigation.PushAsync(new Dashboard.Dashboard());
                                                MessageDialog.Show("Success", "Transaction completed successfully.", DialogType.Error, "OK", null);
                                            }
                                            else
                                            {
                                                await pd.Dismiss();
                                                MessageDialog.Show("Error", "Unable to charge your card. Please try again later", DialogType.Error, "OK", null);
                                                await BusinessLogic.Log("", "Unable to charge your card. Please try again later", "", "**SENSITIVE**", "", "FundAccountPage");
                                            }
                                        }
                                        else
                                        {
                                            await pd.Dismiss();
                                            MessageDialog.Show("Error", "Unable to charge your card. Please try again later", DialogType.Error, "OK", null);
                                            await BusinessLogic.Log("", "Unable to charge your card. Please try again later", "", "**SENSITIVE**", "", "FundAccountPage");
                                        }
                                    }
                                    else
                                    {
                                        await pd.Dismiss();
                                        MessageDialog.Show("Error", "Unable to charge your card. Please try again later", DialogType.Error, "OK", null);
                                        await BusinessLogic.Log("", "Unable to charge your card. Please try again later", "", "**SENSITIVE**", "", "FundAccountPage");
                                    }
                                }
                                else
                                {
                                    await pd.Dismiss();
                                    MessageDialog.Show("Transaction Unsuccessful", "Please verify that the card details you entered and try again.", DialogType.Error, "OK", null);
                                    await BusinessLogic.Log("", "Please verify that the card details you entered and try again.", "", "**SENSITIVE**", "", "FundAccountPage");
                                }
                            }
                            else
                            {
                                await pd.Dismiss();
                                MessageDialog.Show("Error", "Unable to connect to the server at the moment. please try again later.", DialogType.Error, "OK", null);
                                await BusinessLogic.Log("", "Unable to connect to the server at the moment. please try again later.", "", "**SENSITIVE**", "", "FundAccountPage");
                            }
                        }
                        catch (Exception ex)
                        {
                            await pd.Dismiss();
                            MessageDialog.Show("Error", "Unable to charge your card. Please try again later", DialogType.Error, "OK", null);
                            await BusinessLogic.Log(ex.ToString(), "Unable to charge your card. Please try again later", "", "**SENSITIVE**", "", "FundAccountPage");
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            });
        }