'JSON format not recognised using Amazon Java SDK

I am using the Amazon Pay SDK with Coldfusion and I have nearly got it over the line. However, I am trying to use the updateCheckoutSession method and it doesn't recognize the arguments for that method. When I call the method I get the following error:

enter image description here

I have tried creating and formatting the JSON as many different ways as I can think of and I just keep getting the same error (error above).

My call to the method:

<!-- Gets the Session ID from the URL -->
<cfset amzSessionId = url.amazonCheckoutSessionId>          
<cfobject action="create" type="java" class="com.amazon.pay.api.WebstoreClient" name="WebstoreClient">
<cfset theJson = '{"webCheckoutDetails":{"checkoutResultReturnUrl":"XXXXXX"},"paymentDetails":{"paymentIntent":"AuthorizeWithCapture","canHandlePendingAuthorization":false,"softDescriptor":"Descriptor","chargeAmount":{"amount":"#orderTotal#","currencyCode":"GBP"}},"merchantMetadata":{"merchantReferenceId":"XXXXXX","merchantStoreName":"XXXXXX"}}'>
<cfset updateResponse = WebstoreClient.updateCheckoutSession(amzSessionId,theJson)>

Below is a CFDUMP of the WebstoreClient and the update method is shown at the bottom.

enter image description here

If you need any additional information I will be glad to provide it.



Solution 1:[1]

I think you are supposed to pass a java JSONObject type variable refer. So the following should theoretically work.

<cfset theJsonString = '{"webCheckoutDetails":{"checkoutResultReturnUrl":"XXXXXX"},"paymentDetails":{"paymentIntent":"AuthorizeWithCapture","canHandlePendingAuthorization":false,"softDescriptor":"Descriptor","chargeAmount":{"amount":"#orderTotal#","currencyCode":"GBP"}},"merchantMetadata":{"merchantReferenceId":"XXXXXX","merchantStoreName":"XXXXXX"}}'>
<cfset theJsonObject = createObject('java', 'org.json.JSONObject').init(theJsonString)>
<cfset updateResponse = WebstoreClient.updateCheckoutSession(amzSessionId, theJsonObject)>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 rrk