Ejemplo n.º 1
0
        public static async Task <SlydePayPaymentStatusResponse> CancelSlydePayTransaction(EntityTypes entityType, IStakeType stakeType, SlydePayApiSettingsDTO slydePayApiSettings)
        {
            try
            {
                SlydePayCreateInvoiceRequest request = new SlydePayCreateInvoiceRequest
                {
                    EmailOrMobileNumber = slydePayApiSettings.MerchantEmail,
                    MerchantKey         = slydePayApiSettings.Merchantkey,
                    OrderCode           = stakeType.TxRef
                };

                var httpClient = new HttpClient();


                var data = JsonConvert.SerializeObject(request, new JsonSerializerSettings {
                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                });
                var stringContent = new StringContent(data);
                stringContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                var responseMessage = await httpClient.PostAsync("https://app.slydepay.com.gh/api/merchant/transaction/cancel", stringContent);

                var contentString = await responseMessage.Content.ReadAsStringAsync();

                SlydePayPaymentStatusResponse response = JsonConvert.DeserializeObject <SlydePayPaymentStatusResponse>(contentString);

                return(response);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"GenerateSlydePayToken {ex.Message}");
                return(null);
            }
        }
Ejemplo n.º 2
0
        private static async Task <string> GenerateAndSendSlydePayInvoice(EntityTypes entityType, IStakeType stakeType, SlydePayApiSettingsDTO slydePayApiSettings, string PayOption, string MomoNumber = null, string email = null)
        {
            string customerMobileNumber = MomoNumber ?? stakeType.User.PhoneNumber;
            string customerEmail        = email == "default" ? stakeType.User.Email : email;

            try
            {
                SlydePayOrderItem item = new SlydePayOrderItem();
                item.ItemCode  = stakeType.Id.ToString();
                item.ItemName  = $"{entityType.ToString()} Investment";
                item.Quantity  = 1;
                item.SubTotal  = stakeType.Amount;
                item.UnitPrice = stakeType.Amount;

                SlydePayOrderItem[] items = { item };

                SlydePayCreateInvoiceRequest request = new SlydePayCreateInvoiceRequest
                {
                    EmailOrMobileNumber = slydePayApiSettings.MerchantEmail,
                    MerchantKey         = slydePayApiSettings.Merchantkey,
                    Amount               = stakeType.Amount,
                    OrderCode            = stakeType.TxRef,
                    OrderItems           = items,
                    SendInvoice          = true,
                    PayOption            = PayOption,
                    CustomerName         = stakeType.User.FirstName + " " + stakeType.User.FirstName,
                    CustomerEmail        = customerEmail,
                    CustomerMobileNumber = customerMobileNumber
                };

                var httpClient = new HttpClient();


                var data = JsonConvert.SerializeObject(request, new JsonSerializerSettings {
                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                });
                var stringContent = new StringContent(data);
                stringContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                var responseMessage = await httpClient.PostAsync("https://app.slydepay.com.gh/api/merchant/invoice/create", stringContent);

                var contentString = await responseMessage.Content.ReadAsStringAsync();

                SlydePayCreateInvoiceResponse response = JsonConvert.DeserializeObject <SlydePayCreateInvoiceResponse>(contentString);

                return(response.result.payToken);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"GenerateSlydePayToken {ex.Message}");
                return(null);
            }
        }
Ejemplo n.º 3
0
 public static async Task <string> GenerateAndSendSlydePayAnkasaInvoice(EntityTypes entityType, IStakeType stakeType, SlydePayApiSettingsDTO slydePayApiSettings)
 {
     return(await GenerateAndSendSlydePayInvoice(entityType, stakeType, slydePayApiSettings, "SLYDEPAY"));
 }
Ejemplo n.º 4
0
 public static async Task <string> GenerateAndSendSlydePayCardInvoice(EntityTypes entityType, IStakeType stakeType, SlydePayApiSettingsDTO slydePayApiSettings, string email)
 {
     return(await GenerateAndSendSlydePayInvoice(entityType, stakeType, slydePayApiSettings, "VISA", null, email));
 }
Ejemplo n.º 5
0
        public static async Task <string> GenerateAndSendSlydePayMomoInvoice(EntityTypes entityType, IStakeType stakeType, SlydePayApiSettingsDTO slydePayApiSettings, string MomoNumber)
        {
            if (string.IsNullOrEmpty(MomoNumber))
            {
                return(null);
            }

            return(await GenerateAndSendSlydePayInvoice(entityType, stakeType, slydePayApiSettings, getSlydePayOption(MomoNumber), MomoNumber));
        }
Ejemplo n.º 6
0
        public static async Task <string> GenerateSlydePayToken(EntityTypes entityType, IStakeType stakeType, SlydePayApiSettingsDTO slydePayApiSettings)
        {
            try
            {
                SlydePayOrderItem item = new SlydePayOrderItem();
                item.ItemCode  = stakeType.Id.ToString();
                item.ItemName  = $"{entityType.ToString()} Investment";
                item.Quantity  = 1;
                item.SubTotal  = stakeType.Amount;
                item.UnitPrice = stakeType.Amount;

                SlydePayOrderItem[] items = { item };

                SlydePayCreateInvoiceRequest request = new SlydePayCreateInvoiceRequest
                {
                    EmailOrMobileNumber = slydePayApiSettings.MerchantEmail,
                    MerchantKey         = slydePayApiSettings.Merchantkey,
                    Amount     = stakeType.Amount,
                    OrderCode  = stakeType.TxRef,
                    OrderItems = items
                };

                //PayliveConnector connector = new PayliveConnector(slydePayApiSettings.ApiVersion, slydePayApiSettings.MerchantEmail, slydePayApiSettings.Merchantkey, slydePayApiSettings.ServiceType, slydePayApiSettings.IntegrationMode);

                var httpClient = new HttpClient();


                var data = JsonConvert.SerializeObject(request, new JsonSerializerSettings {
                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                });
                var stringContent = new StringContent(data);
                stringContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                var responseMessage = await httpClient.PostAsync("https://app.slydepay.com.gh/api/merchant/invoice/create", stringContent);

                var contentString = await responseMessage.Content.ReadAsStringAsync();

                SlydePayCreateInvoiceResponse response = JsonConvert.DeserializeObject <SlydePayCreateInvoiceResponse>(contentString);

                return(response.result.payToken);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"GenerateSlydePayToken {ex.Message}");
                return(null);
            }
        }