InvalidIavToken


#1

I am testing creating a funding source through Dwolla.js and am now getting InvalidIavToken. The only guidance for this error mentions getting the same IavToken every time it is run, but I am getting a new one every time.
I am able to create the customer without any problem. I get a new IAV token, but it is not accepted. Below is the code I am working with, using PHP.
Thanks for your time.

<?php $dwolla_api_url = 'https://api-sandbox.dwolla.com'; $apiClient = new DwollaSwagger\ApiClient($dwolla_api_url); $customersApi = new DwollaSwagger\CustomersApi($apiClient); $customer = $customersApi->create([ 'firstName' => $current_user->user_firstname, 'lastName' => $current_user->user_lastname, 'email' => $current_user->user_email, 'type' => 'receive-only', 'businessName' => $b_name, 'ipAddress' => $ip ]); $myCustomerId = explode("/",$customer)[4]; //ugly but works for now $myUrl = $dwolla_api_url . "/customers/" . $myCustomerId; $iavToken = $customersApi->getCustomerIavToken($myUrl); ?>
<script type="text/javascript">
     dwolla.iav.start('<?php echo $iavToken->token; ?>', {
					container: 'iavContainer',
					stylesheets: [
						'https://fonts.googleapis.com/css?family=Lato&subset=latin,latin-ext'
					],
					  microDeposits: false,
					  fallbackToMicroDeposits: true,
					  backButton: true,
					  subscriber: ({ currentPage, error }) => {
						  console.log('currentPage:', currentPage, 'error:', JSON.stringify(error))
						}
					}, function(err, res) {
				  console.log('Error: ' + JSON.stringify(err) + ' -- Response: ' + JSON.stringify(res));
	});

Here is a sample of the last javascript from the client:
<script type=“text/javascript”>
dwolla.iav.start(‘aWLL3WIYAMJNeYKGUiju0XQnghv12wJyvwNCO9lUzDIQxLXfQr’, {
container: ‘iavContainer’,
stylesheets: [
https://fonts.googleapis.com/css?family=Lato&subset=latin,latin-ext
],
microDeposits: false,
fallbackToMicroDeposits: true,
backButton: true,
subscriber: ({ currentPage, error }) => {
console.log(‘currentPage:’, currentPage, ‘error:’, JSON.stringify(error))
}
}, function(err, res) {
console.log('Error: ’ + JSON.stringify(err) + ’ – Response: ’ + JSON.stringify(res));
});


(Spencer Hunter) #2

Hi @stephenEnact, thanks for posting! After reviewing your code snippet it appears you’re calling our sandbox to fetch an IAV token. By default, dwolla.js will point to our production environment unless a configuration is set to specify sandbox. Referenced here in our docs, prior to calling dwolla.iav.start() you’ll want to pass in a configuration of:

dwolla.configure('sandbox');

Hope this helps, let us know if this resolves the issue you are running into!


#3

Thanks. That fixed it. I had that command on the form post, so it hadn’t happened yet.