Comments (4)
Hi @JohnnyJayJay, through the PayPal-Debug-ID which you have given in the description, I can see that the total_amount and minimum_amount_due value is set as 0.0.
Can you check with your integration again ?
Thanks!
from paypal-java-sdk.
I can see that the total_amount and minimum_amount_due value is set as 0.0.
That is correct. This was the only amount that worked before, that's why I used it. For any other amount, I used to get the error "Minimum amount is bigger than total amount". After some debugging and having failed to find anything that could be causing this, I thought that had to do with me running in sandbox and didn't investigate any further.
Now, I get the same 400 Response for any amount.
from paypal-java-sdk.
Hi @JohnnyJayJay
When you take look into the below doc link for Create draft invoice,
https://developer.paypal.com/docs/api/invoicing/v1/#invoices_create
There is no direct request parameter like total_amount. total_amount
field is a read only field on the invoice resource and it is not valid in the invoice creation request. Documentation lists out all valid fields accepted in create invoice request. If you wish to only provide total amount, you should include a single item with that amount in the request.
Below is the example request body which you are trying to use.
Sample erroneous request payload:
{
"number": "ba1542a",
"merchant_info": {
"email": "*** MASKED ***",
"first_name": "Dennis",
"last_name": "Doctor",
"business_name": "Medical Professionals, LLC"
},
"total_amount": {
"currency": "USD",
"value": "110.0"
},
"allow_partial_payment": true,
"minimum_amount_due": {
"currency": "USD",
"value": "20.0"
},
"currencyCode": "USD"
}
Error response:
{
"name": "BUSINESS_ERROR",
"message": "Minimum Due Amount cannot be greater than Total Amount.",
"information_link": "https://developer.paypal.com/docs/api/invoicing/#errors",
"debug_id": "e713060cb1ff5"
}
from paypal-java-sdk.
@JohnnyJayJay, try adding the amount via items array.
items array
(contains the invoice_item object)
An array of invoice line item information.
https://developer.paypal.com/docs/api/invoicing/v1/#definition-invoice_item
Sample Request payload:
{
"number": "ba1542b",
"merchant_info": {
"email": "*** MASKED ***",
"first_name": "Dennis",
"last_name": "Doctor",
"business_name": "Medical Professionals, LLC"
},
"items": [
{
"name": "Sutures",
"quantity": 110,
"unit_price": {
"currency": "USD",
"value": "5"
}
}
],
"allow_partial_payment": true,
"minimum_amount_due": {
"currency": "USD",
"value": "20.0"
},
"currencyCode": "USD"
}
Example code block where I can able to set minimum_amount_due value successfully.
try {
APIContext context = new APIContext(clientID, clientSecret, mode);
MerchantInfo merchantInfo = new MerchantInfo();
merchantInfo.setEmail("*** MASKED ***");
merchantInfo.setFirstName("Dennis");
merchantInfo.setLastName("Doctor");
merchantInfo.setBusinessName("Medical Professionals, LLC");
Currency unitPrice = new Currency().setCurrency("USD").setValue(Double.toString(110));
Currency minimum_amount_due = new Currency().setCurrency("USD").setValue(Double.toString(20));
// ### Items
InvoiceItem item = new InvoiceItem();
item.setName("Ground Coffee 40 oz").setQuantity(1).setUnitPrice(unitPrice);
List<InvoiceItem> items = new ArrayList<InvoiceItem>();
items.add(item);
Invoice invoice = new Invoice();
invoice.setAllowPartialPayment(true)
.setItems(items)
.setMinimumAmountDue(minimum_amount_due)
.setNumber(invoice.generateNumber(context).getNumber())
.setMerchantInfo(merchantInfo)
.create(context)
.setBillingInfo(Collections.singletonList(new BillingInfo().setEmail("[email protected]")))
.send(context);
} catch (JsonSyntaxException e) {
e.printStackTrace();
} catch (JsonIOException e) {
e.printStackTrace();
} catch (PayPalRESTException e) {
e.printStackTrace();
}
from paypal-java-sdk.
Related Issues (20)
- Constantly getting ACCOUNT_CANNOT_BE_FETCHED HOT 2
- New subscription api implemntation HOT 9
- Getting INVALID_RESOURCE_ID when trying to authorize an order created client side with ngx_paypal HOT 2
- Only in some cases this error is happening: VALIDATION_ERROR Invalid request - see details field: redirect_urls.return_url HOT 2
- getpayment command is failure. HOT 1
- How to download statement in excel format using Java language HOT 2
- Links for Self, Approval URL, and Execute Do Not Work HOT 8
- Question: Does Transaction class hold transaction ID and execution timestamp? HOT 2
- InvoiceSample has wrong developer docs links, i.e the links mentioned in the InvoiceSample java file is not working. HOT 1
- 2 factor Authentication HOT 6
- Error while running Rest API Sample's credit card save & retrieve examples under Vault section HOT 2
- Rest API Sample's Validate Webhook example under Payments section gives out Error responses HOT 1
- pay servlet returns nul value for authentication HOT 2
- payment using sandbox account in java HOT 9
- Unable to import into Eclipse HOT 6
- Reasons for Sale Object having a state of 'pending' after executing a payment via REST API HOT 1
- Using Event.get() in webhook listener HOT 5
- Wrong amount: Transaction amount details (subtotal, tax, shipping) must add up to specified amount total HOT 1
- Event.validateReceivedEvent throw error webhook.id cannot be null HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from paypal-java-sdk.