Forum
CountryID with Perch Shop & Braintree
I'm having trouble with checkout via Braintree.
I'm currently testing in sandbox and the payment is coming back failed with the following debug message:
...
SELECT * FROM perch2_shop_customers WHERE customerID='11' AND customerDeleted IS NULL LIMIT 1
[1] SELECT * FROM perch2_shop_addresses WHERE addressID=82 AND addressDeleted IS NULL LIMIT 1
[1] SELECT * FROM perch2_shop_addresses WHERE addressID=81 AND addressDeleted IS NULL LIMIT 1
[1] SELECT * FROM perch2_shop_countries WHERE countryID='0' LIMIT 1
No country set for address
[1] SELECT * FROM perch2_shop_countries WHERE countryID='0' LIMIT 1
No country set for address
Payment failed
...
My checkout doesn't require an address, the goods that are being sold through the site are collected from the store so there is no need for a shipping address, but do I still require a billing address for this to work? I was hoping I could just register a user with first name, last name, phone and email (passwordless) and then take credit card details for payment. I also tried setting a default for the country during registration with a hidden field <perch:input type="hidden" id="country_name" value="157" />
but that does not seem to work.
Here is some more of the debug, including the response from Braintree:
...
[params] => Array
(
[transaction] => Array
(
[type] => sale
[amount] => 20.00
[orderId] => 35
[paymentMethodNonce] => dab7bd21-bbc9-0e00-2588-d95c0c05ce5c
[billing] => Array
(
[company] => false
[firstName] => Hamish
[lastName] => Irving
[streetAddress] => false
[extendedAddress] => false
[locality] => false
[postalCode] => false
[region] => false
[countryName] => false
)
[shipping] => Array
(
[company] => false
[firstName] => Hamish
[lastName] => Irving
[streetAddress] => false
[extendedAddress] => false
[locality] => false
[postalCode] => false
[region] => false
[countryName] => false
)
[options] => Array
(
[submitForSettlement] => true
)
)
)
[message] => Country name is not an accepted country.
[creditCardVerification] =>
[transaction] =>
[subscription] =>
[merchantAccount] =>
[verification] =>
)
...
It should be enough to set the country as a hidden field, yes.
Thanks, thats encouraging, however it isn't collecting the country. Can you see any errors with what I am doing?
My registration form
register.html
Called on my
register.php
pageYou are setting a country number there, it seems to want a country name based on that message. Have you checked to see what it is expecting?
Hi Rachel, not sure how I should check to see what it is expecting? I'm assuming Perch needs to accept a country first and then pass it to Braintree?
We do also check for
address_1
being set as evidence of an address being correctly configured, so you could set that to a fixed value and see if that helps.OK, I've got both the
countryID
andaddress_1
populating in the DB, I can see inperch2_shop_addresses
table..However, now after I click to submit a payment in sandbox, I get the following error on my
checkout.php
page after it submits to Braintree?Are you checking the customer is logged in before checkout?
Yes, using the following on
checkout.php
pageOK, managed to get it working - I could see from the
perch2_shop_countries
table thatcountryID
is expecting a number (in my case New Zealand = 157)Having both
countryID
andaddress_1
set has got it working