Pagseguro . Net Core Problem with . xml

Asked

Viewed 338 times

0

I am implementing the payment with Pagseguro, however I am having problem in the execution of the following line:

const bool isSandbox = true;
EnvironmentConfiguration.ChangeEnvironment(isSandbox);

While doing some research I found that I had not added the folder with .xml calling for Configuration/Pagseguroconfig.xml so I included them in the main project. But I’m still getting the message that I couldn’t find the xml.

I think it is necessary to do a validation of the read path located in Uol.Pagseguro/Resources/Pagseguroconfiguration.Cs, where right at the beginning I have:

private static string urlXmlConfiguration = ".../.../Configuration/PagSeguroConfig.xml";

In some were found that this was necessary to change so that it was directed to the root of the project leaving so:

private static string urlXmlConfiguration = HttpRuntime.AppDomainAppPath + "PagSeguroConfig.xml";

But I’m unable to use Httpruntime within the . aspnet Core Standard project. How can I be working around this problem?

  • Eluander in the Pagseguro documentation is specified where the path should be?

  • @Leonardobonetti, According to the documentation may be on my way, but I am not able to make this path be found in the core... https://pagseguro.uol.com.br/v2/guia-de-integracao/documentaca-da-biblioteca-pagseguro-network.html#Pagseguroconfiguration

  • Can you do that? private Static string urlXmlConfiguration = System.IO.Path.Combine(Appcontext.Basedirectory, "Pagseguroconfig.xml");

  • @Rafael I tried to use the one you gave me, but there is no reference to Appcontext

  • Look, I don’t think there’s any support for the. NET Core, however, a person performed a pull request with this support: https://github.com/pagseguro/pagseguro-sdk-dotnet/pull/18/files#, if this is the case you may "embed" the xml inside the Assembly and modify the code you load inside that class, maybe resolve partially, I’ll try to download the sdk and take a test here later.

  • @Rafael I was able to find out why there was no reference to Appcontext, it was because the library I imported was in 4.5 and the rest is in . core 2.1. I modified the class library for the core so Appcontext was found... after doing some tests. The Url that is now returning is "C: Users Eluander Documents Developer Pagsupera src Pag.Core.Api bin Debug netcoreapp2.1 Pagseguroconfig.xml" and so continues the xml error...

  • Browse that folder and find where it is and fix the Path.

Show 2 more comments

1 answer

2


I did an ASP.NET Core project and added the UOL.Pagseguro project, I made the following modifications:

In the UOL.Pagseguro project I modified the urlXmlConfiguration for:

 private static string urlXmlConfiguration = "Config/PagSeguroConfig.xml";

In the ASP.NET Core project I added the Config folder and inside it the PagSeguroConfig.xml:

inserir a descrição da imagem aqui

I modified the property copy to output Directory/Copy to Output Directory file . xml for it to be copied next to the Assembly folder when it is published:

inserir a descrição da imagem aqui

I made an action that loads and returns the credentials data and put a link in the menu to test:

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

I added the source code to GITHUB:

https://github.com/superrfm/aspnetcorepagseguro

  • Perfect! Worked 100%! Thanks for Sharing!

  • This project Uol.PagSeguro https://github.com/superrfm/aspnetcorepagseguro/tree/master/Uol.PagSeguro is a copy of the Pagserguro lib or what?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.