I am instantiating stripe with composer and attempting to subscribe a customer to a subscription plan in test mode using the card number 4000 0000 0000 0341. The documentation says this will be accepted but then throw an error when used to create a subscription. My questions is, why does the create subscription step always return success with this card number?
My charge code is
<form action="subscribe.php" method="post">
<input type="hidden" name="customer" value="<? echo $stripeID ?>">
<input type="hidden" name="plan" value="<? echo $thisPlan['id'] ?>">
<script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="<?php echo $stripe['publishable_key']; ?>"
data-name="www.example.com"
data-description="<? echo $thisPlan['name'] ?>"
data-amount="<? echo $thisPlan['amount'] ?>"
data-locale="auto"
data-panel-label="Subscribe Now"
data-label="Subscribe"
data-allow-remember-me="false">
</script>
</form>
and my subscribe.php is
try {
$result = \Stripe\Subscription::create(array(
"customer" => $_POST['customer'],
"plan" => $_POST['plan']
));
echo "Subscription successful";
}
catch (Stripe\Error\Base $e) {
// Code to do something with the $e exception object when an error occurs
echo($e->getMessage());
} catch (Exception $e) {
// Catch any other non-Stripe exceptions
}
'Your card was declined.'
as expected. – John C