Login With PayPal scopes not working properly - next.js

I'm working on a e-Commerce platform where sellers can sell their services. The only payment gateway I'm using is PayPal, I need to get information about the seller's PayPal account like the email address or account ID to store it and then forward payments to their account when a customer buys something from them, I plan to do this with Login With Paypal.
When I click on the button to sign in and get redirected to http://sandbox.paypal.com/signin, I type my email address and password to obtain a code using openid profile email scopes, everything goes as intended, when I add the https://uri.paypal.com/services/paypalattributes value to the scopes string to get access specifically to the account verification status and PayPal account ID though, I receive an error saying the request couldn't be processed and to try again, therefore never hitting the callback URL containing the code that I need, no matter how many times I try again I get the same error.
Just in case, I'm using a Sandbox environment. This is my Next.js Login With PayPal button code.
<Script src="https://www.paypalobjects.com/js/external/api.js"
onReady={() => {
paypal.use( ['login'], function (login) {
login.render ({
"appid":"...",
"authend":"sandbox",
"scopes":"openid profile email
https://uri.paypal.com/services/paypalattributes",
"containerid":"lippButton",
"responseType":"code",
"locale":"en-us",
"buttonType":"LWP",
"buttonShape":"pill",
"buttonSize":"lg",
"fullPage":"true",
"returnurl":"http://127.0.0.1:3000/api/paypal/callback"
})
})
}}/>
I've also checked Account verification status and PayPal account ID (payer ID) scopes in my PayPal account settings.
DevTooling the request, this is what I receive:
"errors": [
{
"message": "Invalid request during get consent content",
"locations": [
{
"line": 3,
"column": 5
}
],
"path": [
"connect",
"getConsent"
],
"extensions": {
"name": "INVALID_REQUEST",
"details": []
}
}
],
"data": {
"connect": {
"getConsent": null,
"__typename": "ConnectQuery"
}
},
"extensions": {
"tracing": {
"version": 1,
"startTime": "2022-10-07T01:54:28.831Z",
"endTime": "2022-10-07T01:54:29.053Z",
"duration": 221889707,
"execution": {
"resolvers": [
{
"path": [
"connect"
],
"parentType": "Query",
"fieldName": "connect",
"returnType": "ConnectQuery",
"startOffset": 1755903,
"duration": 28116203
},
{
"path": [
"connect",
"getConsent"
],
"parentType": "ConnectQuery",
"fieldName": "getConsent",
"returnType": "ConsentEvaluationResponse",
"startOffset": 30085850,
"duration": 188656843
}
]
}
},
"correlationId": "..."
}
}

If an account or app in the PayPal Sandbox environment appears to be behaving in a way you can't find an explanation for, the simplest resolution is often to simply create a new sandbox account/app and verify whether the problem occurs there as well. If it doesn't, use the new one -- if it does, you have have ruled out the account/app itself as an issue and can focus on configuration/integration issues or a real potential problem to report.

Related

Is there any way to make WooCommerce REST API be friendly to customers?

I'm building an e-shop on WordPress + WooCommerce and Android app that retrieving data from WooCommerce REST API. I'm using WooCommerce's REST API with JWT to get information about products, categories, etc. also make orders, adding to cart, etc.
It's good, if you have admin's OAuth 1.0a credentials, but, I'm using customer's JWT. I made WordPress accept this auth method (by my plugin).
If I make request to http://SERVER/wp-json/wc/v3/products/categories, I will get this error:
{
"code": "woocommerce_rest_cannot_view",
"message": "Вы не можете просматривать список ресурсов.",
"data": {
"status": 403
}
}
I'm passing Authentification: Bearer "JWT" and WordPress accept it, but WooCommerce don't give me any info.
How I made WordPress accept my JWT:
function test_rest_user($result, $th, $request){
$secret_key = defined('JWT_AUTH_SECRET_KEY') ? JWT_AUTH_SECRET_KEY : false;
$auth = $request->get_header_as_array("Authorization");
if ($auth){
$token = explode(" ", $auth[0])[1];
$user = api::exchange_token_to_wp_user($token, $secret_key);
if ($user){
set_current_user($user->data->ID);
}
}
}
add_filter("rest_pre_dispatch", "test_rest_user", 10, 3);
The main topic of this question is that WooCommerce not accepting JWT. This is response from WordPress REST API with customers's JWT (http://SERVER/wp-json/wp/v2/users/me):
{
"id": 7,
"name": "test",
"url": "",
"description": "",
"link": "http://SERVER/author/test/",
"slug": "test",
"avatar_urls": {},
"meta": [],
"_links": {
"self": [
{
"href": "http://SERVER/wp-json/wp/v2/users/7"
}
],
"collection": [
{
"href": "http://SERVER/wp-json/wp/v2/users"
}
]
}
}
So, I'd temporal solution. I made function, that hooks WooCommerce REST API permissions, you can Google how to do that. It hooks from woocommerce_rest_check_permissions filter. Just check is user logged in and provide access to methods. It's so easy!

Google Analytics Reporting API - Get Activity with User ID

I can't get User Activity from the Google Analytics Reporting API (v4) using a User ID.
Client ID (in a different, non-User ID view) works, however.
Am I missing something?
--
For Client ID
I go here in my Google Analytics web interface:
https://analytics.google.com/analytics/web/#/report/visitors-user-activity/a45743608w76484324p79062844/_u.date00=20190327&_u.date01=20190402&_r.userId=1142688158.1525244974
I get user activity details as expected:
--
I call the following:
POST https://analyticsreporting.googleapis.com/v4/userActivity:search?key={YOUR_API_KEY}
{
"viewId": "79062844",
"dateRange": {
"startDate": "2019-03-27",
"endDate": "2019-04-02"
},
"user": {
"type": "CLIENT_ID",
"userId": "1142688158.1525244974"
}
}
I get the expected response:
{
"sessions": [
…
],
"totalRows": 14,
"sampleRate": 1
}
--
For User ID
I go here in my Google Analytics web interface:
https://analytics.google.com/analytics/web/#/report/visitors-user-activity/a45743608w76484324p185098721/_u.date00=20190327&_u.date01=20190402&_r.userId=Not%20Logged%20In-
I get user activity details as expected:
--
I call the following:
POST https://analyticsreporting.googleapis.com/v4/userActivity:search?key={YOUR_API_KEY}
{
"viewId": "185098721",
"dateRange": {
"startDate": "2019-03-27",
"endDate": "2019-04-02"
},
"user": {
"type": "USER_ID",
"userId": "Not Logged In-"
}
}
I get an error instead:
{
"error": {
"code": 400,
"message": "USER_ID: Not Logged In- not found.",
"status": "INVALID_ARGUMENT"
}
}
--
I have tried different IDs, different dates, changing the type to CLIENT_ID, URL encoding the User ID, and User IDs with no spaces - no joy.
It seems this is indeed a bug which several others are also experiencing.
This bug can be +1'd and followed here:
https://issuetracker.google.com/issues/130161158
Edit: This has now been fixed.
From your URL, you are looking for an ID called Not%20Logged%20In- which is not a valid id. Its probably changing the id when you copy paste the URL.

Dialogflow simulator not responding

I am testing a simple conversation from my dialogflow simulator using a fulfillment hosted in firebase functions.
And I am receiving the fulfillment response when triggered
But my simulator is showing this. Saying no response is received.
Please help
The complete RAW fulfillment response
{
"responseId": "99b660de-e2ca-4d8c-ace5-ef724fe5ee72",
"queryResult": {
"queryText": "male",
"parameters": {
"gender": "male"
},
"allRequiredParamsPresent": true,
"webhookPayload": {
"google": {
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "Amazing"
}
}
]
},
"expectUserResponse": true,
"userStorage": "{\"data\":{}}"
}
},
"outputContexts": [
{
"name": "projects/assurance-purple/agent/sessions/bf891cbe-8642-eb61-ed7b-d6796adfab60/contexts/_actions_on_google",
"lifespanCount": 99,
"parameters": {
"data": "{}",
"gender.original": "male",
"gender": "male"
}
}
],
"intent": {
"name": "projects/assurance-purple/agent/intents/96b523a0-7a3a-4135-bdfc-d9d8ad16b661",
"displayName": "getGender"
},
"intentDetectionConfidence": 1,
"diagnosticInfo": {
"webhook_latency_ms": 45
},
"languageCode": "en"
},
"webhookStatus": {
"message": "Webhook execution successful"
}
}
My actions on google Testing debug tab
`
{
"response": "We're sorry, but something went wrong. Please try again.",
"expectUserResponse": false,
"conversationToken": "",
"audioResponse": "",
"visualResponse": {
"visualElementsList": [
{
"displayText": {
"content": "Sorry, this action is not available in simulation"
}
}
],
"suggestionsList": [],
"agentLogoUrl": ""
},
"clientError": 4,
"is3pResponse": false
}
`
You don't show the entire response (copying and pasting it as text in your question would have been better), but it looks like you're sending a response back for an Action, but trying to test it in Dialogflow's conversation tool.
The Actions on Google response is slightly different than the response that Dialogflow expects to handle the additional features that the Assistant supports. Because of this, you need to use the Actions on Google simulator when testing your agent.
The Dialogflow test is looking for some specific fields to show the response that are not included with the actions-on-google library, and it will not show anything that is in a Google RichResponse object.
To summarize:
If you are working with an Action, use the Actions on Google simulator.
If you are working with other Dialogflow integrations, you can use the test tool on the right in Dialogflow.
Update
The error you're indicating from the AoG Simulator suggests that you're trying to just issue a statement in the conversation and not starting the Action, or that the Action has quit. Make sure you're talking to the action by starting it with "talk to my test app" or whatever the name of your Action is.

How can I use googles "Interesting Calendars" with their v3 FreeBusy API?

When I attempt to use a calendar such as en.usa#holiday#group.v.calendar.google.com (Or anything with the ID ending in group.v.calendar.google.com) The FreeBusy API errors with:
"calendars": {
"en.usa#holiday#group.v.calendar.google.com": {
"errors": [
{
"domain": "global",
"reason": "notFound"
}
],
"busy": []
}
}
Making the same request but asking for another calendar succeeds.
The request I am making is reproducible in the Google API Docs at https://developers.google.com/calendar/v3/reference/freebusy/query
Where the request body is:
{
"timeMin": "2018-07-01T11:21:53.682-04:00",
"timeMax": "2018-08-25T11:21:53.682-04:00",
"items": [
{
"id": "en.usa#holiday#group.v.calendar.google.com"
}
],
"timeZone": "UTC"
}
I ruled out credentials being an issue; the same credentials work with this calendarId when it is used on the events API. This should also mean that the calendarId is valid.
The google account being used has this interesting calendar added to it. (Those events show up in the combined view)

Campaign measurement is not sent to Google Analytics account

I am following campaign measurement guide to do
https://developers.google.com/analytics/devguides/collection/android/v4/campaigns
Google Play Campaign Attribution
General Campaign & Traffic Source Attribution
For the Google Play Campaign Attribution, after adding the campaign service and receiver to the androidManifest.xml, i followed the testing guide.
https://developers.google.com/analytics/solutions/testing-play-campaigns
In the log successfully received the install referrer intent.
07-29 17:05:32.968 8333-8363/? D/GAv4: Received installation campaign: content=test_content, keyword=test_term, medium=test_medium, name=test_name, source=test_source
But in my google analytic account, Acquisition -> Sources -> All, nothing shows up. Can anyone have any idea what is the root cause?
I also implemented the hit screen analytic, this is working.
My google-services.json is below:
{
"project_info": {
"project_number": "123456788680",
"project_id": "test-app-project"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:12345678680:android:488edac1c6c2df62",
"android_client_info": {
"package_name": "com.example.test.analytic"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "xxxxxxxx_xxxxxxxxxxxxxxKoT0XEkMgOCUe0c"
}
],
"services": {
"analytics_service": {
"status": 2,
"analytics_property": {
"tracking_id": "UA-xxxxxxxx-2"
}
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 1
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:12345678680:android:6092a3d09b6b18d2",
"android_client_info": {
"package_name": "com.example.test"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "xxxxxxxx_xxxxxxxxxxxxxxKoT0XEkMgOCUe0c"
}
],
"services": {
"analytics_service": {
"status": 2,
"analytics_property": {
"tracking_id": "UA-xxxxxxxx-2"
}
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 1
}
}
}
],
"configuration_version": "1"
}
I modified the project name and the key to post here. In my actual project, i didn't modify anything. There are 2 clients with different package name, because i have 2 projects, one is the main entry app and another is the library. All both needs to send info the google analytic. But both in one application, so I set it to use the same analytic property when request configuration form google. Is that impact? I think it shouldn't.
Can anyone help me?
For me, the information was not sent before building the tracker for the first time.
After sending the broadcast I also only get:
D/GAv4: Received installation campaign: content=test_content, keyword=test_term, medium=test_medium, name=test_name, source=test_source
Then after sending my first own tracking information to Google Analytis, I get:
D/GAv4: Sending first hit to property: UA-63098830-1
D/GAv4: Found relevant installation campaign: content=test_content, keyword=test_term, medium=test_medium, name=test_name, source=test_source
D/GAv4: Sending installation campaign to: UA-63098830-1, content=test_content, keyword=test_term, medium=test_medium, name=test_name, source=test_source

Resources