Inhalte aufrufen

Profilbild

Smartstore Error


29 Antworten zu diesem Thema

#21 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3162 Beiträge

Geschrieben: 19 February 2018 - 19:55

Try
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
before your WebRequest/HttpWebRequest. Example.

Schöne Grüße aus Düsseldorf,
Marcus Gesing


#22 Olamide

Olamide

    Member

  • Members
  • 21 Beiträge

Geschrieben: 19 February 2018 - 20:06

Hello, I really appreciate your effort, I actually did that in my code before making the request as shown below:

 

I noticed that is not reaching the log line in bold

 

PLEASE NOTE THAT THE METHOD IS AN ASYNCHRONOUS METHOD WHICH IS BEING CALLED IN A SYNCHRONOUS METHOD I.E. PostProcessPayment METHOD

 

public async Task GetPayStackPaymentReferenceUrl(PayStackSettings settings,Core.Domain.Customers.Customer customer,string amount, string reference,string callbackurl,int storeid)
{
try
{
 
var model = new PaystackStandardModel
{
amount = amount,
email =customer.Email,
reference = reference,
callback_url = callbackurl,
metadata = new Metadata
{
custom_fields = new Custom_Fields[]
   {
new Custom_Fields{display_name = "Store Id",variable_name="store_id",value=storeid.ToString()},
new Custom_Fields{display_name = "Customer Guid",variable_name="customer_guid",value=customer.CustomerGuid.ToString()}
   }
}
};
using (var client = new HttpClient())
{
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
_logger.Info("settings.PayStackApiUrl: " + settings.PayStackApiUrl);
client.BaseAddress = new Uri(settings.PayStackApiUrl);
 
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", settings.SecretKey);
var jsonObj = JsonConvert.SerializeObject(model);
_logger.Info("jsonObj: " + jsonObj);
var stringContent = new StringContent(jsonObj, System.Text.Encoding.UTF8, "application/json");
 
var result = await client.PostAsync("transaction/initialize", stringContent);
var content = await result.Content.ReadAsStringAsync();
_logger.Info("paystackResponse: " + content);
var paystackResponse = JsonConvert.DeserializeObject<PaystackResponse>(content);
 
if (paystackResponse.status)
{
paystackpaymentUrl = paystackResponse.data.authorization_url;
_logger.Info("paystackpaymentUrl: " + paystackpaymentUrl);
// return paystackResponse.data.authorization_url;
}
//return "";
}
}
catch (Exception ex)
{
_logger.Error(ex,ex.Message);
//return "";
}
 
thanks


#23 Murat Cakir

Murat Cakir

    SmartStore AG

  • Administrators
  • 1053 Beiträge

Geschrieben: 19 February 2018 - 21:55

And where and how gets GetPayStackPaymentReferenceUrl() called? You either...

  • ...must await for the method to complete, or
  • ...wrap your function call in Task.Run(...), or
  • ...use our AsyncRunner.RunSync() wrapper to call your method, or
  • ...just don't do async stuff  ;)

Murat Cakir
SmartStore AG


#24 Olamide

Olamide

    Member

  • Members
  • 21 Beiträge

Geschrieben: 19 February 2018 - 23:08

Hello,

 

Thanks for the feedback, i removed the async implementation and it worked, it is now redirecting to the payment gateway.

 

But i have another issue, it requires a callback url to be specified, i followed the method in paypal implementation which is

_services.WebHelper.GetStoreLocation(store.SslEnabled) + "Plugins/SmartStore.PayStack/PayStack/ConfirmPayment";

 

but didn't work

 

How can i generate a callback url with the following details:

Controller name: PayStackController

actionName: ConfirmPayment

 

This is my RouteProvider implementation

 

public void RegisterRoutes(RouteCollection routes)
{
routes.MapRoute("SmartStore.PayStack",
"Plugins/SmartStore.PayStack/{action}",
new { controller = "PayStack" },
new[] { "SmartStore.PayStack.Controllers" }
)
.DataTokens["area"] = "SmartStore.PayStack";
}
 
Thanks


#25 Olamide

Olamide

    Member

  • Members
  • 21 Beiträge

Geschrieben: 20 February 2018 - 00:01

Hello,

 

I have corrected the error, it actually from my Routeprovider, i didn't specify the controller part of the url in the routes.MapRoute method.

 

The payment gateway is now working fine.

 

But i noticed something, while i was still designing the payment gateway, if an error occurred in the PostProcessPayment override method where the redirection takes place, the cart items are empty and the customer won't see any item in the basket also when i check the dashboard, i see it as pending payment, how can i prevent this, I mean if error occurs in the PostProcessPayment, i want to preserve the items in the cart and not mark it as pending payment.

 

Thanks



#26 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3162 Beiträge

Geschrieben: 20 February 2018 - 10:43

You cannot prevent pending payment status because it's the initial status. It's the correct status in case of an error in PostProcessPayment. PostProcessPayment and URL redirecting take place after the order has been placed, i.e. the shopping cart is always empty at this point, regardless of whether an error occured or not. However you can implement and override CanRePostProcessPayment method. That allows the buyer to initiate the payment redirecting again from his frontend order page.
 
Theoretical, if you don't want to accept an order in case of a payment error, you would have to redirect in the checkout. However, there is a danger that money will be collected for which there is no order at all (should be avoided under all circumstances).

Schöne Grüße aus Düsseldorf,
Marcus Gesing


#27 Olamide

Olamide

    Member

  • Members
  • 21 Beiträge

Geschrieben: 20 February 2018 - 11:12

Hello Marcus,

 

You have being of great help to me, thanks a lot. The payment plugin is now working as required. Really appreciate your effort.

 

But please i need some few things:

 

1. is it possible to customize the products by adding suppliers with their respective account numbers so that when payments are made using the plugin, they are created directly.

2. How can i design a custom module for the site, i need a chat module to integrate with it and i want to create it and install on the site.

 

 

Thanks



#28 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3162 Beiträge

Geschrieben: 20 February 2018 - 15:34

1. No, not out of the box.
2. That depends on details. You can use a widget for the chat UI and inject it in the frontend through the plugin.

Schöne Grüße aus Düsseldorf,
Marcus Gesing


#29 Olamide

Olamide

    Member

  • Members
  • 21 Beiträge

Geschrieben: 21 February 2018 - 07:09

Hello Marcus,

 

Thanks for the reply.

 

Since it's not possible out of the box, perhaps it could be possible in the paid version.

 

Also can i add custom properties when registering a product.

 

Thanks



#30 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3162 Beiträge

Geschrieben: 21 February 2018 - 13:17

You can use SyncMapping.


Schöne Grüße aus Düsseldorf,
Marcus Gesing




Auf dieses Thema antworten