PayPal Rest API error that sum does not add up but it does - paypal

I am using PayPal Rest API (SDK for Java) and when I submit a payment for excution (i.e. before the redirect) I get the error:
Excetpion e [{
"field": "transactions[0]",
"issue": "Item amount must add up to specified amount subtotal (or total if amount details not specified)"
}]]]
However the numbers are as follows (copy from my debug log) and add up and particularly the price of all items (there is only one) is exactly the subtotal
[[ tranaction t total 24.57]]
[[ tranaction t subtotal 19.8]]
[[ tranaction t tax 3.92]]
[[tranaction t shipping 0.85]]
[[tranaction t item[0] price 19.8]]
Anybody an idea whats up there?
Cheers
Tom

Reason is that I had below values and paypal then interprets the price as per item and not for the 2 items combined. Adaption then worked
"item_list": {
"items": [
{
"name": "PRODUCT_6",
"quantity": "2",
"price": "19.8",
"currency": "EUR"
}
]
}

Related

What is OData standard for odata.nextLink in case of 1:N $expand queries?

We can see the odata.nextlink standard in the server driven paging for normal queries here. But there is no odata.nextlink standard mentioned in case of 1:N $expand queries in $expand docs.
Can someone please confirm OData standard for 1:N $expand queries please?
Example:
If we have multiple account_tasks for a single account, how the result should look like:
GET [Organization URI]/api/data/v9.1/accounts?$top=1&$expand=Account_Tasks($select=subject)
Option-1: Where data is shown in list inline till the page-size, and odata.nextLink is shown if data count exceeds the page-size. So, odata.nextLink will show the next set of results. (Similar to standard pagination here.)
{
"#odata.context": "[Organization URI]/api/data/v9.1/$metadata#accounts(name,Account_Tasks(subject,scheduledstart))",
"value": [
{
"#odata.etag": "W/\"37867294\"",
"name": "Contoso, Ltd. (sample)",
"accountid": "7a4814f9-b0b8-ea11-a812-000d3a122b89",
"Account_Tasks": [
{
"#odata.etag": "W/\"28876919\"",
"subject": "Task 1 for Contoso, Ltd.",
},
{
// More account_tasks here. No odata.nextLink if data count < page-size.
]
}
]
}
Option-2: We'll show empty results inline and provide an odata.nextLink to actual data.
{
"#odata.context": "[Organization URI]/api/data/v9.1/$metadata#accounts(name,Account_Tasks(subject,scheduledstart))",
"value": [
{
"#odata.etag": "W/\"37867294\"",
"name": "Contoso, Ltd. (sample)",
"accountid": "7a4814f9-b0b8-ea11-a812-000d3a122b89",
"Account_Tasks": [],
// Empty list shown above and URL given below will show the full results.
"Account_Tasks#odata.nextLink": "[Organization URI]/api/data/v9.1/accounts(7a4814f9-b0b8-ea11-a812-000d3a122b89)/Account_Tasks?$select=subject,scheduledstart"
}
]
}
Option-3: Where data is shown in list till page-size, and odata.nextLink is shown every time (even if data count is smaller than the page-size). So, the odata.nextLink will show the full expand results including inline results.
{
"#odata.context": "[Organization URI]/api/data/v9.1/$metadata#accounts(name,Account_Tasks(subject,scheduledstart))",
"value": [
{
"#odata.etag": "W/\"37867294\"",
"name": "Contoso, Ltd. (sample)",
"accountid": "7a4814f9-b0b8-ea11-a812-000d3a122b89",
"Account_Tasks": [
{
"#odata.etag": "W/\"28876919\"",
"subject": "Task 1 for Contoso, Ltd.",
},
{
// More account tasks here
],
"Account_Tasks#odata.nextLink": "[Organization URI]/api/data/v9.1/accounts(7a4814f9-b0b8-ea11-a812-000d3a122b89)/Account_Tasks?$select=subject,scheduledstart"
}
]
}
Thanks in advance.
Good question -- paging of nested results is often misunderstood.
Nested results are paged individually, so where the nested account_tasks for a particular account exceeds a sever-defined threshold, the account_tasks up to that threshold are included, along with a nextlink to retrieve the additional account_tasks for that account. Which, I believe, is your Option 1.
Note that, since the threshold is server-defined, it is also valid to have a threshold of 0, and only include a nextlink for the nested account_tasks. However, each account will still have a different nextlink, and following that nextlink will return only those account_tasks for the account in which the nextlink was returned.
Does that make sense?

Multiple response in action on google dialogflow

How can i get multiple response on action on google console using dialogflow ?
i simulated on Action on google console but only two responses are showing on it
where as third response are not showing
here is my json response
{
"source": "webhook",
"data": {
"google": {
"is_ssml": true,
"permissions_request": null,
"expect_user_response": true
}
},
"messages": [
{
"type": 0,
"speech": "peter Got around 28 marks in maths. which is ranked 1 among 3 candidate in class 1"
},
{
"textToSpeech": "peter Got around 28 marks in maths. which is ranked 1 among 3 candidate in class 1",
"platform": "google",
"displayText": "peter Got around 28 marks in maths. which is ranked 1 among 3 candidate in class 1",
"type": "simple_response"
},
{
"textToSpeech": "Working",
"platform": "google",
"displayText": "Working",
"type": "simple_response"
},
{
"textToSpeech": "Working 2",
"platform": "google",
"displayText": "Working 2",
"type": "simple_response"
}
]
}
Here is my console output
any help regarding this is much appreciated
Thank you
Regards Saif
Only two simple responses will be accepted as a response. If you want more content you will need to consolidate your text into one of the two responses.
As you can see on the AoG Responses docs, it is specified as a requirement :
At most 2 chat bubbles per turn
So your third bubble won't display, as intended by Google.
As suggested in the previous answer from Nick, you need to consolidate your text and wrap everything in your 2 bubbles. In a simple response, you can line break by adding a \n where needed.
In a Basic Card however, you can access a limited subset of markdown, as stated in the docs link I provided, like that :
New line with a double space
**bold**
*italics*
Rich responses have the following requirements and optional properties that you can configure:
Supported on surfaces with the actions.capability.SCREEN_OUTPUT
capability.
The first item in a rich response must be a simple response.
At most two simple responses.
At most one basic card or StructuredResponse.
At most 8 suggestion chips. (you can add more than 8 also but you will get a warning not an error.)
Suggestion chips are not allowed in a FinalResponse
Linking out to the web from smart displays is currently not
supported.

Can I access ReimburseCharge objects in the IPP QBO v3 API?

I queried an Invoice that contains a billable expense charge. The response includes (and I'm showing just the relevant portions of it):
....
"Line": [
{
"LineNum": 1,
"DescriptionLineDetail": {
"ServiceDate": "2015-11-15"
},
"Id": "3",
"DetailType": "DescriptionOnly",
"Description": "Test Billable Transaction 1"
},
{
"LineNum": 2,
"DescriptionLineDetail": {
"ServiceDate": "2015-11-15"
},
"Id": "4",
"DetailType": "DescriptionOnly",
"Description": "Test Billable Expense Transaction 3"
},
{
"DetailType": "SubTotalLineDetail",
"Amount": 8.01,
"SubTotalLineDetail": {}
}
],
"LinkedTxn": [
{
"TxnId": "1938",
"TxnType": "ReimburseCharge"
},
{
"TxnId": "1932",
"TxnType": "ReimburseCharge"
}
],
...
I tried querying the API for ReimburseCharge and got only errors back. Is this business object on the roadmap?
On a related note, I observe that a billable line (at least in Purchase objects) can have its BillableStatus attribute set to "HasBeenBilled" with an Update call. It cannot be set back to "Billable" without first setting it to "NotBillable", but this does seem to work more than once so that it's not a one-way effect. If the line has actually been billed though, I get a validation fault when I try to change the BillableStatus from "HasBeenBilled" to "NotBillable", which I suppose makes sense.
Here's what's decidedly problematic though: I cannot use the API to either link a billable expense to an invoice or figure out where an already-linked expense is invoiced. Also, I cannot see the amount of the individual lines contained in these "DescriptionOnly" lines, so all I get is the total. Does Intuit have plans to change this and, if so, when?
This decision for supporting Reimb Charge is still pending.
Regarding DescriptionOnly- This was meant to support only total and sub totals.
So, if you have to use lines then you should use SalesItemLineDetail

Age, gender, & country not showing in Facebook Insights data

Nearly all the other metrics are available to view in Facebook Insights, except the user demographics. When I try to view them, I get an empty array:
"data": [
{
"name": "page_impressions_by_age_gender_unique",
"period": "day",
"values": [
{
"value": {
},
"end_time": "2015-10-08T07:00:00+0000"
}
],
"title": "Daily Reach Demographics",
"description": "Daily: Total Page Reach by age and gender.",
"id": "x/insights/page_impressions_by_age_gender_unique/day"
}
],
I have most permissions set: read_insights, manage_pages, publish_actions.
For me it's working for my page. If you don't have for daily means search in weekly or 28 days report. May be todays report not updated yet.
"Daily Reach Demographics" Also have "weekly and 28_days Reach Demographics" Search for that. And "read_insights" permission will be okay for this action.
Maybe it is related to one of these Facebook issues:
1993653884193030: page_impressions_by_age_gender_unique missing from page insights
1010193999087765: Some metrics are missing for period "day"
Response from Facebook:
This is actually not a bug, but by design. There are not enough impressions/data available to create a breakdown for that specific timeframe (in your case "day") so we do not return any data.

Pay with Paypal through Paypal REST API does not show up payment description on Paypal Sandbox or live sites

I am implementing Paypal's new REST API Pay with Paypal method that can be referenced here:
https://developer.paypal.com/webapps/developer/docs/integration/web/accept-paypal-payment/
The payment executes fine, exactly the way it should be. The user chooses to pay with Paypal and is then redirected to the Paypal site where he is expected to log in and approve the payment. The JSON data that I am sending Paypal is pretty much what is specified in the above link and mine looks like this:
{
"intent":"sale",
"redirect_urls":{
"return_url":"http://<return URL here>",
"cancel_url":"http://<cancel URL here>"
},
"payer":{
"payment_method":"paypal"
},
"transactions":[
{
"amount":{
"total":"7.47",
"currency":"USD"
},
"description":"This is the payment description."
}
]
}
As it redirects the user to the paypal website, the description and total amount column is shown blank
I am not sure if this is a mistake on Paypal's REST API but I believe I am providing the necessary description + amount payment to be reflected on this page. If this information is not shown, it is typically a deterrent to the user since they would definitely like to see the amount they are paying on the Paypal site even though this amount is listed on my website.
This is what it looks like:
For those who would like to indicate that the user has not logged in, well, even after logging in, the description and the current purchase column remain blank.
Am I missing any parameters that need to be sent to Paypal in order to indicate this description data?
Note: This issue persists for both the live and sandbox servers.
The left hand pan in above page displays:
1. Item details from order. You can include item list as part of the transaction details in payment resource. The same will be displayed here.
2. Components of the transaction amount e.g. shipping amount, tax, etc. if you include them in request.
Try this request to see example:
{
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"redirect_urls": {
"return_url": "http://<return url>",
"cancel_url": "http://<cancle url>"
},
"transactions": [
{
"amount": {
"total": "8.00",
"currency": "USD",
"details": {
"subtotal": "6.00",
"tax": "1.00",
"shipping": "1.00"
}
},
"description": "This is payment description.",
"item_list": {
"items":[
{
"quantity":"3",
"name":"Hat",
"price":"2.00",
"sku":"product12345",
"currency":"USD"
}
]
}
}
]
}
Thank you. Madhu remember to use the rest-api library!
Details amountDetails = new Details();
amountDetails.setSubtotal(autoregistro.getPedido().getItems().get(0).getTotal().toPlainString());
amountDetails.setTax("0");
amountDetails.setShipping("0");
Amount amount = new Amount();
amount.setCurrency("USD");
amount.setTotal(autoregistro.getPedido().getItems().get(0).getTotal().toPlainString());
// amount.setTotal("7.47"); // Los decimales deben ser con punto
amount.setDetails(amountDetails);
Item item = new Item();
item.setCurrency("USD");
item.setQuantity("1");
item.setName(autoregistro.getPedido().getItems().get(0).getDescripcion());
item.setPrice(amountDetails.getSubtotal());
List<Item> items = new ArrayList<Item>();
items.add(item);
ItemList itemList = new ItemList();
itemList.setItems(items);
Transaction transaction = new Transaction();
transaction.setDescription(item.getName());
transaction.setAmount(amount);
transaction.setItemList(itemList);
List<Transaction> transactions = new ArrayList<Transaction>();
transactions.add(transaction);
Payer payer = new Payer();
payer.setPaymentMethod("paypal");
// payer.setPaymentMethod("credit_card");
Payment payment = new Payment();
payment.setIntent("sale");
payment.setPayer(payer);
payment.setTransactions(transactions);
RedirectUrls redirectUrls = new RedirectUrls();
redirectUrls.setCancelUrl(this.configParameters.getAutoregistroURL() + "/pay_paypal?cancel=true");
redirectUrls.setReturnUrl(this.configParameters.getAutoregistroURL() + "/pay_paypal?success=true");
payment.setRedirectUrls(redirectUrls);
Payment createdPayment = payment.create(apiContext);