Do you like this bundle? Leave a ★ or run composer global require symfony/thanks && composer thanks
to say thank you to all libraries you use in your current project, this included!
When a credit card is associated with a Customer or it is charged, may happen some errors.
Stripe provides a list of test cards to use to test some scenarios.
Lets recap the flows: to make a payment using Stripe (for a Charge or for a Subscription) you have to:
- Create a Customer;
- Associate a Card/Source to this Customer.
- Charge the Customer's credit card/source (with a Charge or with a Subscription).
You can associate a card/source to a Customer in two ways:
- Associating the card/source to the Customer when you create the Customer (in one API call);
- First creating the Customer and then associating a card/source to it (in two calls).
Last thing: errors may arise in two cases:
- When the card is created;
- When the card is charged.
Well understand these differences is very important as this will help you identify errors and reasons of them.
For example, it required us a lot of time to spot the logic behind the different behaviors of a card_declined
with a
generic_decline
reason and of a card_declined
with a fraudulent
reason.
We will better explain this difference very soon. For the moment put your best efforts to maintain the concentration on what we are writing!
So, finally, we have three things to remember:
- The payment flow (Create Customer, associate a card to it, charge the card);
- How to associate a Card/Source to a Customer (in one call, when creating a new Customer; or in two calls, associating it to an already existing Customer);
- Errors may happen when the card is being created and associated to a Customer or when it is charged,
Despite the structure of the Stripe's documentation, there are three main scenarios:
- You create the Customer and at the same time associate a card;
- You first create a customer and then associate the card.
- You have a Customer and you create a Charge for him/her.
In the next paragraphs we will examine the behaviors of Stripe and how this bundle handles them.
Exposing the scenarios, we will use the test cards and we will show them here from the most simple ones to the most complex ones.
Here we will show what happens if you try to use those credit card numbers while creating a Customer.
So, what you are doing is create a Customer and at the same time associating a Card to it.
Described Behavior: The address_line1_check
and address_zip_check
verifications fail. If your account is
blocking payments that fail postal code validation, the
charge is declined.
Not fully tested yet. Please, provide feedbacks opening an issue.
Described Behavior: Charge succeeds but the address_line1_check
verification fails.
Not fully tested yet. Please, provide feedbacks opening an issue.
Descripted behavior: The address_zip_check verification fails. If your account is blocking payments that fail postal code validation, the charge is declined.
Not fully tested yet. Please, provide feedbacks opening an issue.
Descripted behavior: Charge succeeds but the address_zip_check
and address_line1_check
verifications are both
unavailable
.
Not fully tested yet. Please, provide feedbacks opening an issue.
Descripted behavior: If a CVC number is provided, the cvc_check
fails. If your account is blocking payments that
fail CVC code validation, the charge is declined.
Stripe Behavior: no customer is created (and so, no card associated and no charge created)
Bundle Returned error: stripe.card_error.incorrect_cvc
Bundle Behavior: no customer is created (and so, no card associated and no charge created)
Descripted behavior: Attaching this card to a Customer object succeeds, but attempts to charge the customer fail.
Stripe Behavior: Creates the Customer, associates the card, creates the Charge but then marks it as fraudulent
Bundle Returned error: stripe.card_error.card_declined.generic_decline
Bundle Behaior: Saves the same data and associates the error to the card. The Charge is filled with fictional data that are then updated by the webhook event sent by Stripe.
Descripted behavior: Charge succeeds with a risk_level
of elevated
and placed into review.
Stripe Behavior: Customer created, card associated, Charge created but put in manual review queue. A review
event
is sent other than the customer
, card
and charge
ones.
Bundle Behavior: Customer created, card associated, Charge created
Descripted behavior: Charge is declined with a card_declined
code.
Stripe Behavior: no customer is created (and so, no card associated and no charge created)
Bundle Returned error: stripe.card_error.card_declined.generic_decline
Bundle Behavior: no customer is created (and so, no card associated and no charge created)
Descripted behavior: Charge is declined with a card_declined
code and a fraudulent
reason.
Stripe Behavior: Creates the Customer, associates the card, creates the Charge but then marks it as fraudulent
Bundle Returned error: stripe.card_error.card_declined.fraudulent
Bundle Behaior: Saves the same data and associates the error to the card. The Charge is filled with fictional data that are then updated by the webhook event sent by Stripe.
Descripted behavior: Charge is declined with a incorrect_cvc
code.
Stripe Behavior: no customer is created (and so, no card associated and no charge created)
Bundle Returned error: stripe.card_error.incorrect_cvc
Bundle Behavior: no customer is created (and so, no card associated and no charge created)
Descripted behavior: Charge is declined with a expired_card
code.
Stripe Behavior: no customer is created (and so, no card associated and no charge created)
Bundle Returned error: stripe.card_error.expired_card
Bundle Behavior: no customer is created (and so, no card associated and no charge created)
Descripted behavior: Charge is declined with a processing_error
code.
Stripe Behavior: no customer is created (and so, no card associated and no charge created)
Bundle Returned error: stripe.card_error.processing_error
Bundle Behavior: no customer is created (and so, no card associated and no charge created)
Descripted behavior: Charge is declined with an incorrect_number code as the card number fails the Luhn check.
Bundle Returned error: The form sending is blocked by JavaScript (remember that if JS is disabled a
stripe.card_error.missing
error is anyway returned as it is not possible to get the card token from Stripe)
Do you like this bundle?
LEAVE A ★
or run
composer global require symfony/thanks && composer thanks
to say thank you to all libraries you use in your current project, this included!