Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for nopcommerce 4.30 #223

Open
RevotecEu opened this issue Jun 11, 2020 · 67 comments
Open

Support for nopcommerce 4.30 #223

RevotecEu opened this issue Jun 11, 2020 · 67 comments

Comments

@RevotecEu
Copy link

Hi, it would be great to have the plugin working on 4.3.

  • Is there anything ongoing? It might be that we look into it.

Regards,Danny

@Sinodon
Copy link

Sinodon commented Jun 12, 2020

thanks

@madewithfire
Copy link

Hi, it would be great to have the plugin working on 4.3.

  • Is there anything ongoing? It might be that we look into it.

Regards,Danny

Added 4.3 support in this fork https://github.com/madewithfire/api-plugin-for-nopcommerce

@Sinodon
Copy link

Sinodon commented Jun 15, 2020

thank you,very much

@poyker
Copy link
Member

poyker commented Jun 16, 2020

@madewithfire Thank you for your contribution! It is much appreciated!

Let the community test it a little bit and if the feedback is positive we will merge it.

@madewithfire
Copy link

Thanks @poyker , I will come up with more updates once I get some time.

@RakeshYadvanshi
Copy link

@poyker @madewithfire any update on the 4.3 version. I am excited for 4.3

@MaximG1234
Copy link
Contributor

MaximG1234 commented Jun 28, 2020

@madewithfire Reviewing your code now and you've done a fantastic job at cleaning up the API and saved me a tremendous amount of time. Thank you!

For anyone interested it looks like this implementation is now based on tokens generated from UserIds(users/customers) in Nop where they have the Role 'Api' assigned; on first review seems sensible.

It looks like the IdentityServer dependency has been removed and replaced with Microsoft.AspNetCore.Authentication.JwtBearer which seems to make sense.

Some points for others who have a vested interest in this project.

  1. It also looks like WebHooks has been removed (which probably needed to go for now anyways).

  2. There is a bug in ProductsController > UpdateProductTags() where the code hasn't been correctly migrated.

I believe you need to replace:


foreach (var productTag in productTagsToRemove)
{
    //product.ProductTags.Remove(productTag);
    //product.ProductProductTagMappings
    //       .Remove(product.ProductProductTagMappings.FirstOrDefault(mapping => mapping.ProductTagId == productTag.Id));
    _productService.UpdateProduct(product);
}

with

this._productTagService.UpdateProductTags(product, productTagsToRemove.Select(o => o.Name).ToArray());

  1. There is also a small issue where you want to remove (or wrap in a debug) Console.WriteLine("API Call"); from the ApiStartup file because its going to have a significant performance implication.

  2. There are also some regressions with regards to localization that I can see in ManufacturerApiService > GetManufacturers().

  3. There is a bug in DTOHelper > PrepareImageDto where you have commented out the line Src = _pictureService.GetPictureUrl(picture).

  4. It also looks like you've removed Validation from the dto entities? I assume you have migrated this functionality somewhere
    else but if not this obviously isn't correct, I will need to confirm this....

  5. There are quite a number of regressions in DTOHelper for example PrepareOrderDTO() where you have omitted providing shipments.


public OrderDto PrepareOrderDTO(Order order)
{
    var orderDto = order.ToDto();

    orderDto.OrderItems = _orderService.GetOrderItems(order.Id).Select(PrepareOrderItemDTO).ToList();

    var customerDto = _customerService.GetCustomerById(order.CustomerId);

    if (customerDto != null)
    {
        orderDto.Customer = customerDto.ToOrderCustomerDto();
    }

    return orderDto;
}

should be

public OrderDto PrepareOrderDTO(Order order)
{
    var orderDto = order.ToDto();

    orderDto.OrderItems = _orderService.GetOrderItems(order.Id).Select(PrepareOrderItemDTO).ToList();
    orderDto.Shipments = _shipmentService.GetShipmentsByOrderId(order.Id).Select(PrepareShippingItemDTO).ToList();

    var customerDto = _customerApiService.GetCustomerById(order.CustomerId);

    if (customerDto != null)
    {
        orderDto.Customer = customerDto.ToOrderCustomerDto();
    }

    return orderDto;
}

I am currently working on getting my fork of this API (which has additional controllers) working and merged with @madewithfire code and properly testing everything. Perhaps we could commit all of it together at some point?

@MaximG1234
Copy link
Contributor

MaximG1234 commented Jun 28, 2020

I have completed a very rudimentary untested version which supports 4.3 resolves the issues with @madewithfire code but merges the good parts plus my additions which include PictureService and TaxCategoriesService. For anyone interested the code is here https://github.com/MaximG1234/api-plugin-for-nopcommerce.

I feel this plugin is critical to the ongoing development of the NopCommerce platform and I would really love to discuss with other interested parties about maintaining this project move actively going forward along with building more robust testing.

Anyone interested, please reach out to me!

@madewithfire
Copy link

Thanks @MaximG1234 for reviewing the code. Hope this plug in will be ready soon for 4.3 👍

@nareshyalagala
Copy link

I tried running your source @madewithfire @MaximG1234

Keep getting following error when running

TypeLoadException: Could not load type 'Microsoft.AspNetCore.Authentication.Internal.RequestPathBaseCookieBuilder' from assembly 'Microsoft.AspNetCore.Authentication, Version=3.1.5.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

Is it dotnetcore version issue ? Microsoft.AspNetCore.Authentication.JwtBearer has Microsoft.IdentityModel.Protocols.OpenIdConnect dependensy.

@MaximG1234
Copy link
Contributor

@nareshyalagala Hey mate, you should find that if you add the nuget package 'Microsoft.AspNetCore.Authentication' the project should compile successfully. I'll take a look next checkin and make sure its part of the project in future.

@nareshyalagala
Copy link

Compiling fine. But when I run the code and install plugin it wont work

@cygnet-dev
Copy link

cygnet-dev commented Jul 5, 2020

Hi, it would be great to have the plugin working on 4.3.

  • Is there anything ongoing? It might be that we look into it.

Regards,Danny

Added 4.3 support in this fork https://github.com/madewithfire/api-plugin-for-nopcommerce

This is not working with Facebook External Authentication plugin. It gives an error when you try to execute the request from other controllers except token controller.

The 'AppId' option must be provided. (Parameter 'AppId')

@MaximG1234
Copy link
Contributor

Hi, it would be great to have the plugin working on 4.3.

  • Is there anything ongoing? It might be that we look into it.

Regards,Danny

Added 4.3 support in this fork https://github.com/madewithfire/api-plugin-for-nopcommerce

This is not working with Facebook External Authentication plugin. It gives an error when you try to execute the request from other controllers except token controller.

The 'AppId' option must be provided. (Parameter 'AppId')

Hi @cygnet-dev , I've actually also run into the same problem but from the best I can tell at this stage this is actually a bug in the Facebook External Authentication plugin. Specifically it looks like regardless of the state of the Facebook Authentication Plugin (i.e. active/inactive) it disregards this value and intercepts requests in the pipeline regardless. For me it was sufficient to simply disable facebook authentication however if you require it it may be necessary to set the AppId parameter for the Authentication plugin prior to using the API.

@nareshyalagala Unfortunately at this stage I cant provide you further input beyond the source code I have provided, based on my testing the code currently checked in does work successfully (kinda). I am still working on this code and expect that I will have further updates in the coming days.

@MaximG1234
Copy link
Contributor

MaximG1234 commented Jul 9, 2020

Hi everyone, I've just checked in a version @ https://github.com/MaximG1234/api-plugin-for-nopcommerce that is somewhat tested. I'd still consider this nowhere near ready for production but the API major functionality mostly works.

It seems I have also discovered a minor limitation in LinqToDB (used by Nop for data access now) itself which limits some operations that are performed by the API. Specifically LinqToDb cannot perform GroupBy without materializing objects. This means there is going to be a performance and memory impact when querying customers or other operations that require grouping.

In particular this affected the Customer Controller which I have rewritten and simplified but now materializes in memory. I imagine there are some way to improve/work around these issues and I'll revisit them soon.

I have successfully got the following unit tests passed.
Capture

@tramtri
Copy link

tramtri commented Jul 25, 2020

@MaximG1234

Thank you for your contributor.

Can you tell me how to add Swagger into Api plugin? I tried but I just got only one /Token endpoint displaying on the Swagger page. I don't understand why is that. One point I figure out that TokenController is the one not inherit BaseApiController.

Any suggestion will be greatly appreciate.

Thank you in advance.

@Mohammedsalah19
Copy link

I have completed a very rudimentary untested version which supports 4.3 resolves the issues with @madewithfire code but merges the good parts plus my additions which include PictureService and TaxCategoriesService. For anyone interested the code is here https://github.com/MaximG1234/api-plugin-for-nopcommerce.

I feel this plugin is critical to the ongoing development of the NopCommerce platform and I would really love to discuss with other interested parties about maintaining this project move actively going forward along with building more robust testing.

Anyone interested, please reach out to me!

@MaximG1234 after installed plugin it throw this error :
ArgumentException: The 'AppId' option must be provided. (Parameter 'AppId')

Screenshot (106)

@MichaelNZ85
Copy link

@MaximG1234 Do you have a compiled version of the plugin available for fast deployment?

@andrejpk
Copy link

andrejpk commented Sep 1, 2020

@MaximG1234 , you mentioned:

  1. It also looks like WebHooks has been removed (which probably needed to go for now anyways).

That's a tough pill to swallow. Can you elaborate on why? (I use webhooks in backend order flow/automation.)

@Nickman87
Copy link

@MaximG1234 and @madewithfire Thanks for the awesome work in updating this plugin!

I'm trying to get it up and running so I can start testing it out on my setup, but I cannot find the correct authentication information.
It seems everything has been switched to JWT tokens, which is fine, but how do I configure them? Do I need to add a SecurityKey in my appsettings.json? And is it enough to add that same key into an Authorization header prefixed with Bearer ? Or how do I generate the necessary token for authentication?

Thanks again!

@madewithfire
Copy link

@Nickman87, To generate the token, you can use nopcommerce's credentials. After getting the token, pass it with "Bearer" in header. You also need to assign ApiUser role to the user.

@praveenatherese
Copy link

How can i configure route? I was able to download api plugin from https://github.com/MaximG1234/api-plugin-for-nopcommerce.

tried posting https://localhost:44316/Api/api/login
{
"email":"[email protected]",
"password":"******"
}

but response was HTML response
Your store. Page not found

@sg2707
Copy link

sg2707 commented Sep 21, 2020

How can i configure route? I was able to download api plugin from https://github.com/MaximG1234/api-plugin-for-nopcommerce.

tried posting https://localhost:44316/Api/api/login
{
"email":"[email protected]",
"password":"******"
}

but response was HTML response
Your store. Page not found

http://localhost/...../api/token
in body use form-data then pass your NOP commerce username and password. Make sure user have the role 'API Users'

@paul01su
Copy link

paul01su commented Oct 1, 2020

Hi everyone, Im new with the nopcommerce, i tried to add this plugin manually, but i dont know how to access the plugin UI in the admin, i cant see it and maybe the nopcommerce is not detecting the plugin as installed, so, how can i do that?
Thanks

@Prateek58
Copy link

Hi,
Got the Token successfully, but other post and get methods not working when pass Bearer token as Authentication header in getting 403 forbidden error. super privileges' (777)are provided to published code directory but still not able to use.. please help..

@zakaryaasadi
Copy link

Hi everyone, Im new with the nopcommerce, i tried to add this plugin manually, but i dont know how to access the plugin UI in the admin, i cant see it and maybe the nopcommerce is not detecting the plugin as installed, so, how can i do that?
Thanks

Hi

Please follow me:

  • Download the code Api plugin v4.3 from this link https://github.com/zakaryaasadi/api_for_nopcommerce

  • Open file .zip and copy folder Nop.Plugin.Api to path -> {your NopCommerce solution}\Plugins

  • Go to visual studio from tab ( View -> Solution Explorer )

  • Right click on Plugins Folder -> Add -> Existing Project... -> Open file from path {your NopCommerce solution}\Plugins\Nop.Plugin.Api\Nop.Plugin.Api.csproj

  • From Solution Explorer , right click on Nop.Plugin.Api and click on Rebuild.

  • Now, press ctrl + F5 to start without debugging

  • Now, you can access the plugin UI in the admin -> Configuration -> Local plugins, then install Web Api plugin

  • Documentation from link https://github.com/SevenSpikes/api-plugin-for-nopcommerce

I apologize because my english is not good :)

@nakamoto9999
Copy link

Hi @MaximG1234,
I implemented your 4.30 API plugin, but I can´t get success in the use.
Take a look:

  1. I started to get access token using
    http://mysite/api/[email protected]&password=xxx

It´s looks like working fine, I can get the access_token in a response json like this:

{"access_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOiIxNjA3NDM0MTI5IiwiZXhwIjoiMTkyMjc5NDEyOSIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL2VtYWlsYWRkcmVzcyI6Im5ha2Ftb3RvQG5ldGZhc2hpb24uY29tLmJyIiwiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwNS8wNS9pZGVudGl0eS9jbGFpbXMvbmFtZWlkZW50aWZpZXIiOiJhMTRjZTNjMS04YTFmLTQ4MGQtYTE2YS0zMmY2MWIxZWFhZTgiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoibmFrYW1vdG9AbmV0ZmFzaGlvbi5jb20uYnIifQ.RYFhlSjzHjOMNM7qdgYobjyhuvwlDAjGP4GTwklbMdc","token_type":"Bearer","expires_in":1922794129,"error_description":null}

But when i try to use the access token in any API transaction, like:
http://mysite/api/products/count?access_token=eyJ......Mdc

I am getting the message:

"User authenticated but not in Api Role."

By the way, the user I used in step 1 is assigned to role "API User" in my web site

Where am I doing any mistake??

Thanks.

@Prateek58
Copy link

Prateek58 commented Dec 9, 2020 via email

@nakamoto9999
Copy link

Hi @Prateek58 ,
Thanks for your response.

I changed the Customer Role Name to "API_User" (the System Name is "ApiUserRole") but the result remains the same.
I realized that, even if I don't put access_token when requesting any services in the API, ( http://mysite/api/products/count for instance) the answer is always the same:
"User authenticated but not in Api Role."

Finally, which of these API solutions are you using?
https://github.com/madewithfire/api-plugin-for-nopcommerce
https://github.com/MaximG1234/api-plugin-for-nopcommerce
https://github.com/zakaryaasadi/api_for_nopcommerce
https://github.com/toddca/api-plugin-for-nopcommerce/tree/nopCommerce_4.30

All of these plugins are support 4.30 .

Regards.

@PoirkhitSaikia
Copy link

Hi @Prateek58 ,
Thanks for your response.

I changed the Customer Role Name to "API_User" (the System Name is "ApiUserRole") but the result remains the same.
I realized that, even if I don't put access_token when requesting any services in the API, ( http://mysite/api/products/count for instance) the answer is always the same:
"User authenticated but not in Api Role."

Finally, which of these API solutions are you using?
https://github.com/madewithfire/api-plugin-for-nopcommerce
https://github.com/MaximG1234/api-plugin-for-nopcommerce
https://github.com/zakaryaasadi/api_for_nopcommerce
https://github.com/toddca/api-plugin-for-nopcommerce/tree/nopCommerce_4.30

All of these plugins are support 4.30 .

Regards.

Hi @nakamoto9999

I also got the same issue but I applied the apiuser role in this section. Please follow the image as I have listed out the steps required. If this works than give a thumbs up.

Image Link: https://ibb.co/zFMg6Xm
Screenshot (1195)

@Prateek58
Copy link

Prateek58 commented Dec 10, 2020 via email

@nakamoto9999
Copy link

Hi @Prateek58 ,
It´s working now ! Tahe a look at response of Postman panel...

image

I already pushed the thumbs up. You gave me a great Christmas gift !!
Regards.

@Prateek58
Copy link

Prateek58 commented Dec 11, 2020 via email

@jakubmaguza
Copy link

I have completed a very rudimentary untested version which supports 4.3 resolves the issues with @madewithfire code but merges the good parts plus my additions which include PictureService and TaxCategoriesService. For anyone interested the code is here https://github.com/MaximG1234/api-plugin-for-nopcommerce.
I feel this plugin is critical to the ongoing development of the NopCommerce platform and I would really love to discuss with other interested parties about maintaining this project move actively going forward along with building more robust testing.
Anyone interested, please reach out to me!

@MaximG1234 after installed plugin it throw this error :
ArgumentException: The 'AppId' option must be provided. (Parameter 'AppId')

Screenshot (106)

Go to Facebook Auth plugin, and put random (or real if you are using it) data there.

@PoirkhitSaikia
Copy link

Hello Developers,

Can anyone let me know where I will get full API list for version 4.2? Most of the APIs are not available in github. How to progress like this?

@dinukasal
Copy link

dinukasal commented Jan 1, 2021

Hello, I implemented TopicController in this apiplugin for nop 4.3 https://github.com/madewithfire/api-plugin-for-nopcommerce
TopicController was Implemented as they have implemented other controllers But it gives this error,
AutoMapper.AutoMapperMappingException: 'Missing type map configuration or unsupported mapping.'
image

Any idea to fix this?
@madewithfire

These new changes are in this repo https://github.com/Red-Transact/api-plugin-for-nopcommerce

PS: @madewithfire You need to create a new branch for 4.3 still its nopCommerce_4.20 :)

@dinukasal
Copy link

Fixed above issue by adding CreateMap<Topic,TopicDto>(); to ApiMapperConfiguration

@ExzaSolutions
Copy link

Hi , I got stuck with this AppId problem on the api calls,
I just unistalled the FaceBook plugin and then it worked ,no more Missing AppId error

@trevorscottprice
Copy link

trevorscottprice commented Jan 27, 2021

Any consensus on which of these forks is best? I've tried a number of them but it that none of them have a complete features for "customer search", "checkout", or "add new customer address".

@vivekanand199110
Copy link

Hi everyone, I'm new with the nopcommerce, I tried to add this plugin manually in my local machine, but could not do it.

Even tried with steps as well:
#223 (comment)
it's showing errors don't know where I am going wrong.

How can we use postman for API integrations with Nopcommerce, any suggestions or links?

Which of these API solutions are best to use
https://github.com/madewithfire/api-plugin-for-nopcommerce
https://github.com/MaximG1234/api-plugin-for-nopcommerce
https://github.com/zakaryaasadi/api_for_nopcommerce
https://github.com/toddca/api-plugin-for-nopcommerce/tree/nopCommerce_4.30

All of these plugins are support 4.30?

Thanks

1 similar comment
@vivekanand199110
Copy link

Hi everyone, I'm new with the nopcommerce, I tried to add this plugin manually in my local machine, but could not do it.

Even tried with steps as well:
#223 (comment)
it's showing errors don't know where I am going wrong.

How can we use postman for API integrations with Nopcommerce, any suggestions or links?

Which of these API solutions are best to use
https://github.com/madewithfire/api-plugin-for-nopcommerce
https://github.com/MaximG1234/api-plugin-for-nopcommerce
https://github.com/zakaryaasadi/api_for_nopcommerce
https://github.com/toddca/api-plugin-for-nopcommerce/tree/nopCommerce_4.30

All of these plugins are support 4.30?

Thanks

@ibrahimdevs
Copy link

ibrahimdevs commented Mar 2, 2021

Hey @poyker and @MaximG1234 ,

Thanks for great plugin, I also know that it is free plugin. But if you can update it for 4.30, both community and also paid customers will appreciate it. (I'm also one your paid customer for your other products.)

I also noticed there is 4.30-beta branch , when do you plan to make it ready for production?
https://github.com/SevenSpikes/api-plugin-for-nopcommerce/tree/nopCommerce_4.30_Beta

Thanks,

@andrejpk
Copy link

andrejpk commented Mar 2, 2021

Split this into a new issue

#246

@amzr0987
Copy link

amzr0987 commented Mar 6, 2021

Thanks for great plugin and helping community....
After 3.90 there are major changes in overall framework of Nop-Commerce. Now it is 4.40 beta.
Anyone successfully upgraded to for NC 4.40 beta?
Please share repository links.
Thanks

@codeiskool
Copy link

Can we please get some consensus on the which of the multiple repos out there we can use?

@andrejpk
Copy link

Agree.. we need a community fork. I'd think about choosing a set of maintainers to start a new community fork. Otherwise we'll run into the same issues on someone else's fork.

@brian-lagerman
Copy link

Agree.. we need a community fork. I'd think about choosing a set of maintainers to start a new community fork. Otherwise we'll run into the same issues on someone else's fork.

Disagree, but only due to recent developments. There's a new milestone attached to nopCommerce 4.5 to include Web API support natively in the core product. This was hanging around as an open issue there, but it now appears to be getting traction.

I can only assume that the efforts of anyone looking to contribute would be better served by helping and advancing over there, as this plugin will almost certainly become redundant if that milestone gets completed. I for one would prefer to work on a fork of the core, as there will likely be better testing. Admittedly, that could push completion down the road a bit though.

Web API Support

@poyker
Copy link
Member

poyker commented Mar 22, 2021

Hi guys,

There is already a 4.3 Beta branch based on the contributed code here.

@amzr0987
Copy link

amzr0987 commented Mar 24, 2021

Thanks for great free plugin, But if any one can update it for 4.40 and share, we in nopcommerce community, all will appreciate.

@jakubmaguza
Copy link

Go ahead, it's not that hard. You need to take one of 4.3 forks and change all methods to async await.

It's not hard to do, but it's very time consuming.

Nop says they will introduce their own api with 4.5

@amzr0987
Copy link

I did it previously, with few api calls of customer only. However unlucky, there were runtime issues.
could any one please take all necessary infrastructure, plugin related classes. And only customer related calls to test NC 4.40 compatibility.

@stepanbenes
Copy link

@amzr0987 Check out my fork at https://github.com/stepanbenes/api-for-nopcommerce. I have done most of the work to update it for 4.40. Mainly change all methods to their async alternatives. Some work still needs to be done, so feel free to contribute.

@amzr0987
Copy link

Thanks Stepanbenes for upgraded to NC 4.40,
Now could you please help in how to test this call in localhost (development) environment.

@amzr0987
Copy link

Thanks Stepanbenes for upgraded to NC 4.40,
Forgot to mention I installed plugin, able to see configuration.
Now could you please help in how to test this call in localhost (development) environment.

@stepanbenes
Copy link

@amzr0987 I have updated the readme file to describe how to install the plugin. You can test the api in localhost using swagger UI page (/api/swagger). Currently, there is no client application for testing implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests