Giter Site home page Giter Site logo

Comments (4)

prakash-gangadharan avatar prakash-gangadharan commented on July 28, 2024

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.

JohnnyJayJay avatar JohnnyJayJay commented on July 28, 2024

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.

prakash-gangadharan avatar prakash-gangadharan commented on July 28, 2024

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.

prakash-gangadharan avatar prakash-gangadharan commented on July 28, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.