PayPal Patch Payee after approval before capture - paypal

In the PayPal documentation they state that you can update the payee email address after an order has been created
https://developer.paypal.com/docs/api/orders/v2/#orders_patch
However, if I try it by sending the following JSON to their API
{
"op": "replace",
"path": "/purchase_units/#reference_id=='default'/payee",
"value": {
"email_address": "a-sandbox-business-account#business.example.com"
}
}
I get told that the payee is not patchable
{"name":"UNPROCESSABLE_ENTITY","details":
[{"field":"path",
"value":"/purchase_units/0/payee",
"location":"body",
"issue":"NOT_PATCHABLE",
"description":"Cannot be patched."
}]
... }
After struggling quite a bit with the PayPal integration I'm too invested to give up at this point! Any ideas on how I should go about this? I've also tried changing the parameter name from email_address to email and setting value directly to the email address but neither are working. Do I need to replace the complete purchase_unit or maybe constructed my JSON badly?
Thanks in advance!

Use standard JSON patch syntax to patch the value directly
[
{
"op": "replace",
"path": "/purchase_units/#reference_id=='default'/payee/email_address",
"value": "receiveremail#somedomain.com"
}
]
Note that only a payee email_address can be patched; a merchant_id (if set instead) cannot be patched.

Related

Watson Assistant action to call IBM Cloud Function fails with Direct CloudFunctions calls are not supported on this platform

We are trying to implement cloud functions in Watson conversation but am receiving message 'Direct CloudFunctions calls are not supported on this platform'. When I googled for the error, I see that the issue could be because the region for WA and the cloud functions are different or not in US South/Germany. But I can confirm that both my WA and cloud functions are in US South.
I was trying in the 'Try out' panel. Below is the mock json editor content for my dialog node.
{
"context": {
"my_credentials": {
"user": "jgjg",
"password": "khk"
}
},
"output": {
"text": {
"values": [
"response text"
]
}
},
"actions": [
{
"name": "/<myIBMCloudOrganizationID>_<myIBMCloudSpace>/get-http-resource/weather",
"type": "server",
"parameters": {
"location": "Austin"
},
"credentials": "$my_credentials",
"result_variable": "$my_result"
}
]
}
Can you pls advise me on what am I doing wrong. Thanks.
I was going through the same issue. Cloud functions are only available in some regions. If your app is hosted in sydney or somewhere you cannot use that service there. Create a new app and set the location to london
Are you sure your user and password are set correctly?
Your user should consist of LETTERS and NUMBERS and some HYPHENS. like so : ...a-32d7-7d...
Your password should be just a string ...gafhWhu6alirEVpD...
Both are found in your api key on your IbmCloudFunctions page : https://console.bluemix.net/openwhisk/learn/api-key
Username is before the : of the api key and
Password after the : of the api key
If you already know this then i'm afraid i dont know how to help you.
Best

Magento 2 REST API Customer Custom Attribute

The Magento 2 REST API Documentation explains a way to set custom_attributes on a customer when updating or creating it. http://devdocs.magento.com/swagger/index_20.html#/
Unfortunately I couldn't get this to work...
My POST and PUT JSON request data is :
{
"customer": {
"custom_attributes": [
{
"attribute_code": "firstname",
"value": "TEST"
}
],
"email": "someone#exaxmple.com",
"extension_attributes": [],
"firstname": "Someone",
"gender": null,
"lastname": "Else",
"middlename": null,
"taxvat": null,
"website_id": "1"
}
}
The Customer is created but the Firstname is not "TEST".
Is there anyone who had the same problem and fixed it? Please let me know how.
My best guess is that, since Firstname is an existing Out-Of-The-Box attribute - the OOTB attribute name-value mapping assignment will take precedence.
Could you try again, with a unique custom attribute name (i.e. something that doesn't clash with OOTB attribute names)
You will need to DEFINE a custom-customer-attribute before you can use the M2 API to perform operations on that custom-customer-attribute.
This StackExchange thread - https://magento.stackexchange.com/questions/88245/magento2-create-a-customer-custom-attribute - has additional information on how to go about setting up a custom-customer-attribute.

Orion subscription when condition on expression is true

My purpose is to make a subscription so that accumulator server from the Orion's test package receives notifications when attribute's value exceeds a treshold. If I am correct this is not implemented on NGSI v1. So on NGSI v2 when I use the above subscription payload with the suitable Service and Subservice Headers
{
"description":"mydescription",
"subject":{
"entities":[
{
"id":"room1",
"type":"room",
"isPattern":"false"
}
],
"condition":{
"attrs":[
"temperature"
],
"expression":{
"q":"temperature>5"
}
}
},
"notification":{
"http":{
"url":"http://myURL:1028/accumulate"
},
"attrs":[
]
},
"expires":"2040-01
-01T14:00:00.00Z"
}
I don't receive any notifications on accumulator server. Without the expression I receive notifications on first place when i make the subscription and also every time that the attribute's value is changed.
Orion version: 1.7.0
I have also tried the solution with noCache for subscriptions on Context Broker.
EDIT: When I query the context for room1
curl -X GET localhost:1026/v2/entities/room1 -H "Fiware-Service: myService" -H "Fiware-ServicePath: /mySubService"
this is the reply from Orion.
{
"id":"room1",
"type":"room",
"TimeInstant":{
"type":"ISO8601",
"value":"2017-05-15T13:33:35.632Z",
"metadata":{
}
},
"temperature":{
"type":"float",
"value":"6",
"metadata":{
"TimeInstant":{
"type":"ISO8601",
"value":"2017-05-15T13:33:35.632Z"
}
}
}
}
Note that your temperature is a string ("6") and not a number. In order the filter to work it should be a number, i.e. you have to get:
{
..
"temperature":{
"type": "float",
"value": 6,
..
}
Note that the NGSIv1 API doesn't allow to create/update attributes with JSON native types other than strings (a more detailed explanation can be found in this presentation, "Native JSON datatypes" slides) If you attemp to create/update temperature as a number using NGSIv1 operations, it will be casted to string.
Thus you have to use the NGSIv2 API (which doesn't have such limitation) in order to create/update attributes with numeric values. For instance, the following request will update temperature value to the (numeric) value 6:
PUT /v2/entities/room1/attrs/temperature
{
"type": "float",
"value": 6
}

Can't post node that requires a pre assigned value with services api

I have setup a content type with a subject field that has pre assigned values in a dropdown field.
I am using the services api to post new content from a polymer app.
When I POST to the api I send the field structure and value in json but get and error.
"406 (Not Acceptable : An illegal choice has been detected. Please contact the site administrator.)"
Even though the object I am sending matches one of the required values in the field.
Do I need to prefix the value with something? I assume I'm posting to the right place to get that response but don't know why it would accept anything other than the string value.
Here is what I sent to the api which is picked up by my Charles proxy.
{
"node": {
"type": "case",
"title": "my case",
"language": "und",
"field_subject": {
"und": {
"0": {
"value": "subject1"
}
}
},
"body": {
"und": {
"0": {
"value": "my details of subject"
}
}
}
}
}
And here is an example of what I have setup in my Drupal field
subject1| first
subject2| second
subject3| third
subject4| forth
For anyone else with the same problem, this subject is poorly documented, but the answer is simple, my subject did not need the value key despite devel suggesting thats how it would be formatted.
"field_subject": {
"und": [
"subject1"
]
}
I could also shorten my code with "und" being an array.

Stripe Charge Card via HTTP Rest API

I am attempting to charge a card via Stripe but am getting:
{ error:
{ type: 'invalid_request_error',
message: 'You must supply either a card or a customer id' } }
Below is in the body (assume api key is correctly in header, content type is application/x-www-form-urlencoded, it is a post request to https://api.stripe.com/v1/charges)
data = {
"amount": 400,
"currency": "usd",
"card": {
"number": "4242424242424242",
"exp_month": "12",
"exp_year": "2019",
"cvc": "442"
},
"description": "Charge for test#example.com"
}
Any idea why this isn't working? Is it formatted incorrectly? Can't find an example of doing it this way in Stripe Documentation. Can charging a card be done directly like this, or is a token required? If so, how can this be done via HTTP and not stripe.js?