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:
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" 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.
If you need any additional information I will be glad to provide it.
CodePudding user response:
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)>