Beispiel #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);
            }
        }
Beispiel #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);
            }
        }
Beispiel #3
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);
            }
        }