Is there any way to get refund details (ie. which items have been returned)? - square-connect

I am working on integration and need to get the refunded items inventory adjusted in our ERP. But I'm not getting any information about what items have actually been returned. I've tried the refunds as well as the payments endpoints.
"refunds": [
{
"type": "PARTIAL",
"created_at": "2017-08-03",
"processed_at": "2017-08-03",
"reason": "Returned Goods",
"refunded_money": {
"amount": -1100,
"currency_code": "USD"
},
"payment_id": "XXXXXXXXX",
"merchant_id": "XXXXXXXXXXX",
"refunded_processing_fee_money": {
"amount": 0,
"currency_code": "USD"
}
=====> ITEM_ID????
}]

Have you looked at the v1 Payments endpoint? That should have the itemization information you need for each refund.
Most developers use the inventory endpoints to do full syncs of other inventory management systems however.

Related

How to get payment Details at PayPal Subscription with php?

Im setting up a subscription with PayPal and php. So far I know that if the event PAYMENT.SALE.COMPLETED is called the payment was successful. To process the payment at my webhook I need more details about the payment (Who payed? What plan or subscription?). How can I get more details? Is it about the IDs?
This is the event body of an test event:
{
"id": "WH-2WR32451HC0233532-67976317FL4543714",
"create_time": "2014-10-23T17:23:52Z",
"resource_type": "sale",
"event_type": "PAYMENT.SALE.COMPLETED",
"summary": "A successful sale payment was made for $ 0.48 USD",
"resource": {
"parent_payment": "PAY-1PA12106FU478450MKRETS4A",
"update_time": "2014-10-23T17:23:04Z",
"amount": {
"total": "0.48",
"currency": "USD"
},
"payment_mode": "ECHECK",
"create_time": "2014-10-23T17:22:56Z",
"clearing_time": "2014-10-30T07:00:00Z",
"protection_eligibility_type": "ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE",
"protection_eligibility": "ELIGIBLE",
"links": [
...
],
"id": "80021663DE681814L",
"state": "completed"
},
"links": [
...
A real (non-webhook-test-simulator) event should have the subscription ID (I-#### number) of the subscription that the payment corresponds to. You should have stored that ID in your own user's profile at subscription creation time.
Another approach is to pass your own custom_id at subscription creation time.
You can test all of this in sandbox mode.

Facebook Analytics Active Users Tab - No Data

I have a live facebook app, with proper permissions (verified with Graph API). I can create custom Dashboards with all the relevant data, and I get data in my Event Manager.
Current Permissions (Granted and Declined):
{
"data": [
{
"permission": "user_birthday",
"status": "granted"
},
{
"permission": "user_likes",
"status": "granted"
},
{
"permission": "user_gender",
"status": "granted"
},
{
"permission": "email",
"status": "granted"
},
{
"permission": "public_profile",
"status": "granted"
},
{
"permission": "user_friends",
"status": "declined"
},
{
"permission": "read_insights",
"status": "declined"
}
What I'm having an issue with is with the "Active Users" tab under "Activity". It keeps telling me there isn't enough data, however journeys for the same time period show over 17K journeys, my custom dashboards show similar numbers (19K) for impressions and logins.
What constitutes "Active Users" and why would I not be seeing anything under the Analytics component of the Analytics Explorer?
If there is another post or documentation that clarifies this, or if additional information is required, please let me know.
Thank you in advance
"User Activity" or "Active Users" actually only looks at a few events, which are listed here: https://www.facebook.com/help/analytics/1747887018756757
If you're not logging any of those events, then you won't see any data under "Active Users."

Access control at property level (hiding/showing properties in api response based on the role)

I have a spring-boot based micro-service generated using JHipster.
I am using keycloak as my Auth Server. I could enable Role-based & scope based authorization on my resources(apis).
Now the requirement is: based on the role of the client, I need to restrict the information to send in the response (either mask the attributes or nullify them).
eg:
consider the following api to get the person's profile
/api/person/{id}
{
"name": {
"firstName": "Jack",
"lastName": "Sparrow"
},
"gender": "MALE",
"emails": {
"details": [
{
"emailId": "jack.sparrow#gmail.com"
}
]
},
"phones": {
"details": [
{
"phoneNumber": "1234567890",
"countryCode": "+1"
}
]
},
"addresses": {
"details": [
{
"addressLine1": "aaaaaaaa",
"addressLine2": "bbbbbbb",
"city": "cccccc",
"state": "ddddd",
"country": "South Africa",
"postalCode": "987654"
}
]
},
"photo": "string",
"nationality": "South Africa",
"countryOfResidence": "string",
"active": true,
"createdAt": 1537431339569,
"modifiedAt": 1537436600693,
"createdBy": "admin",
"modifiedBy": "admin"
}
Now, when a person with BASIC role calls this API, the requirement is to show only basic information like:
- name, gender
If he has INTERMEDIATE role then we can send something more than basic but not full information. eg: name, gender, photo, nationality
If he has ADMIN role then we can send the complete information.
Can anyone please let me know What is the best approach to achieve this.
-- Thanks in advance :)

Sprind data jpa - How to handle selective fields posted by client to rest web service

I am handling request through Spring data rest using jpa. I have a domain class say user, in this domain class there is lots of fields and mappings. When client want to update user data, they have to submit whole json body as per domain class. In want to handle it so that client can update user information by sending selective fields only. What is the best approach for doing this please suggest.
Sample JSON OBJECT mapped to User domain class:
{
"id": 1,
"oauthClientDetails": {
"clientId": "8909241111",
"resourceIds": null,
"clientSecret": "secret",
"scope": "read",
"authorizedGrantTypes": "client_credentials",
"webServerRedirectUri": null,
"authorities": null,
"accessTokenValidity": 18000,
"refreshTokenValidity": null,
"additionalInformation": "{}",
"autoApprove": null
},
"deviceNo": "SMR01-4417-0002",
"deviceMasterType": {
"id": 1,
"name": "Single Phase",
"description": "Single phase meter",
"createdDate": "21-02-2018 10:11:03",
"updatedDate": "24-02-2018 10:11:03",
"statusMaster": {
"id": 2,
"name": "Active",
"createdDate": "21-02-2018 10:11:03",
"updatedDate": "21-02-2018 10:11:05",
"status": "1"
}
},
"societyName": "M G ROad",
"flatNo": "51",
"firstName": "rohit",
"lastName": "yadav",
"roleMaster": {
"id": 1,
"name": "Super user",
"description": "This role provides all application permissions.",
"createdDate": "23-02-2018 10:15:05",
"updatedDate": "23-02-2018 10:15:05",
"statusMaster": {
"id": 1,
"name": "De-Active",
"createdDate": "21-02-2018 10:11:03",
"updatedDate": "21-02-2018 10:11:05",
"status": "1"
}
},
"statusMaster": {
"id": 2,
"name": "Active",
"createdDate": "21-02-2018 10:11:03",
"updatedDate": "21-02-2018 10:11:05",
"status": "1"
},
"email": null,
"countryMaster": {
"id": 1,
"countryCode": "BOL",
"countryName": "Bolivia, Plurinational State of",
"callingCode": "591",
"createdDate": "21-02-2018 10:11:05",
"updatedDate": "21-02-2018 10:11:05"
},
"otp": "1234",
"otpVerification": null,
"alternateMobile": "8800488281",
"createdDate": "28-02-2018 11:15:05",
"updatedDate": "02-03-2018 10:15:05",
"clientID": null
}
You could partition your domain into sub domains, e.g.
Device contains (deviceNo) and DeviceMaster (deviceMasterType)
Role, Status, Country for roleMaster, statusMaster, countryMaster
with the root level elements such as email, updatedDate etc part of a base domain object such as Client.
your REST endpoints could then expose this domain structure to allow updating of partial information:
https://api.com/device
https://api.com/deviceMaster
https://api.com/role
https://api.com/status
https://api.com/country
https://api.com/client
and update the domain in parts. If a subdomain such as /device only needs the deviceNo updated, ignore the missing JSON fields when creating a domain object.
While it's good idea to break into sub-domain classes as suggested by #codebrane.
But even your sub-domain classes can have selective fields.
So you should first define which are optional and mandatory fields.
This first check should tell your clients what are the mandatory items they should send.
You should use Bean validations to achieve this as supported by whichever vendor database you are using.
And, it is unlikely that all items in your JSON are dependent, for example, a user's address or device information cannot be created without first saving the user.
If you put all of them in a single API then it will be hard for you to implement Single responsibility principle, rather not good as well.
In this scenario, you would correctly first save the user and then address, etc in a different API call.
Separate your dependent entities as separate domain objects which will help you in designing your REST APIs accordingly.
If you follow this approach then it helps you in giving the right responses to your clients as well. For e.g., an API which only takes address and fails for whatever reason will inform client that a single entity failed. If you had used Address, Contact, Device, etc all in one API then at server they can fail or pass independently and your API response will not be informative to the client.

how to restrict price range in google shopping API

I'm using the Google Shopping API to try to retrieve products that have an "order" of magnitud of a certain number, or approximation to this. For example If I would to select products that are between th $40 - $60 price range : $50 +/- $10. What should I add in the URL search string?
I know I can rank by price like this (according to the API):
GET https://www.googleapis.com/shopping/search/v1/public/products?key=key&country=US&q=%22mp3+player%22%7Cipod&rankBy=price%3Adescending
Nevermind, the correct way to do this was using flask and jinja2 along with ajax. One has to be aware of using JSON and how it maps correctly to its equivalent python objects, when using the google shopping API main 'items' objects :
"product": {
"googleId": "9243781955569725518",
"author": {
"name": "CompUPlus.com",
"accountId": "1209120"
},
"creationTime": "2010-03-04T09:51:45.000Z",
"modificationTime": "2010-11-25T09:24:08.000Z",
"language": "en",
"country": "US",
"title": "Logitech Squeezebox Radio, black",
"description": "Logitech Squeezebox Radio brings a world of free Internet radio subscription
services and your personal digital music collection to any space in your home
over your Wi-Fi network.",
"link": "http://www.compuplus.com/Radios/LOGITECH-Squeezebox-Radio-BLK-930-1115160.html",
"gtin": "00097855063601",
"gtins": [
"00097855063601"
],
"brand": "Logitech",
"mpn": "930-000101",
"condition": "new",
"images": [
{ "link": "http://content.etilize.com/300/1014430207.jpg" }
]
"inventories": [
{
"channel": "online",
"availability": "inStock",
"currency": "usd",
"price": 183.19
}
],
}

Resources