Search REST API List: Magento 2 API List of Product Search Endpoint

Here I am giving you a complete list of all the search REST API list or product filtering REST APIs inside Magento 2.

This will give you easy access to the API collection in one place.

Search REST API in Magento 2

You can easily do this list of APIs together and when you create a mobile application, it will be very convenient to filter any kind of data.

Within this API list, you will find all the details of how to filter any product by category ID or search, how to remove the collection, in the list given below.

If you want information in detail, then by clicking on the related link given below, you can go to another page, where its complete detail with example is given.

 

Magento 2 List of All Search REST API

When you will go to another page by clicking on that link, there you have to use what methods, which token to use in authorization, what should be the body content type you will get.

1. Product Search REST API for Search And Filter

https://wishusucess.com/rest/V1/categories/115/products

2. Quick Searches REST API in Magento 2

https://wishusucess.com/rest/default/V1/search?searchCriteria[requestName]=quick_search_container&searchCriteria[filter_groups][0][filters][0][field]=search_term&searchCriteria[filter_groups][0][filters][0][value]=iphone

3. Advanced Search Container Magento 2 REST API

https://wishusucess.com/rest/default/V1/search?searchCriteria[requestName]=advanced_search_container&searchCriteria[filter_groups][0][filters][0][field]=price.from&searchCriteria[filter_groups][0][filters][0][value]=200&searchCriteria[filter_groups][0][filters][1][field]=price.to&searchCriteria[filter_groups][0][filters][1][value]=500

4. Gets Products Where The SKU Search in Magento 2 REST API

https://wishusucess.com/rest/default/V1/search?searchCriteria[requestName]=advanced_search_container&searchCriteria[filter_groups][0][filters][0][field]=sku&searchCriteria[filter_groups][0][filters][0][value]=Accessoires1278&searchCriteria[filter_groups][0][filters][0][condition_type]=like

5. Product Filter Using Price And SKU in Magento 2 REST API

https://wishusucess.com/rest/V1/products?searchCriteria[filter_groups][0][filters][0][field]=sku&searchCriteria[filter_groups][0][filters][0][value]=Coquefhoih72389&searchCriteria[filter_groups][0][filters][0][condition_type]=like&searchCriteria[filter_groups][0][filters][1][field]=sku&searchCriteria[filter_groups][0][filters][1][value]=Coque12345&searchCriteria[filter_groups][0][filters][1][condition_type]=like&searchCriteria[filter_groups][1][filters][0][field]=price&searchCriteria[filter_groups][1][filters][0][value]=400&searchCriteria[filter_groups][1][filters][0][condition_type]=from&searchCriteria[filter_groups][2][filters][0][field]=price&searchCriteria[filter_groups][2][filters][0][value]=600&searchCriteria[filter_groups][2][filters][0][condition_type]=to

6. A Simple Search Using an in Conditions Type

https://wishusucess.com/rest/default/V1/products?searchCriteria[filter_groups][0][filters][0][field]=name&searchCriteria[filter_groups][0][filters][0][value]=Coque Carbone et Effet Brossé Silicone à Coins Renforcés&searchCriteria[filter_groups][0][filters][0][condition_type]=like&searchCriteria[filter_groups][0][filters][1][field]=name&searchCriteria[filter_groups][0][filters][1][value]=Accessoires Apple iPhone&searchCriteria[filter_groups][0][filters][1][condition_type]=like

7. Logical and Condition Search REST API Magento 2

https://wishusucess.com/rest/default/V1/products?searchCriteria[filter_groups][0][filters][0][field]=sku&searchCriteria[filter_groups][0][filters][0][value]=Accessoires1278&searchCriteria[filter_groups][0][filters][0][condition_type]=like&searchCriteria[filter_groups][1][filters][0][field]=price&searchCriteria[filter_groups][1][filters][0][value]=2500&searchCriteria[filter_groups][1][filters][0][condition_type]=lt

8. Magento 2 Logical AND and OR Search REST API

https://wishusucess.com/rest/default/V1/products?searchCriteria[filter_groups][0][filters][0][field]=sku&searchCriteria[filter_groups][0][filters][0][value]=Accessoires1278&searchCriteria[filter_groups][0][filters][0][condition_type]=like&searchCriteria[filter_groups][0][filters][1][field]=sku&searchCriteria[filter_groups][0][filters][1][value]=Coquefhoih72389&searchCriteria[filter_groups][0][filters][1][condition_type]=like&searchCriteria[filter_groups][1][filters][0][field]=price&searchCriteria[filter_groups][1][filters][0][value]=200&searchCriteria[filter_groups][1][filters][0][condition_type]=from&searchCriteria[filter_groups][2][filters][0][field]=price&searchCriteria[filter_groups][2][filters][0][value]=600&searchCriteria[filter_groups][2][filters][0][condition_type]=to

 

If you need any kind of help in Magento 2 store development then you can mail or message us or call us immediately, we will try our best to help you in every way from development.

If any query is also related to mobile application development or creating a store using the Magento framework and facing any problem, you can take help from us.

 

Recommended Posts:

Magento 2.4 Installation Guide: How to Install Magento 2.4.2

Magento Store: Best 36 Magento Website Examples in The World

How to Call CMS Block Page in PHTML File in Magento 2

In this block, I am showing you how to call the cms block page inside Magento 2.

Whenever we customize the theme or create a new website, at that time we often need to show the content of the block page inside our p file.

Often we call CMS static block to display better data on the frontend.

Many times through CMS block we add slider image, banner image, or sometimes some special product, sales promotions, return policies, etc., and to call it in many places, we call that block in phtml file.

I am telling you step by step method how you can show data by calling the block page in a PHTML file.

Call CMS Block Page in PHTML

Before You Call Block Page in Magento 2 website you must have that block page.

To create a new block page, you can create a new blog by going inside the admin content.

Then you can decide its identifier yourself if you want and you can use that identifier wherever you want to call it.

 

Create Static Block Page in Magento 2

Login to Magento 2

Admin > Content > Block > Add New Block

Enable Block: When you enable the block, then the content is visible; if you disable it, the content is disabled

Block Title: The title of the block decides what purpose it is made for and what it should be known as.

Identifier: The identifier is basically to call that block. There can never be two blocks of a bean identifier. The identifier is always unique.

Store View: Select the store views to show the static block in.

Block Content: Whatever content you want to add inside the block like Image, Text, Title, Heading, Table, Product, etc. then these are all content when you call block anywhere then this content will appear

When you save the block, it appears as a content grid, then if you want to edit it in HTML format, then you can edit anything in it by clicking on the so as HTML.

Magento 2 CMS Block Page

 

Read more: Add Multiple Product Attribute Using InstallData in Magento2

 

How to Call CMS Block Page in PHTML File in Magento 2

Now below are the steps to call the CMS static block page in phtml file.

<?php
echo $this->getLayout()
->createBlock('Magento\Cms\Block\Block')
->setBlockId('your_block_identifier')
->toHtml();
?>

or

<?php echo $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('your_block_identifier_name')->toHtml();?>

 

Call Block Identifier in CMS Page

By using this below method you can display CMS static block content in any cms block page or any static block page.

{{block class="Magento\\Cms\\Block\\Block" block_id="block_identifier"}}

 

How to Get CMS Static Block In XML

Code to display the CMS Static Block in the “Content.

If you want to call static block inside XML file then you can follow the below method for that.

In the XML file, you can mention either the identifier or the ID of the block and through that, you can call the block.

<referenceContainer name="content"> 
<block class="Magento\Cms\Block\Block" name="block_identifier"> 
<arguments> 
<argument name="block_id" xsi:type="string">block_identifier</argument> 
</arguments> 
</block> 
</referenceContainer>

You can call the CMS static block by adopting any of these methods.

Wherever you want to show data, whether it is a slider, whether it is a product, whether it is a promotion or any kind of block content, you can easily call it in any phtml file and show it on the frontend.

If you face any kind of problem in this then you can feel free to call us, talk or mail, we will be there 24*7 to assist you.

 

Similar Posts:

Add Custom Class on Checkout Form Field in Magento 2

Magento 2.4 Installation Guide: How to Install Magento 2.4.2

Get Category Page Detail Using Category Page REST API

While creating a mobile application we need to get the data of the list page through the Magento 2 category page rest API.

In this sequence, I am telling you the steps here, using which you can get the information of the category page through Magento 2 API.

If you are searching Magento 2 REST API to get all categories where the is_active attribute is true in that case also you can use the below api.

You can also get the data of the enabled category of any store through the default REST API of Magento 2 given below

This Magento API behaves in such a way that you can get only the data of the active category, then you can use this API.

If a category is disabled, its attribute will not be active

 

Category Collection REST API Magento 2

This Magento 2 REST api of the category page lets you get category collection through store view code.

Through this, you can get the collection of entire store category collection details.

Endpoint:

https://www.wishusucess.com/rest/default/V1/categories

Method: GET

Header

  • Content-type: application/json
  • Authorization: Bearer Admin Token

Authorization: Not required

Category Page REST API in Magento 2

 

Response:

{
"id": 2,
"parent_id": 1,
"name": "Default Category",
"is_active": true,
"position": 1,
"level": 1,
"product_count": 1181,
"children_data": [
{
"id": 38,
"parent_id": 2,
"name": "What's New",
"is_active": true,
"position": 1,
"level": 2,
"product_count": 0,
"children_data": []
},


{
"id": 29,
"parent_id": 2,
"name": "Promotions",
"is_active": false,
"position": 6,
"level": 2,
"product_count": 0,
"children_data": [
{
"id": 30,
"parent_id": 29,
"name": "Women Sale",
"is_active": true,
"position": 1,
"level": 3,
"product_count": 224,
"children_data": []
},
{
"id": 31,
"parent_id": 29,
"name": "Men Sale",
"is_active": true,
"position": 2,
"level": 3,
"product_count": 39,
"children_data": []
},
{
"id": 32,
"parent_id": 29,
"name": "Pants",
"is_active": true,
"position": 3,
"level": 3,
"product_count": 247,
"children_data": []
},
{
"id": 33,
"parent_id": 29,
"name": "Tees",
"is_active": true,
"position": 4,
"level": 3,
"product_count": 192,
"children_data": []
}
]
},
{
"id": 37,
"parent_id": 2,
"name": "Sale",
"is_active": true,
"position": 6,
"level": 2,
"product_count": 0,
"children_data": []
}
]
}

 

Read more: Get Product Image URL Via Magento 2 REST API

 

Get All Category Page Data Via API in Magento 2

There is not much difference between the first and this API, but through this API you can get the complete category data of any Magento  2 website.

Using this REST API of Magento, you can easily get any categories and their subcategories across the store

Endpoint:

https://www.wishusucess.com/index.php/rest/V1/categories/

Method: GET

Header

  • Content-type: application/json
  • Authorization: Bearer Admin Token

Authorization: Not required

Category Collection REST API

 

Response:

{
"id": 2,
"parent_id": 1,
"name": "Default Category",
"is_active": true,
"position": 1,
"level": 1,
"product_count": 1181,
"children_data": [
{
"id": 38,
"parent_id": 2,
"name": "What's New",
"is_active": true,
"position": 1,
"level": 2,
"product_count": 0,
"children_data": []
},
{
"id": 29,
"parent_id": 2,
"name": "Promotions",
"is_active": false,
"position": 6,
"level": 2,
"product_count": 0,
"children_data": [
{
"id": 30,
"parent_id": 29,
"name": "Women Sale",
"is_active": true,
"position": 1,
"level": 3,
"product_count": 224,
"children_data": []
},
{
"id": 31,
"parent_id": 29,
"name": "Men Sale",
"is_active": true,
"position": 2,
"level": 3,
"product_count": 39,
"children_data": []
},
{
"id": 32,
"parent_id": 29,
"name": "Pants",
"is_active": true,
"position": 3,
"level": 3,
"product_count": 247,
"children_data": []
},
{
"id": 33,
"parent_id": 29,
"name": "Tees",
"is_active": true,
"position": 4,
"level": 3,
"product_count": 192,
"children_data": []
}
]
},
{
"id": 37,
"parent_id": 2,
"name": "Sale",
"is_active": true,
"position": 6,
"level": 2,
"product_count": 0,
"children_data": []
}
]
}

 

 

REST API for All Category Details With Image File

In this API, you can also get the image URL of each category simultaneously.

Rest of the details will remain the same as before API.

Magento 2 API, with the help of which all the category data of any store along with the image of each category is also available

Endpoint:

https://wishusucess.com/index.php/rest/V1/categories/list?searchCriteria[filterGroups][0][filters][0][field]=parent_id&searchCriteria[filterGroups][0][filters][0][value]=2

Method: GET

Header

  • Content-type: application/json
  • Authorization: Bearer Admin Token

Authorization: Not required

All Category Details Using Image File

 

Response

{
"items": [
{
"id": 3,
"parent_id": 2,
"name": "Gear",
"is_active": true,
"position": 4,
"level": 2,
"children": "4,5,6",
"created_at": "2022-01-20 14:12:16",
"updated_at": "2022-01-20 14:12:17",
"path": "1/2/3",
"available_sort_by": [],
"include_in_menu": true,
"custom_attributes": [
{
"attribute_code": "display_mode",
"value": "PAGE"
},
{
"attribute_code": "is_anchor",
"value": "0"
},
{
"attribute_code": "path",
"value": "1/2/3"
},
{
"attribute_code": "children_count",
"value": "3"
},
{
"attribute_code": "url_key",
"value": "gear"
},
{
"attribute_code": "url_path",
"value": "gear"
}
]
},
{
"id": 37,
"parent_id": 2,
"name": "Sale",
"is_active": true,
"position": 6,
"level": 2,
"children": "",
"created_at": "2022-01-20 14:15:55",
"updated_at": "2022-01-20 14:15:55",
"path": "1/2/37",
"available_sort_by": [],
"include_in_menu": true,
"custom_attributes": [
{
"attribute_code": "display_mode",
"value": "PAGE"
},
{
"attribute_code": "is_anchor",
"value": "0"
},
{
"attribute_code": "path",
"value": "1/2/37"
},
{
"attribute_code": "children_count",
"value": "0"
},
{
"attribute_code": "url_key",
"value": "sale"
},
{
"attribute_code": "url_path",
"value": "sale"
}
]
},
{
"id": 38,
"parent_id": 2,
"name": "What's New",
"is_active": true,
"position": 1,
"level": 2,
"children": "",
"created_at": "2022-01-20 14:15:55",
"updated_at": "2022-01-20 14:15:55",
"path": "1/2/38",
"available_sort_by": [],
"include_in_menu": true,
"custom_attributes": [
{
"attribute_code": "display_mode",
"value": "PAGE"
},
{
"attribute_code": "is_anchor",
"value": "0"
},
{
"attribute_code": "path",
"value": "1/2/38"
},
{
"attribute_code": "children_count",
"value": "0"
},
{
"attribute_code": "url_key",
"value": "what-is-new"
},
{
"attribute_code": "url_path",
"value": "what-is-new"
}
]
}
],
"search_criteria": {
"filter_groups": [
{
"filters": [
{
"field": "parent_id",
"value": "2",
"condition_type": "eq"
}
]
}
]
},
"total_count": 3
}

 

Similar Posts:

How to Get New Arrival Product REST API in Magento 2

Create Account REST API : How to Create an Account of Customer, Admin

 

Suggested Post:

BMLT Course in Hindi: Scope and Future Career in BMLT, Eligibility

Add Custom Class on Checkout Form Field in Magento 2

When we work on the checkout page of Magento 2 sometimes we need to add custom class on checkout form field.

The checkout page gets a bit complicated as it is made of Knockout js.

We can implement a plugin to add custom classes to any field in the customer shipping form on the checkout page in an easy way.

Through custom plugins, customers can add class to any field of the form.

Add Custom Class on Checkout Form Fields

In order to add a custom class on the checkout customer shipping form field, we will develop a custom plugin and through that will inject a class into any form field.

 

Step 1: Add Custom Class on Checkout Form Field Module Registration

For this first, we have to create a registration file so that we can register our custom plugin.

Wishusucess/CustomClass/registration.php
<?php 
/*
* Developer: Hemant Singh Magento 2 Professional
* Website: http://www.wishusucess.com/
*/
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Wishusucess_CustomClass',
__DIR__
);

 

Read more: How to Earn Money Digitally By Blog Writing And Other Way

 

Step 2: Module File for Custom Class Plugin

In this step, we have to create a model file.

As we all know that this is a basic file that holds the basic information details of any model or plugin.

Wishusucess/CustomClass/etc/module.xml
<?xml version="1.0"?>
<!--
/**
* Developer: Hemant Kumar Singh Magento Developer
* Website: http://www.wishusucess.com/
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Wishusucess_CustomClass" setup_version="1.0.0" active="true"></module>
</config>

 

Step 3: Add Dependency Injection File for Custom Class

Here we will tell Magento through a dependency injection file that we are going to make changes to its core functionality through the plugin.

That's why both the file type and name of that plugin will be mentioned in this file.

Wishusucess/CustomClass/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../vendor/magento/framework/ObjectManager/etc/config.xsd"> 
<type name="\Magento\Checkout\Block\Checkout\AttributeMerger">
<plugin name="customAttributeMerger" type="\Wishusucess\CustomClass\Model\Plugin\AttributeMergerPlugin"/>
</type>
</config>

 

Step 4: Plugin to Add Custom Class in Form Field

Via this plugin class, we will do some merge in behavior in the checkout form field.

As the checkout form field is loaded, a class will be automatically added.

Through this class, you can decide in which field you have to add the class name.

Wishusucess/CustomClass/Model/Plugin/AttributeMergerPlugin

<?php
/**
* Developer: Hemant Kumar Singh Magento Developer
* Website: http://www.wishusucess.com/
*/
namespace Wishusucess\CustomClass\Model\Plugin;

class AttributeMergerPlugin
{
public function afterMerge(\Magento\Checkout\Block\Checkout\AttributeMerger $subject, $result)
{
if (array_key_exists('telephone', $result)) {
$result['telephone']['additionalClasses'] = 'teliphone_number';
}

return $result;
}
}

Here is an example, I have added a custom class in the Magento default telephone number form field named telephone_number.

You can make any changes you want by using this class.

Because of creating a plugin, you will not need to add anything to any other file.

 

Step 5: Run Below Command

Now you have to run the command given below, then clear the cache, now you will see the class name.

php bin/magento setup:upgrade

php bin/magento setup:static-content:deploy -f

php bin/magento c:c

Custom Class on Customer Field

Here you can see that the custom class telephone number has been added.

In this way, you can add a custom class to any of the customer form fields as per your wish.

The easiest way to add a class is through a plugin

 

Download This Plugin

 

Similar Posts:

Configure PayPal in Magento 2 : How to Integrate PayPal

PayPal Account: How to Create New PayPal Account, Transfer

How to Get New Arrival Product REST API in Magento 2

In this article, we will learn how to filter the products of a Magento 2 store using the REST API and we will also know how to get new arrival products REST API.

By the way, Magento 2 Provides a facility for the REST API that is well known as Swagger Module which contains all list of REST APIs resources:

Using this model, you can get the product by visualizing and testing it through REST API.

When you hit the URL of your store by typing swagger you will get the list details of all the APIs.

Like I have taken an example below, according to this example you enter your URL and hit it, then you will get the API.

Endpoint:

http://www.wishusucess.com/swagger

Here we are filtering the product on the basis of attribute and the name of that attribute is a new product.

So while filtering the product through Rest API, we will get the newly added product by filtering

 

 

Get New Arrival Products REST API

 

To filter a new product, what should be its search criteria and which method will be used, what access token will be used, the details of all these are given below.

Endpoint

https://www.wishusucess.com/rest/V1/products?searchCriteria[sortOrders][0][field]=created_at&searchCriteria[pageSize]=10

Method: GET

Header: 

  • Authorization: Bearer <admin token>
  • Content Type: application/json

Body: none

New Arrival Products REST API

Search Parameter for New Arrivals in REST API

 

Created At New Arrivals

Response:

{
"items": [
{
"id": 2007,
"sku": "WSH08-31-Purple",
"name": "Sybil Running Short-31-Purple",
"attribute_set_id": 10,
"price": 44,
"status": 1,
"visibility": 1,
"type_id": "simple",
"created_at": "2021-12-23 09:40:40",
"updated_at": "2021-12-23 09:40:40",
"weight": 1,
"extension_attributes": {
"website_ids": [
1
],
"category_links": [
{
"position": 0,
"category_id": "28"
},
{
"position": 0,
"category_id": "35"
},
{
"position": 0,
"category_id": "2"
}
]
},
"product_links": [],
"options": [],
"media_gallery_entries": [
{
"id": 3353,
"media_type": "image",
"label": "",
"position": 1,
"disabled": false,
"types": [
"image",
"small_image",
"thumbnail"
],
"file": "/w/s/wsh08-purple_main_1.jpg"
},
{
"id": 3354,
"media_type": "image",
"label": "",
"position": 2,
"disabled": false,
"types": [],
"file": "/w/s/wsh08-purple_back_1.jpg"
}
],
"tier_prices": [],
"custom_attributes": [
{
"attribute_code": "image",
"value": "/w/s/wsh08-purple_main_1.jpg"
},
{
"attribute_code": "small_image",
"value": "/w/s/wsh08-purple_main_1.jpg"
},
{
"attribute_code": "thumbnail",
"value": "/w/s/wsh08-purple_main_1.jpg"
},
{
"attribute_code": "options_container",
"value": "container2"
},
{
"attribute_code": "msrp_display_actual_price_type",
"value": "0"
},
{
"attribute_code": "url_key",
"value": "sybil-running-short-31-purple"
},
{
"attribute_code": "required_options",
"value": "0"
},
{
"attribute_code": "has_options",
"value": "0"
},
{
"attribute_code": "tax_class_id",
"value": "2"
},
{
"attribute_code": "category_ids",
"value": [
"28",
"35",
"2"
]
},
{
"attribute_code": "description",
"value": "<p>Fortunately, it's okay to look cute while you're working out. The Sybil Running Short combines a fun, color-blocked design with breathable mesh fabric for sporty-fun style.</p>\n<p>&bull; Blue running shorts with green waist.<br />&bull; Drawstring-adjustable waist.<br />&bull; 4\" inseam. Machine wash/line dry.</p>"
},
{
"attribute_code": "size",
"value": "174"
},
{
"attribute_code": "color",
"value": "57"
}
]
}
],
"search_criteria": {
"filter_groups": [],
"sort_orders": [
{
"field": "created_at",
"direction": null
}
],
"page_size": 1
},
"total_count": 2046
}

 

Similar Posts:

Create Account REST API : How to Create an Account of Customer, Admin

Magento 2 Login REST API: How to Login Customer, Admin

Wishusucess on GitHub

Create Account REST API : How to Create an Account of Customer, Admin

In this article, I am going to explain to you how to use create account rest api in Magento 2. In this, I will also explain to you how to create customer and admin accounts using REST API.

Whenever you order a product inside the Magento store, there are three ways to do it.

By creating a customer account, we can order the product, which we call registered users or they are also called logged-in customers.

Another way is that customers can order products without registering an account, whom we know as guest users.

The third way is that the guest customer is registered only at the time of ordering.

As a guest user who logs in or creates an account when ordering
Through this article, I am going to explain how to register a client through the REST endpoint.

 

 

Admin Create Account REST API

Now if you are looking for the REST API endpoint to create Magento 2 admin users s you can follow the below steps.

 

Endpoint:

The below details are the basic structure of REST APIs to call in Magento 2.

<HTTP verb> http://<host>/rest/<scope>/<endpoint>

HTTP headers:

Through this section, we send the required authentication details and tell the Magento store that we are the authentic user who can access the requested data.

Payload:

Through this section, we send necessary valid details along with the endpoint.

POST <host>/rest/<store_code>/V1/tfa/provider/google/authenticate
{
"username": "admin",
"password": "<admin-password>",
"otp": "<otp-value>"
}

There is no API to create a Magento admin user you can get the access token of the admin user by using the rest API.

But you can create an admin account from the Magento 2 store in the admin.

Admin Panel > System > Permissions > All User > New User.

 

Response:

When you use the Magento admin rest API to get the access token that returns the admin’s access token in the following format.

4r2jdjdr11j6gmau8990hcj6qk5unh3i

Now, whenever you need to access the backend details or any other details then you have to use this token in the header for the authorization in every call and that header token validate then allows you to access the store details.

 

 

Customer REST API to Create Account

 

To create a customer, we can send all the details in the payload, in the first step I have only added four fields to create a customer in a short way.

But when you create a customer through rest API, all the other fields are optional, that's why you don't need to add all the fields in order to create customer accounts. You can create a customer by sending only four details in the payload in the Rest API.

 

Method 1: REST API to Create Customer in Magento 2

Endpoint:

POST <host>/rest/<store_code>/V1/customers
http://www.wishusucess.com/rest/V1/customers

Method: POST

Authorization: Not required

Body: raw: JSON

Headers: Content-Type: application/json

{
"customer": {
"email": "cs.hemantsingh@gmail.com",
"firstname": "Hemant",
"lastname": "Singh"
},
"password": "aaAdm378in@#123"
}

Create Account REST API in Magento 2

 

Response:

{
"id": 4,
"group_id": 1,
"created_at": "2022-01-14 18:38:21",
"updated_at": "2022-01-14 18:38:21",
"created_in": "Default Store View",
"email": "cs.hemantsingh@gmail.com",
"firstname": "Hemant",
"lastname": "Singh",
"store_id": 1,
"website_id": 1,
"addresses": [],
"disable_auto_group_change": 0,
"extension_attributes": {
"is_subscribed": false
}
}

 

Method 2: Create Customer REST API

In this step I am adding full customer details in payload else other details will be the same as the first methiod.

create customer rest api in detail

Response:

{
"id": 5,
"group_id": 1,
"default_billing": "3",
"default_shipping": "3",
"created_at": "2022-01-14 19:02:46",
"updated_at": "2022-01-14 19:02:47",
"created_in": "Default Store View",
"email": "cs.hemants@gmail.com",
"firstname": "Hemant",
"lastname": "Singh",
"store_id": 1,
"website_id": 1,
"addresses": [
{
"id": 3,
"customer_id": 5,
"region": {
"region_code": "UP",
"region": "Uttar Pradesh",
"region_id": 566
},
"region_id": 566,
"country_id": "IN",
"street": [
"Noida"
],
"telephone": "7992293862",
"postcode": "201301",
"city": "Noida",
"firstname": "Hemant",
"lastname": "Singh",
"default_shipping": true,
"default_billing": true
}
],
"disable_auto_group_change": 0,
"extension_attributes": {
"is_subscribed": false
}
}

 

If you log in to your Magento 2 store with any of the username and password details that you have given while creating the account using REST API, then it will log in successfully.

Or if you go to All Customers in the admin of the store, then your new account that has been created will appear.

Now if you want to implement login functionality using Magento rest api then you can use login rest API.

 

Read more: Magento 2 Login REST API: How to Login Customer, Admin

 

Other Post:

PayPal Account: How to Create New PayPal Account, Transfer

Wishusucess on GitHub

Magento 2 Login REST API: How to Login Customer, Admin

I am going to explain the Magento 2 login REST API for mobile applications so by using those REST APIs you can develop the application using the Magento 2 e-commerce framework.

So these APIs are basically used for the login system for the customers and admin users. You can take help of these proper rest ways to implement the login functionality.

 

 

Magento 2 Login REST API

 

To access the data of any store of your magento, first of all, you have to define yourself that you are the genuine person accessing that data.

Authentication means you have to prove as a genuine user of customer it admin that allows Magento e-commerce store to identify the access rights. It means you have the right to access (administrator, integration, client, or guest) resources of the API call.

Now if you just want to check some things as a front-end customer then you have to log in customer and for that, you have to get a customer access token.

But if you want to access internal details of the store then for that you must have to authenticate your identity and get an access token of admin details.

 

 

Magento 2 Login Rest API Customer

 

Step 1: You must have a customer account in order to get access tokens of customers. If you don't have a user account then you can create a customer account first.

Step 2: Now you have to send the customer user details like username and password in the payload with the POST method.

Step 3: Get customer access token in response.

 

API URL: {baseurl}/rest/V1/integration/customer/token

Endpoint:

https://wishusucess.com/rest/V1/integration/customer/token

Method: POST

Authorization: Not required

Body:

{
   "username":"cs.hemantsingh@gmail.com",
   "password":"Admin@#44123"
}

Magento 2 Login REST API

Response:

l2l6ccj0hwvm6pvj7uy7oflr7k7uvabv

 

 

Admin Login REST API in Magento 2

 

If any mobile application is developed using Magento eCommerce then at that time we need to login to Magento admin through rest API.

Let us know what is the complete step of admin login via REST API, by following which we can get this access token.

Step 1: You need a Magento store admin account in order to get access tokens of your stores via rest API.

Step 2: Now by hitting the below details you can get the admin access token. Along with the rest API URL you have to send the admin username and password in the payload with the POST method.

Step 3: Get admin access token in response.

 

API URL: {baseurl}/rest/V1/integration/admin/token

Endpoint: 

https://wishusucess.com/rest/V1/integration/admin/token

Method: POST

Header: Not required

Body:

{
    "username":"admin32",
    "password":"Admin555@#123"
}

Magento 2 Login REST API

Response:

9nnv93lsivrfvzyzt1cgdw8f3xnij05v

 

Read more: Magento 2.4 Installation Guide: How to Install Magento 2.4.2

 

Similar Post:

How to Make Payment Using PayPal REST API in Magento 2

Configure PayPal in Magento 2 : How to Integrate PayPal

How to Make Payment Using PayPal REST API in Magento 2

I am going to explain to you how to make payments using the PayPal REST API call to create orders through PayPal in Magento 2 e-commerce platform.

Here I am using the PayPal payment method to create an order for which I will pay through PayPal REST API and complete the order.

So it is important to have the right API calls as well as the right payload to fulfill the order.

When we hit the Paypal API, other details like basic authorization and header details must also be correct, otherwise, the payment will not be completed.

 

Read more: Configure PayPal in Magento 2 : How to Integrate PayPal

 

Now the correct point is what is the correct API call and payload to complete the order using PayPal express payment method to process checkout payment get it done the order.

So let's start steps one by one in order to complete the product order via Paypal rest API.

 

 

Step 1: Get an Access Token PayPal Sandbox App

 

First of all, we have to do the configuration of Magento admin, for that you can follow this step of Paypal Integration in Magento 2.

When your account is created and all its details are received then you reach this step to get access token using Paypal rest API.

You can proceed to the next step only after getting the required sandbox account details from the PayPal Developer Dashboard, for this you can complete those steps of the development environment to get OAuth 2.0 client ID and secret credentials for the sandbox accounts.

The access token you received authorizes you to access the PayPal REST API server by using those tokens.

 

Endpoint:

https://api-m.sandbox.paypal.com/v1/oauth2/token

Method: POST

Authorization: Basic Auth

Username: My app and credentials(client_id)

Password: Client secret

Body: x-www-form-urlencoded

grant_type = client_credentials

Get PayPal Access Token For Apps

 

Step 2: Create Order Using PayPal REST API

 

Now by using the below payload details you can create an order and complete the payment by using Paypal REST Apis call.

Endpoint:

https://api-m.sandbox.paypal.com/v1/payments/payment

Method: POST

Header:

Content-type: application/json

Authorization: <access-token>

Authorization: Basic Auth

Username: my app and credentials(client_id)

Password: Client secret

{
"intent": "authorize",
"experience_profile_id": "XP-T8WE-L7SC-RN4L-QJAS",
"payer": {
"payment_method": "paypal"
},
"transactions": [{
"amount": {
"currency": "USD",
"total": "1.25",
"details": {
"shipping": "0.1",
"subtotal": "1",
"tax": "0.15"
}
},
"payee": {
"email": "cs.hemantsingh@gmail.com"
},
"description": "Test paypal payment done on 13th Jan 2022",
"item_list": {
"items": [{
"name": "acessories belt monolog",
"quantity": "1",
"price": "1",
"sku": "test1",
"currency": "USD"
}],
"shipping_address": {
"recipient_name": "Hemant Singh",
"line1": "New test",
"city": "Saratoga",
"country_code": "US",
"postal_code": "95070",
"phone": "0116519999164",
"state": "CA"
}
}
}],
"redirect_urls": {
"return_url": "https://wishusucess.com/",
"cancel_url": "https://wishusucess.com/"
}
}

Create Order Using PayPal REST API

 

Response: Order Created Using PayPal Payment Method

{
"id": "PAYID-MHL4VTA69N500857X1559800",
"intent": "authorize",
"state": "created",
"payer": {
"payment_method": "paypal"
},
"transactions": [
{
"amount": {
"total": "1.25",
"currency": "USD",
"details": {
"subtotal": "1.00",
"tax": "0.15",
"shipping": "0.10"
}
},
"payee": {
"email": "cs.hemantsingh@gmail.com"
},
"description": "Test paypal payment done on 13th Jan 2022",
"item_list": {
"items": [
{
"name": "acessories belt monolog",
"sku": "acessoriebelt321",
"price": "1.00",
"currency": "USD",
"quantity": 1
}
],
"shipping_address": {
"recipient_name": "Hemant Singh",
"line1": "New test",
"city": "Saratoga",
"state": "CA",
"postal_code": "95070",
"country_code": "US",
"phone": "0116519999164"
}
},
"related_resources": []
}
],
"experience_profile_id": "XP-T8WE-L7SC-RN4L-QJAS",
"create_time": "2022-01-07T05:08:28Z",
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/payments/payment/PAYID-MHL4VTA69N500857X1559800",
"rel": "self",
"method": "GET"
},
{
"href": "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-47V04030JC5984021",
"rel": "approval_url",
"method": "REDIRECT"
},
{
"href": "https://api.sandbox.paypal.com/v1/payments/payment/PAYID-MHL4VTA69N500857X1559800/execute",
"rel": "execute",
"method": "POST"
}
]
}

 

 

Approval PayPal REST API Payments

 

Paypal Login Details: Enter your Paypal username

Password: Enter your Paypal password details

 

"href": "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-50C051037E557641M",
"rel": "approval_url",

"method": "REDIRECT"

 

Now you have to hit the approval URL in your response body and proceed as a guest for the testing purpose and it will redirect to the website to review the order.

PayPal REST API for Payment

As soon as you do this complete step, then your order will be completed and it will automatically go to your website.

Configure PayPal in Magento 2 : How to Integrate PayPal

I will tell you to step by step method to How to integrate the PayPal payment gateway on Magento 2 checkout page or configure PayPal in Magento 2.

PayPal comes by default with Magento, but we have to integrate it, then the PayPal payment option comes on the checkout page.

The Magento Ecommerce Framework provides a default model for integrating the PayPal Express checkout account. This feature was not there in the old version of Magento, but in the above version of 2.1.8, this facility has been given.

 

 

PayPal Payment Gateway in Magento 2

 

Paypal Express Checkout is also easy to integrate and it is easy for the customer to make the payment.

Due to this, the credibility of the website also increases. And when the website looks reliable in the eyes of the customer, then its sales also increase.

PayPal Payment Gateway is the most used payment gateway in the world which is also known for being the fastest and most secure.

It accepts payments in almost all currencies and mediums like debit cards, credit cards, etc.

The above-mentioned reason is sufficient that it is used in any online store or to accept online payment,

Then let us know how to add the PayPal Express Checkout payment method on your Magento website.

 

 

Steps to Configure PayPal in Magento 2

 

In order to configure PayPal Payment Gateway in Magento 2, we have to follow the following steps.

  • Expand the Paypal Express Checkout section in Magento 2, Admin.
  • Create a PayPal Account
  • Go to developer Paypal my account section and then get PayPal, API Username, API Password, and API Signature.
  • Fill in all the required details in Magento 2 admin.
  • Admin > Store > Configuration > Sales > Payment Method > Select Merchant Location > PayPal Express
  • Just select test mode for testing purposes or not for live site

Configure PayPal in Magento 2

 

Step 1: Create PayPal Account

 

You have to first log in from the developer account section of PayPal and then click on API & SDK.

Log into paypal account

 

Now you have to go inside of My Apps and credentials PayPal developer account then click on generate sandbox access token button then your business sandbox details will be generated.

Configure PayPal in Magento 2

 

Now you have to click on the Paypal personal or business mail manage the account you will see view/see the details.

Get PayPal Account APIs Key Details

 

After clicking on the above button you will get the API Credentials details of PayPal for the PayPal Integration.

Get My Apps Credentials PayPal

 

 

Step 2: Configure PayPal in Magento 2 Admin

 

Now just go inside of admin section and fill in all the details.

Admin > Store > Configuration > Sales > Payment Method > Select Merchant Location > PayPal Express

Now your Magento 2 Paypal payment method configuration has been done.

After successful completion, when you go to the frontend of your Magento 2 store you will see the PayPal payment option.

 

 

How Frontend Looks After PayPal Integration

 

I am giving you some details below, by which you will be confirmed that your PayPal payment method has been completed.

First of all, you have to go to the product details page of Magento 2 you will see the PayPal payment option.

Then you will go to the mini cart and there you will also see the PayPal payment method.

Now you will go to the checkout page of Magento 2 and there you will also see the PayPal payment method option

All these proofs prove that your PayPal payment integration has been successfully completed.

 

 

Add PayPal on Product Details Page

 

When PayPal is successfully added, then this automatic option will appear on the product detail page.

If you want to keep this payment option on the product detail page, then you can keep it, otherwise, you can also remove it.

Configure PayPal in Magento 2 Product Detail Page

 

 

 

PayPal Payment Option in MiniCart

 

This feature comes by default in Magento, when your PayPal account is properly integrated, then this payment option starts appearing.

Configure PayPal in Magento 2 on Minicart

 

 

Configure PayPal in Magento 2 on Checkout Page

 

Now in the last step, your PayPal payment option appears as a payment method on Magento 2 checkout page.

Here any customer can make his payment using the PayPal payment gateway option.

PayPal accepts all payment methods.

Add PayPal Payment Method on Checkout Page

 

 

Conclusion

 

Although there are other default payment methods on the Magento website, the PayPal payment method is the most important of them and also more popular.

Because it provides the facility of making payments with the fastest, most secure, and best user experience.

This contributes even more to connecting the customers of website owners,

Due to all these great experiences, your website plays an important role in increasing the sales rates and attracting more customers.

 

Payment Gateway Integration Helpline

 

If you face any problem in integrating any payment gateway, then feel free to call us or message us.

We will solve any kind of problem immediately.

Helpline number:

Skype: cs.hemantsingh@gmail.com

Phone: +91-8197565002

 

Similar Posts:

Best Payment Gateway For Magento 2: List of Top 7 And How To Integrate

Best Payment Gateway For Magento 2: List of Top 7 And How To Integrate

In this article, I am going to explain to you how you should choose and integrate payment gateway and the pros and cons of online payments gateways providers. I will also discuss the best payment gateway for Magento 2 websites in 2022.

If you want to advance your business in the Internet world, then it does not matter whether you are the owner of an eCommerce platform or doing any other work.

You have to think about your customers and provide them with a secure, quick, and easy-to-use payment system that will help them make their payments, otherwise, your business will be very difficult to run.

Business owners also have to keep in mind whether they choose the payment system keeping in mind their needs and keeping in mind their customers or not.

The payment solution you choose must meet the needs of both your customers and your business. Therefore, your business must protect your customers from fraud, and also take care that your business is not affected.

The payment method added to your business should be convenient to use and compatible with your website.Best Payment Gateway For Magento 2

When we use a payment gateway to make an online payment, that gateway enables us to process the credit or debit card electronically to accept the payment.

Many times it happens that due to the complex online system, customers leave the website without completing the order.

In such a situation it becomes necessary that the payment gateway of your website should be friendly according to your target customer.

 

Payment Gateway Integration With eCommerce Store

When it comes to e-commerce, payment solutions play an important role in this, at that time we have to make sure that it accepts all your payment methods and credit cards.

According to data in 2022, by far the most popular payment method is a credit card.

If we take out the percentage by adding all the regions, then up to seventy percent of the people prefer to pay by credit card only.

Now the rest of the percentage is occupied by some leading payment companies like PayPal, Amazon, etc.

When your business is global, then your payment method needs to have the option to pay in all types of currency so that customers from every region can pay according to their currency.

When we integrate the payment methods then that differ by two major factors:

  • Whether you must be in compliance with any financial regulation (PCI DSS), and
  • the degree of user experience concerning the checkout and payment procedure.

PCI DSS Compliance:

When we do not store sensitive data of any of our customers, it is not required because when we add third-party payment gateways, all the processing, and regulatory burden is handled by those parties. So you do not need these certificates.

But when you store those data, then it becomes necessary for you to follow those industry rules and regulations.

The Payment Card Industry Data Security Standard (PCI DSS) came into existence in 2004 that handle essential elements for processing card payments.

 

Best Payment Gateway for Magento 2 in 2022

Here, I am giving you the list of best payment gateway which according to 2022 comes in the name of best payment gateway.

Stripe

Stripe is one of the most popular eCommerce payment gateways solutions. That accepts all major electronic payment methods, including Apple Pay, WeChat Pay, and Android Pay.

Pricing does not charge for setup but the standard package charges 2.9 percent + $0.30 per transaction. And the international processing is approx 1 percent on each transaction. Strip also offers customized plans for the business.

 

Read More: How to Integrate Payment Gateway in Magento With Example

 

PayPal

Paypal Payment Gateway provides its service to every corner of the world, This electronic payment gateway is the best payment gateway for Magento e-commerce, its service is worthy of praise.

PayPal provides all kinds of packages for its customers, according to which customers can upgrade the plan according to their convenience. That is one of the best scalable solutions for all types of businesses sized.

PayPal Offers to Process:

  • Credit cards, debit cards, and PayPal payments themselves
  • Other processing services: PayPal Payments Pro, PayPal Express Checkout, and Braintree.

Braintree is a separate payment solution for mobile and web payment systems for e-commerce that completely waives off your international fees. You don't have to pay any extra charges.

PayPal’s Pricing:

  • Zero setup fees.
  • Domestic transactions: 2.9 percent + $0.30 per transaction.
  • Outside the US transactions: are 3.9 percent + a fee based on the currency used. T
  • PayPal Payments Pro charges $30 monthly for a subscription.

 

Amazon Pay

Amazon Pay is also a leading payment gateway method, this eCommerce giant designed its service for the smaller business owner and targets the online retailers.

Amazon Pay offers its processing service for all major cards like credit cards, debit cards, and other major payment methods.

Pricing:

  • Domestic transactions: 2.9 percent + $0.30 per transaction.
  • International is 3.9 percent.
  • The refund amount is $20 + taxes, if applicable.
  • No charges for installation or setup or monthly fees.

 

Authorize.net

Authorize.net's main customers are small and medium-sized businesses and their targeted business model is also designed for them.

This service accepts almost all payment methods, including Paypal and Amazon Pay.

Its security service is quite advanced which facilitates its customers for a seamless transaction for web and mobile applications.

Pricing:

Domestic transaction: 2.9 percent + $0.30 per transaction.

There is a $25 monthly fee for a gateway and $49 for a merchant account setup.

 

2Checkout

2Checkout offers its service in approximately 87 currencies and 15 languages. Its service is such that it easily connects with businesses of different sizes and offers them a worthy choice of customizable service.

Pricing:

  • No setup charges.
  • Domestic transaction: 3.5 percent + $0.35 per transaction.
  • 2Monetize charges: 6.0 percent + $0.60 per transaction.

 

Read more: Step By Step Guide For How To Add Razorpay Payment Gateway

 

Why Custom Payment Gateway?

The third-party payment system is perfect for small or middle-class merchants because it gives them good facility on a certain amount in less time but custom payment gateway becomes necessary for large entrepreneurs or big business organizations that they should not have any kind of restriction.

Having a system to make your own payment according to your own direction, free from all kinds of extra instructions, is an essential step in making the business successful.

However, a custom payment gateway can give you several benefits:

Low Transaction Fee:

If you create your own payment gateway, then the first benefit is that you are saved from transactional charges.

When a large business saves some amount on every single transaction, that becomes a huge number which helps in business growth.

Customization:

When you decide on a custom payment method, then you can completely customize it according to your business, which facilitates the payment of the customer of your business and increases your business growth.

You can also customize your transaction fee according to your business.

Once you have developed the facility to make a custom payment, you can also offer your service to another business and in return, you can do business deals or apply some transaction charges.

 

Conclusion

In conclusion, we can say that you can choose the payment gateway according to the convenience of your business.

If you are a small-scale merchant then it is better to use a third-party payment gateway.

When you use your own payment gateway, it increases your customer's trust in your business and contributes significantly to your sales growth.

Custom payment gateway needs development and maintenance all the time, it should have good ability to eliminate any kind of fraud methods

 

Recommended Post:

PayPal Account: How to Create New PayPal Account, Transfer