I'm using the PayPal API to handle payments on my website. A product has the following prices :
exclusive of tax : 0.083€
vat rate : 20%
all taxes included : 0.10€
In the API, we have to send the items of an order with the exclusive of tax unit price and the vat rate.
Here is my request :
{
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"transactions": [
{
"amount": {
"currency": "EUR",
"total": "99.60",
"details": {
"subtotal": "83.00",
"tax": "16.60"
}
},
"item_list": {
"items": [
{
"quantity": "1000",
"name": "My product",
"price": "0.08",
"currency": "EUR",
"sku": "1-20140407123511492"
}
]
}
}
]
}
As you can see, since PayPal accepts only prices with a maximum of 2 decimals, there is an error in the final calculation (0.003€ multiplied by the quantity).
In the end, I have the following error :
{"name":"VALIDATION_ERROR","details":[{"field":"transactions","issue":"Item amount must add up to specified amount subtotal (or total if amount details not specified)"}],"message":"Invalid request - see details","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR","debug_id":"132eaa3f14cce"}
So, how can we handle small prices with the PayPal API ?
Thanks.
Related
We are generating Quotes from our application using Xero API. We have created our Line Item in Poducts and Services and added price there.
From the API, we do not wish to send Price again, as this is already in Xero. We wish to send LineItem code and perhaps account (Sell vs Purchase) and let Xero use the price.
Can anyone let us know if there is a way to accomplish this, without having to query Xero for the Products and Services prices to build the Quote?
Thank you for your help.
Request:
{
"Quotes": [
{
"Contact": {
"ContactID": "a852a44c-3d8f-4c4b-a628-3a2c2121b9b1"
},
"LineItems": [
{
"ItemCode": "BOOK",
"Description": "BlaBla",
"Quantity": 1
}
],
"Date": "2022-12-20",
"Reference": "Event Name"
}
]
}
Response (error 400):
{
"ErrorNumber": 10,
"Type": "ValidationException",
"Message": "A validation exception occurred",
"Elements": [
{
"Reference": "Event Name",
"Contact": {
"ContactID": "a852a44c-3d8f-4c4b-a628-3a2c2121b9b1"
},
"LineItems": [
{
"Description": "BlaBla",
"ItemCode": "BOOK",
"Quantity": 1.0
}
],
"Date": "\/Date(1671494400000)\/",
"ValidationErrors": [
{
"Message": "Unit Amount cannot be empty"
}
]
}
]
}
I'm sending events hits to GA using the Measurement Protocol for GA4 but the hits are not getting recorded (they are showing on the GA dashboard even after waiting for more then 24 hours).
The URL I'm sending the POST request to:
https://www.google-analytics.com/mp/collect?measurement_id=G-XXXXXXXXXX&api_secret=XXXXXXXXXXXX
The JSON body:
{
"client_id": "XXXXXXX.XXXXXXX",
"events": [
{
"name": "add_to_cart",
"params": {
"value": 50,
"currency": "USD",
"items": [
{
"item_id": "ITEM-SKU-001",
"item_name": "Product Name",
"item_variant": "Product Name",
"currency": "USD",
"price": "50",
"quantity": 1
}
]
}
}
]
}
The "client_id" is the value of the _ga cookie with "GA1.1." removed.
The above request returns an empty response body and a 204 http status code.
When I send the hit to the debug URL, I get the http status code 200 and the response body as:
{
"validationMessages": []
}
What am I doing wrong?
In RavenDB 4.0+ for a given Sample Northwind database (which is also available at http://live-test.ravendb.net/), what RQL queries one may use to:
Get Orders in which at least one of the Lines has Discount == 0?
Get Orders in which all the Lines have Discount != 0?
Get Orders in which at least one of the Lines has Discount != 0?
Get Orders in which all the Lines have Discount == 0?
Here's a sample document structure:
{
"Company": "companies/85-A",
"Employee": "employees/5-A",
"Freight": 32.38,
"Lines": [
{
"Discount": 0,
"PricePerUnit": 14,
"Product": "products/11-A",
"ProductName": "Queso Cabrales",
"Quantity": 12
},
{
"Discount": 0,
"PricePerUnit": 9.8,
"Product": "products/42-A",
"ProductName": "Singaporean Hokkien Fried Mee",
"Quantity": 10
},
{
"Discount": 0,
"PricePerUnit": 34.8,
"Product": "products/72-A",
"ProductName": "Mozzarella di Giovanni",
"Quantity": 5
}
],
"OrderedAt": "1996-07-04T00:00:00.0000000",
"RequireAt": "1996-08-01T00:00:00.0000000",
"ShipTo": {
"City": "Reims",
"Country": "France",
"Line1": "59 rue de l'Abbaye",
"Line2": null,
"Location": {
"Latitude": 49.25595819999999,
"Longitude": 4.1547448
},
"PostalCode": "51100",
"Region": null
},
"ShipVia": "shippers/3-A",
"ShippedAt": "1996-07-16T00:00:00.0000000",
"#metadata": {
"#collection": "Orders",
"#flags": "HasRevisions",
"#id": "orders/1-A",
"#last-modified": "2018-07-27T12:11:53.0447651Z",
"#change-vector": "A:417-EKrWjfz5kESi6lp7Nf442Q",
"#index-score": 1
}
}
I managed to find out some answers only for 1 and 2:
Get Orders in which at least one of the Lines has Discount == 0?
from Orders where Lines[].Discount == 0
from Orders where Lines[].Discount IN (0)
from Orders where Lines[].Discount ALL IN (0)
Get Orders in which all the Lines have Discount != 0?
from Orders where Lines[].Discount != 0
On the BigC dashboard, I can configure two types of discount applications to Category Level discount:
"products in this categories only"
"products in this category and its subcategories".
Example Customer Group Category Level
When retrieving the customer groups via the API, how can I tell which way it was configured? The API returns back very limited information pertaining to customer groups. For example:
[
{
"id": 1,
"name": "Sample Customer Group",
"is_default": false,
"category_access": {
"type": "all"
},
"discount_rules": [
{
"type": "category",
"category_id": "20",
"method": "fixed",
"amount": "9.0000"
},
{
"type": "category",
"category_id": "3",
"method": "percent",
"amount": "10.0000"
}
]
}
]
I can see the category it applies to, and the level of the discount, but the API doesn't return back whether the discount applies to just the category, or also it's subcategories. How can I get this info?
Using the PayPal REST API, I'm passing in this to new payments:
URL: https://api.paypal.com/v1/payments/payment
Request:
{
"intent":"sale",
"payer":{
"payment_method":"paypal"
},
"redirect_urls":{
"return_url":"[return_path]",
"cancel_url":"[cancel_path]"
},
"transactions":[
{
"amount":{
"total":"19.95",
"currency":"USD",
"details":{
"subtotal":"19.95"
}
},
"description":"[product description]"
}
]
}
But on the PayPal approve page I see no any order info. In "Your order summary" section at the left I see no description, no total, no subtotal, nothing.
Screenshot: http://goo.gl/dxoicB
But I expect to see there at lest smth...
How can I make individual items with descriptions in the REST API checkout? Or what I'm doing wrong? It seems I've read the whole Developers Guide, but there is nothing about it.
And another thing: when I done with order, in transaction details also is no any technical info about order.
Screenshot: http://goo.gl/i4iGHZ
There is no technical information allows us to understand what site and what product was sold there.
You have to specify the item_list on transactions to get order summary.
Example request data
{
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"redirect_urls": {
"return_url": "http://return.url",
"cancel_url": "http://cancel.url"
},
"transactions": [{
"item_list": {
"items": [{
"name": "item",
"sku": "item",
"price": "1.00",
"currency": "USD",
"quantity": 1
}]
},
"amount": {
"currency": "USD",
"total": "1.00"
},
"description": "This is the payment description."
}]
}
Refer:
https://developer.paypal.com/webapps/developer/docs/api/#transaction-object
https://github.com/paypal/rest-api-sdk-nodejs/blob/master/samples/payment/create_with_paypal.js#L16