Error related to decimal format when spring application try make a payment with PayPal -
In my current spring project, I recently added support to PayPal. But right now, the payment has only been exhausted when I have tightened the values of the amount in the source code. The methods that handle the payment process in my service category mount the variable where this value is stored in this way:
decimalf df = new substitute ("0.00"); Float value = hero (client); String svalue = df.format (value) .replace (',', '.'); System.out.println ("valor =" + value); System.out.println ("hero (string) =" + tailoring); Description Details = New Description (); Details.setShipping ("0"); Details .Setbottle (Silv); Details.setTax ("0"); Zodiac = new amount (); Amount.setCurrency ("BRL"); Zodiac. Settool (silva); Amount.setDetails (description); Transaction Transactions = New Transactions (); Transaction.setAmount (amount); Transaction.setDescription (select "No Site Loose On Line");
When I run the application and try to pay, I get this error:
Depth: Error code: with 400 responses : {"Name": "VALIDATION_ERROR", "details": [{"field": "transaction [0]. Monetary digit", "issue": "The amount of currency should be a non-negative number, alternatively alternative form From two decimal places to '' ', optional thousands separators',', decimal digits "}, {" field ":" transaction [0] .mount.details.subtotal "," issue " The first is limited to 7 digits: "limited to 7 digits prior to" currency amount non-negative number, alternatively decimal point "}", alternate thousands separator ',' alternatively by two decimal places alternatively Can be included: "Invalid request - view details", "notification_link": "http://ttg.developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR", "debug_id": "9639791c47625"} < / Code>
Can anyone tell me what I am remembering here? I think that decimalf df = new To use Dsmlvfl ( "0.00");
The total value should be enough to format my subtotals, but apparently I am doing something wrong.
It looks like when you pass the "code" in the zodiac sign in the svalue. ; " String type
I will advise you to do this:
Amount .Setallol (float .Parflat (Silv));
and also here:
details.setSubtotal (svalue);
to details.setSubtotal (Float.parseFloat (svalue));
Comments
Post a Comment