Reputation: 674
I am posting in ajax an object called trxdetails to a cfm page.
// onAuthorize() is called when the buyer approves the payment
onAuthorize: function(data, actions) {
return actions.payment.get()
// PayPal Info
.then( function (paypalinfo) {
console.log(paypalinfo)
})
// Execute Payment
.then(actions.payment.execute)
// Transaction Details
.then( function (trxdetails) {
console.log(trxdetails)
$.ajax({
url: 'PayPalExpress/ajax_trxdetails.cfm',
type: 'post',
data: trxdetails,
success: function(json) {
console.log(json)
}
});
})
//.then(trxdetails => console.log(trxdetails));
}
When I cfdump form, I get these field names:
ID,INTENT,STATE,CART,PAYER[PAYMENT_METHOD],PAYER[STATUS],PAYER[PAYER_INFO][EMAIL],PAYER[PAYER_INFO][FIRST_NAME],PAYER[PAYER_INFO][MIDDLE_NAME],PAYER[PAYER_INFO][LAST_NAME],PAYER[PAYER_INFO][PAYER_ID],PAYER[PAYER_INFO][COUNTRY_CODE],PAYER[PAYER_INFO][SHIPPING_ADDRESS][RECIPIENT_NAME],PAYER[PAYER_INFO][SHIPPING_ADDRESS][LINE1],PAYER[PAYER_INFO][SHIPPING_ADDRESS][CITY],PAYER[PAYER_INFO][SHIPPING_ADDRESS][STATE],PAYER[PAYER_INFO][SHIPPING_ADDRESS][POSTAL_CODE],PAYER[PAYER_INFO][SHIPPING_ADDRESS][COUNTRY_CODE],TRANSACTIONS[0][AMOUNT][TOTAL],TRANSACTIONS[0][AMOUNT][CURRENCY],TRANSACTIONS[0][RELATED_RESOURCES][0][SALE][ID],TRANSACTIONS[0][RELATED_RESOURCES][0][SALE][STATE],TRANSACTIONS[0][RELATED_RESOURCES][0][SALE][PAYMENT_MODE],TRANSACTIONS[0][RELATED_RESOURCES][0][SALE][PROTECTION_ELIGIBILITY],TRANSACTIONS[0][RELATED_RESOURCES][0][SALE][PARENT_PAYMENT],TRANSACTIONS[0][RELATED_RESOURCES][0][SALE][AMOUNT][TOTAL],TRANSACTIONS[0][RELATED_RESOURCES][0][SALE][AMOUNT][CURRENCY],TRANSACTIONS[0][RELATED_RESOURCES][0][SALE][TRANSACTION_FEE][VALUE],TRANSACTIONS[0][RELATED_RESOURCES][0][SALE][TRANSACTION_FEE][CURRENCY]
When i try to output one of them such as:
<cfoutput>#FORM.PAYER[PAYER_INFO][EMAIL]#</cfoutput>
I get this error
Element PAYER is undefined in a Java object of type class [Ljava.lang.String;.
Upvotes: 0
Views: 75
Reputation: 3782
Since your form variable names are like structures you shouldn't access the variables using .
notation. When you use the . variable it will consider as
<cfoutput>#FORM.PAYER[PAYER_INFO][EMAIL]#</cfoutput>
PAYER is a key in Form structure.
instead you can get the data as below
<cfoutput>#FORM["PAYER[PAYER_INFO][EMAIL]"]#</cfoutput>
In this case coldfusion will treat PAYER[PAYER_INFO][EMAIL] as a key in Form structure
Upvotes: 2