Jump to content
Larry Ullman's Book Forums

Recommended Posts

I'm receiving the Stripe programming error:

       catch (Stripe_InvalidRequestError $e)

 

I know it is because I added data to the Charge array. It works without the new data but not with it.

Here's the code and I don't see the error:

	$charge = Stripe_Charge::create(array(
	  "amount" => $amount, // amount in cents, again
	  "currency" => "usd",
          "source" => $token,
      	  "address_line1" => $ad,  
      	  "address_city" => $ct,
      	  "address_state" => $st, 
      	  "address_zip" => $zip,
      	  "address_country" => "US", 
          "receipt_email" => $em,
          "receipt_number" => $uid,
      	  "name" => $fn . $ln,
          "shipping" => 0,
          "statement_descriptor" => "BCA Creative.com " . $prod_name,
          "metadata[uid]"=>$uid, 
          "metadata[pid]"=>$pid, 
	  "description" => $prod_name
	 )
	);

Share this post


Link to post
Share on other sites

I'd first check the actual error message in $e, or look in your Stripe Dashboard at the logs. This is the best solution to debugging this, as Stripe is already telling you the specific problem. 

 

Just guessing, though, I suspect the problem is how you're doing the metadata. You need to provide one metadata argument but that argument's value can be an array or JSON. 

Share this post


Link to post
Share on other sites

Thanks for pointing me in the right direction, Larry.

I didn't notice that $e variable so now I could echo it.

Turns out the metadata was correct.

My descriptor was too long so I will have to check that size.

The only thing is, the following parameters still show the following error:

 

The error is exception 'Stripe_InvalidRequestError' with message 'Received unknown parameters: address_line1, address_city, address_state, address_zip, address_country, receipt_number, name'

 

I thought this information is something I can provide to Stripe and they will do an address check and such.

The $charge returns those values, but they are empty, of course.

Maybe you know how I can pass this information in. Although, I don't need it returned, it is only useful if Stripe uses it.

Share this post


Link to post
Share on other sites

Thanks again for helping out.

I have been reading the docs but there is just so much information and trying to pull it all together is where I am at.

I added those address fields to the charge form and received no errors.

However, when the charge is returned, that information is blank.

So I'm thinking there is something formatting problem and maybe you know what it is.

By the way, does Stripe have a forum or should I ask these questions of their tech support?

 

This is what my form looks like:

	<form action="" method="POST" id="payment-form">
		<?php // Show PHP errors, if they exist:
		if (isset($errors) && !empty($errors) && is_array($errors)) {
			echo '<div class="alert alert-error"><h4>Error!</h4>The following error(s) occurred:<ul>';
			foreach ($errors as $e) {
				echo "<li>$e</li>";
			}
			echo '</ul></div>';
		}?>
		<div id="payment-errors"></div>
		<span class="help-block">You can pay using: Mastercard, Visa, American Express, JCB, Discover, and Diners Club.</span>
		<div class="alert alert-info"><h4>JavaScript Required!</h4>For security purposes, JavaScript is required in order to complete an order.</div>

		<label>name</label>
		<input type="text" readonly="readonly" disabled="disabled" value="<?php echo $fn . ' ' .  $ln; ?>" />
		<label>address_line1</label>
		<input type="text" readonly="readonly" disabled="disabled" value="<?php echo $ad; ?>" />
		<label>address_city</label>
		<input type="text" readonly="readonly" disabled="disabled" value="<?php echo $ct; ?>" />
		<label>address_state</label>
		<input type="text" size="2" readonly="readonly" disabled="disabled" value="<?php echo $st; ?>" />
		<label>address_zip</label>
		<input type="text" size="5" readonly="readonly" disabled="disabled" value="<?php echo $zip; ?>" />
		<label>address_country</label>
		<input type="text" size="2" readonly="readonly" disabled="disabled" value="US" /><br><br>

		<label>Card Number</label>
		<input type="text" size="20" autocomplete="off" class="card-number input-medium">
		<span class="help-block">Enter the number without spaces or hyphens.</span>
		<label>CVC</label>
		<input type="text" size="4" autocomplete="off" class="card-cvc input-mini">
		<label>Expiration (MM/YYYY)</label>
		<input type="text" size="2" class="card-expiry-month input-mini">
		<span> / </span>
		<input type="text" size="4" class="card-expiry-year input-mini">
		<button type="submit" class="btn" id="submitBtn">Submit Payment</button>
	</form>

Share this post


Link to post
Share on other sites

Hey! Stripe doesn't have its own forums, but there's chat on IRC on freenode or you can email support. 

 

I think the confusion here is the difference between a payment source--such as a credit card--and the use of that source: e.g., a charge. Things like the address are relevant to the payment source. They don't get provided to the charge nor are they reflected on the charge (although they would be reflected on the `source` attribute of the charge). 

 

Again your logs in the Stripe Dashboard will show everything sent to Stripe and received from Stripe.

 

You should also make sure that your JavaScript is passing along all the values in the token creation request. 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...