Google Pay - get full shipping address from onPaymentDataChanged callback - react-redux

Is it possible to get the full shipping address from the onPaymentDataChanged() callback? To select deliveries and calculate their costs and calculate taxes, I use a third-party API that requires an address_line_1 field, but on this callback I can get only an object with a short address.
It wouldn't be a problem, but I need to calculate costs and show it to user directly from google pay widget before the pay button is clicked and payment is completed.
Example of object that I get from callback:
{
"shippingAddress": {
"countryCode": "UA",
"postalCode": "49000",
"locality": "Dnipro",
"administrativeArea": "Дніпропетровська область"
},
"callbackTrigger": "SHIPPING_ADDRESS"
}
Some links that I used to research:
https://developers.google.com/pay/api/web/reference/response-objects#IntermediateAddress
https://developers.google.com/pay/api/web/reference/client#onPaymentDataChanged
https://developers.google.com/pay/api/web/guides/tutorial#load:~:text=Was%20this%20helpful%3F-,Tutorial,-bookmark_border

The complete address is only available after authorized event, in paymentData

Related

Magento Global Special Price - Create or Update - HTTP Request

Problem: I would like to update the global special price of a product in Magento using a HTTP POST or PUT request.
Whilst I've seen the endpoint /V1/products/special-price in the docs, this is per store and not global.
Which endpoint should I send to, with what data?
Use Cases:
I'll be creating a whole new product, with a special price included at the start
I'll be updating an existing product with a new special price
I'll be deleting the special price from a product
This code worked for scheduling an update. To make it global, I set the store_id to 0.
{
"prices": [
{
"price": 45.00,
"store_id": 0,
"sku": "virtualProductTest",
"price_from": "2023-01-13 08:43:00",
"price_to": "2024-10-16 22:30:45",
"extension_attributes": {}
}
]
}

How Does The Magento 2 Product Discounts Work?

Looking at the Magento Quick Reference Documentation , in product -> extension_attributes -> discounts, the API offers an array of objects one can use for discounting products in Magento 2.
Questions:
Why is an array of objects needed?
Is there somewhere to view "discounts" by navigating from the Magento Dashboard?
Could each key/value pair field options be explained in plain English?
JSON Example
{
"discounts": [
{
"discount_data": { "amount": 0.00, "base_amount": 0.00, "base_original_amount": 0.00, "original_amount": 0.00 },
"rule_id": 0,
"rule_label": ""
}
]
}
Key Value Pairs:
discount_data ->
a) amount
b) base_amount
c) base_original_amount
d) original_amount
rule_id
rule_label
What are you trying to do to create a custom REST API for the discounted product? Meanwhile, to answer your questions:
Answers:
1: Third-party developers cannot change the API Data interface in the Magento core. So, adding extension attributes is the only way to affect interfaces using configuration. The array is formed in the coding structure of the main object of the product, so please make sure to attach the additional details.
So, this custom data, i.e., your extension attribute, will be added as an array for the extensible product object.
2: Navigate to Marketing->cart price rules or catalog price rules applied to the product category.
Also, check the product as:
Navigate to Products > Catalog, select the required item and click 'Edit.'
You can scroll down and click on Advance Price to check if the special price and date are set.
3: Key Value Pair
Please specify for which API you want to create so we can explain the key value like order or product.
To order the object:
{
"paymentMethod": {
"method": "banktransfer"
},
"billing_address": {
"email": "jdoe#example.com",
"region": "New York",
"region_id": 43,
"region_code": "NY",
"country_id": "US",
"street": ["160 1st St."],
"postcode": "11501",
"city": "Mineola",
"telephone": "516-555-1111",
"firstname": "Jane",
"lastname": "Doe"
}
}
Full documentation: https://developer.adobe.com/commerce/webapi/rest/quick-reference/
https://devdocs.magento.com/guides/v2.4/rest/tutorials/inventory/create-order.html

How to check if a calendar event is exception or instance

I am using Google Calendar API in my application for Recurring events(create, update and delete operations), but i am unable to find if a recurring event is an instance event or an exception event
Creating recurring events is similar to creating a regular (single) event with the event resource's recurrence field set.
POST /calendar/v3/calendars/primary/events
...
{
"summary": "Appointment",
"location": "Somewhere",
"start": {
"dateTime": "2011-06-03T10:00:00.000-07:00",
"timeZone": "America/Los_Angeles"
},
"end": {
"dateTime": "2011-06-03T10:25:00.000-07:00",
"timeZone": "America/Los_Angeles"
},
"recurrence": [
"RRULE:FREQ=WEEKLY;UNTIL=20110701T170000Z",
],
"attendees": [
{
"email": "attendeeEmail",
# Other attendee's data...
},
# ...
],
}
To see all the instances of a given recurring event you can use the events.instances() request.
The events.list() request by default only returns single events, recurring events, and exceptions; instances that are not exceptions are not returned. If the singleEvents parameter is set then all the individual instances do appear in the result, but not the underlying recurring events.
for more information please see recurringevents
Unfortunately, there is no way to identify if the instance is an exception of the recurring event. The only work around is to diff the instance with the master event or use the originalStartTime which uniquely identifies the instance (can compare the originalStartTime with the start objects date/dateTime, though this would fail if you had changed the summary or other text field).
The way I have handled this issue is by making an incremental change request with the nextSyncToken. If an exception was made, an instance will be in the payload that is returned from the list call. I check if that instance has a recurringEventId attribute associated with it and if it does, I know that that instance is an exception.
Would highly advocate for Google to include a system similar to that of Microsoft Graph which utilizes an attribute that identifies whether the event is an instance or an exception.
source: https://developers.google.com/calendar/recurringevents

Microsoft 365 API : Issue at attaching Contact to Campaign Response

I am trying to attach a contact to campaign response.
I am using rest API for that.
https://learn.microsoft.com/en-us/dynamics365/customer-engagement/web-api/campaignresponse?view=dynamics-ce-odata-9
Post Data :
{
"firstname": "TestFirst",
"lastname": "TestLast",
"emailaddress": "test#test.com",
"telephone": "1234567890",
"prioritycode": 0,
"responsecode": 1,
"subject": "Test Subject",
"statuscode": 1,
"regardingobjectid_campaign#odata.bind": "/campaigns(xxxx90c-11ef-e811-a966-000d3ad24a0d)",
"regardingobjectid_contact#odata.bind": "/contacts(xxxxfa2e-c3b5-e811-a962-000d3ad24a0d)"
}
Here is my JSON.
I am getting Error : “Campaign as RegardingObject must be supplied”. Without contact, it works fine.
I had the same problem and the documentation is not very clear about it, I had to check all the relationships of the CampaignResponse in order to understand how to solve this.
If you want to create a CampaignResponse linked to both a Campaign and a Contact you need to do the following:
Create a CampaignResponse with the "regardingobjectid_campaign#odata.bind" in the params sent.
POST "https://some_subdomain.crm6.dynamics.com/api/data/v9.0/campaignresponses"
{
"regardingobjectid_campaign#odata.bind": "/campaigns(CAMPAIGN_ID_HERE)",
"description": "some desc",
"subject": "some subject "
}
Then find the CampaignResponse you just created to get its activityid (every CampaignResponse is an Activity)
Finally, you need to create a new ActivityParty, that will link the Contact to the CampaignResponse.
POST "https://some_subdomain.crm6.dynamics.com/api/data/v9.0/campaignresponses(CAMPAIGN_ID_HERE)/activitypointer_activity_parties"
{
"partyid_contact#odata.bind": "/contacts(CONTACT_ID_HERE)",
"participationtypemask": 11 //this is the code for customers
}
The "Regarding" lookup field can only be set to a single "regarding" record. Even though it appears that there are different Regarding fields, one for each entity type, those are "helper" fields that let you easily set the main Regarding field by setting one of those regardingobjectid_xxx fields.
You must choose to use either a campaign or a contact as your Regarding field. You can of course create other lookups, so you could use the Regarding field for your campaign and then add an additional Contact lookup field, for example.

Unable to get gender from Google People API

I've got a problem obtaining gender information from People API.
I'm making a request to https://people.googleapis.com/v1/people/account_id which is not returning gender field. If I add genders to personFields it is giving me Requested entity was not found error.
It looks like obtaining this information is forbidden. Is there any chance to get this field?
There are two ways to use the Google People api.
The first assumes that you have used Oauth2 to authenticate your user.
GET https://people.googleapis.com/v1/people/me
returns the info about the current authenticated user.
The second is a public call to the api. you can use an API key or Oauth2.
GET https://people.googleapis.com/v1/people/117200475532672775346
This will return the info about a specific user {117200475532672775346} but it will depend upon what that user has set to public. The above number is my personal g+ account, the following is the gender response.
"genders": [
{
"metadata": {
"primary": true,
"source": {
"type": "PROFILE",
"id": "117200475532672775346"
}
},
"value": "female",
"formattedValue": "Female"
}
I have no idea where you are getting your account id this is a users google id. The information must be filled out on Google plus i suggest you check the users google+ account to see what they have set to public https://plus.google.com/u/0/117200475532672775346. Note: It doesn't matter if this is the current authenticated user if they dont have the info set public you cant see it in your application.
Tip: assuming you only want to see genders you can use the fields parameter to request just that
?fields=genders

Resources