Concrete5 Community Store (Square) not processing payment as an integer - casting

This error is occurring each time I try to put a payment through.
Log shows:
JSON from response body:
{"errors":[{"category":"INVALID_REQUEST_ERROR","code":"EXPECTED_INTEGER","detail":"Expected
an integer value.","field":"amount_money.amount"}]}
I modified line 123 of CommunityStoreSquarePaymentMethod.php from:
"amount" => StoreCalculator::getGrandTotal()*100,
to:
"amount" => number_format(StoreCalculator::getGrandTotal()*100,'',''),
This gave me the error:
Exception Occurred:
/public_html/packages/community_store_square/src/CommunityStore/Payment/Methods/CommunityStoreSquare/CommunityStoreSquarePaymentMethod.php:123
number_format() expects parameter 2 to be integer, string given (2)
So it looks like it's being read as a string instead of an integer. What's the best way to rectify this? I've tried set_type but not sure I understand how to use it as it returns a boolean.

Related

You called the function 'Value Selector' with these arguments

I am in the process of implementing a LoanBroker with Mulesoft but have an error message when sending a request. I get the following error message back from Postman and Mulesoft Anypoint Studio:
ERROR 2021-06-27 15:20:51,133 [[MuleRuntime].uber.04: [loanbroker].LoanBrokerFlow_Gr7.CPU_LITE #254be3ee] [processor: LoanBrokerFlow_Gr7/processors/0; event: 7e49f560-d74a-11eb-b598-b66921dc5aa5] org.mule.runtime.core.internal.exception.OnErrorPropagateHandler:
********************************************************************************
Message: "You called the function 'Value Selector' with these arguments:
1: Binary ("" as Binary {base: "64"})
2: Name ("amount")
But it expects one of these combinations:
(Array, Name)
(Array, String)
(Date, Name)
(DateTime, Name)
(LocalDateTime, Name)
(LocalTime, Name)
(Object, Name)
(Object, String)
(Period, Name)
(Time, Name)
1| payload.amount
^^^^^^^^^^^^^^
Trace:
at main (line: 1, column: 1)" evaluating expression: "payload.amount".
Element : LoanBrokerFlow_Gr7/processors/0 # loanbroker:bi_gruppe7.xml:34 (Copy_of_setAmount)
Element DSL : <set-variable value="#[payload.amount]" doc:name="Copy_of_setAmount" doc:id="cbcca557-1a69-4cf2-80b1-64333175589d" variableName="amount"></set-variable>
Error type : MULE:EXPRESSION
FlowStack : at LoanBrokerFlow_Gr7(LoanBrokerFlow_Gr7/processors/0 # loanbroker:bi_gruppe7.xml:34 (Copy_of_setAmount))
(set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
Can anyone help me?
Thanks
This generally happens when one tries to access inner value of a payload like json but incoming payload is NOT actually a json type.
One could check the payload mediaType and then try to access the amount in order to avoid Value Selector exception.
%dw 2.0
output application/java
---
if( !isEmpty(payload) and payload.^mediaType contains "json" )
payload.amount
else
read(payload, "application/json").amount //best effort
Would recommend creating a separate dataweave file like dwl/set-amount.dwl and referencing it.
You are probably sending some body in the HTTP request from Postman but Mule doesn't know how to read it. Maybe you did not the Content-Type header in the request to let DataWeave know it is a JSON (application/json) or XML (application/XML).
Ensure you are sending the right content type.
I ran into the same situation. I know exactly the base64 is a json. So, I tried to set the MIME Type by
<set-payload value="#[payload]" doc:name="Set Payload" mimeType="application/json"/>
It works for me.

can we pass multiple args in Get Json Value key?

I'm for now fetching one arg value through Get Json Value key
Create Session Get_Inventory_Details ${Base_URL}
${Headers}= Create Dictionary Content-Type=application/json Authorization=bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyTmFtZSI6InByaXRpc3dhaW4iLCJpYXQiOjE1Njc1MTQ2NDd9.o3qTPbj2KH6AgHpIf1BLV5nOlGL-fR83wSGAYyuWsBQ
${Response}= Get Request Get_Inventory_Details inventorybyOutlet/7 headers=${Headers}
Log To Console ${Response.status_code}
Log Many ${Response.content}
${actual_response}= Convert To String ${Response.status_code}
Should Be Equal ${actual_response} 200
${quantity}= Get Json Value ${Response.content} /0/currentInventory
Run Keyword If ${quantity}>10 Log Threshold Condition Pass ELSE Log Threshold Condition Fail
What can be the possible way out if I want to pass more than one arg in Get Json Value
I have tried
${quantity}= Get Json Value ${Response.content} /0/currentInventory/0/itemid
Reference to Json Data
[
{
"isInventoryOperationEnable":1,
"itemId":1,
"name":"Afghani Chicken Tikka Biryani (Heavy Eater)",
"posName":"Afghani Chicken Tikka Biryani (Heavy Eater)",
"image":"https://d30mle0t4iy75h.cloudfront.net/websiteV2/images/menuItems/AfghaniTikkaBiryani.jpg",
"typeid":2,
"isCombo":0,
"currentInventory":100,
"categoryId":1,
"categoryname":"Biryani",
"subCategoryId":1,
"sequenceInCategory":1
},
{
"isInventoryOperationEnable":1,
"itemId":3,
"name":"Chicken Tikka Biryani (Heavy Eater)",
"posName":"Chicken Tikka Biryani (Heavy Eater)",
"image":"https://d30mle0t4iy75h.cloudfront.net/websiteV2/images/menuItems/ChickenTikkaBiryani.jpg",
"typeid":2,
"isCombo":0,
"currentInventory":100,
"categoryId":1,
"categoryname":"Biryani",
"subCategoryId":1,
"sequenceInCategory":14
}
]
But RobotFramework throws error as :-
JsonPointerException: Document '' does not support indexing, must be mapping/sequence or support __getitem__
Error Message on RobotFramework
Please can anyone help in finding out a way how to pass more than 1 arg in this case
Thank You
Create Session Get_Inventory_Details ${Base_URL}
${Headers}= Create Dictionary Content-Type=application/json Authorization=bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyTmFtZSI6InByaXRpc3dhaW4iLCJpYXQiOjE1Njc1MTQ2NDd9.o3qTPbj2KH6AgHpIf1BLV5nOlGL-fR83wSGAYyuWsBQ
${Response}= Get Request Get_Inventory_Details inventorybyOutlet/7 headers=${Headers}
Log To Console ${Response.status_code}
Log Many ${Response.content}
${actual_response}= Convert To String ${Response.status_code}
Should Be Equal ${actual_response} 200
${response_content_json}= To Json ${Response.content} #To Json is from RequestsLibrary
${quantity}= Set Variable ${response_content_json}[0][currentInventory]
Run Keyword If ${quantity}>10 Log Threshold Condition Pass ELSE Log Threshold Condition Fail
In this case, ${quantity} was 100.
Note two things:
after converting to JSON, variable values can be accessed alike dictionary type variables
To JSON keyword is from RequestsLibrary

How to compare CSV to Postman JSON Response values?

How to compare CSV to Postman JSON Response values?
I want to compare CSV values to Postman Response value.
For Ex:
My CSV:
Iteration, City, Ramen
1,"Vancouver",100
2,"San Francisco",84
My End Point:
a link
My Tests:
pm.test("Your test name", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.args.ramen).to.eql(pm.iterationData.get("Ramen"));
});
Note: I get files from below URL. Only tests are mine.
a link
As of now I'm getting below error:
Your test name | AssertionError: expected '84' to deeply equal 84
Try casting the csv integer value to a string and using to.equal instead of to.eql (which is equivalent to to.deep.equal):
pm.expect(jsonData.args.ramen).to.equal(new String(pm.iterationData.get("Ramen")));
Your expected value for "Ramen" from your CSV Datafile is 84 of type Number.
But your Service returns the property "ramen" with value "84" of type String.
Your test fails for a good reason.
Of course you can change your testdata by casting. But this isn't a good test, because you are changing your expected test-data during runtime to become tests green.
If the response is ok, an the testdata not:
You need to store the the "Ramen" Values in your CSV as a String:
1,"Vancouver","100"
2,"San Francisco","84"
and so on.
If the testdata is ok, an the response not:
You have to fix the wrong Servie behaviour.

Error in calling APEX_UTIL.SET_SESSION_MAX_IDLE_SECONDS

I am calling an APEX page from EBS. I have written a code in Before header to set the session values.
lv_profile_value := NVL(xxua_apex_common_pkg.fnd_profile_value
('ICX_SESSION_TIMEOUT'),'0');
:EBS_ICX_SESSION_TIMEOUT := TO_NUMBER(lv_profile_value)*10;
APEX_UTIL.SET_SESSION_MAX_IDLE_SECONDS (p_seconds =>
:EBS_ICX_SESSION_TIMEOUT);
Here the fnd_profile_value for 'ICX_SESION_TIMEOUT' is set to 240.
Now if I use :
:EBS_ICX_SESSION_TIMEOUT := TO_NUMBER(lv_profile_value)*10;
Then I get this error : 'ORA-06502: PL/SQL: numeric or value error: number precision too large'
But If I just write
:EBS_ICX_SESSION_TIMEOUT := TO_NUMBER(lv_profile_value)*9;
Everything works fine. Can somebody please suggest why it gives no error when I multiply by 9(240*9=2160) and gives an error when multiplied by 10 (240*10=2400).
The value gets properly set in my varaible :'EBS_ICX_SESSION_TIMEOUT'
But when APEX_UTIL.SET_SESSION_MAX_IDLE_SECONDS is called it throws this error.
Please suggest.

How to handle return types with multiple fields

I am calling a method "get_text" on GText.buffer detailed here http://oandrieu.nerim.net/ocaml/lablgtk/doc/GText.buffer.html
let text = textView#buffer#get_text in
However as get_text returns multiple values, when I try to use my variable "text" as a string, for example
textView2#buffer#set_text text;
I get the following error message:
Error: This expression has type
?start:GText.iter ->
?stop:GText.iter -> ?slice:bool -> ?visible:bool -> unit -> string
but an expression was expected of type string
How can I access the string being returned by the method? In general, how can I separate the multiple values returned by a method so I can access and use them individually?
I just looked up your link to lablgtk - it looks like you are missing the ():
let text = textView#buffer#get_text () in ...
The problem with this kind of error is that you are using a (curried) function where a string is required, and the message about the type error sounds kind of "long winded" and not to the point.