Hi @sudox,
Are you still having problems with this? If so, here's what I've found out.
I'm looking at your code, and I'm not seeing any problem with the form post to call the payment form. Nor am I seeing any problem with the process of requesting a token. You're getting a token back, so that's fundamentally sound.
That leaves a couple of possibilities. We could have some weird problem on our end, although I'm not aware of one. Or, the other possibility is in the data you're actually encoding in the token.
When you request the token, the process that creates the token doesn't actually do a lot of checking of the values that you're sending beyond basic sanity checking. Since a lot of the values that you're sending in the request aren't used until the payment form is loaded or submitted, whether or not they're "valid" is dependent on what happens after the payment form gets loaded.
The general idea is to just encode everything you send in, and let the payment form figure out if it's going to work or not. It's possible that you might be sending in a value in the request that doesn't quite make sense once the payment form gets a hold of it.
It's great that you posted your token request code. Using it, I've tried to recreate what you're doing as precisely as I can, and when I do, I get the same error. I go through your token request, changing things one by one, and narrow down the problem to what you're sending for the button name, specifically the ampersand. When I take the ampersand out, it works fine.
The SDK's responsible for turning what you send into an XML formatted request to our API, and it's doing that fine, including encoding the ampersand. If I make a raw XML request myself the same way the SDK would I'd do this:
<setting>
<settingName>hostedPaymentButtonOptions</settingName>
<settingValue>{"text": "Finish & Pay"}</settingValue>
</setting>
...and I would get the same problem.
Something's happening either in the encoding of the token where the ampersand gets encoded as some poison data that breaks the payment form on load, or the token encoding puts the ampersand in correctly, but the payment form display code breaks when it sees it (because it messes up some string parsing or something).
Either way, the workaround for you (for now) is to change the button text to something like "Finish and Pay" or "Finish / Pay".
Sorry about this. Thanks so much for posting this here, though. These are the kinds of bugs I love: takes some work to figure out how to reproduce, but 100% reproducible when you do. I'll get this escalated right away.