2017 © Pedro PelĂĄez
 

library stripe-test-token

Quickly create Stripe test tokens for successful and exceptional Stripe responses.

image

jacobbennett/stripe-test-token

Quickly create Stripe test tokens for successful and exceptional Stripe responses.

  • Tuesday, March 20, 2018
  • by JacobBennett
  • Repository
  • 2 Watchers
  • 104 Stars
  • 5,917 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 10 Forks
  • 0 Open issues
  • 11 Versions
  • 17 % Grown

The README.md

, (*1)

Stripe Test Tokens

Latest Version on Packagist Travis Software License, (*2)

Use this to quickly create Stripe test tokens for successful and exceptional responses from Stripe., (*3)

Install

composer require jacobbennett/stripe-test-token

Usage

<?php

use JacobBennett\StripeTestToken;
use Stripe\Charge;

StripeTestToken::setApiKey('your_stripe_secret_test_key');

// Fake a Successful Charge

Charge::create([
        'amount' => 500,
        'currency' => 'usd',
        'source' => StripeTestToken::validVisa(),
]);


// Fake a Failing Charge

try {

        Charge::create([
                'amount' => 500,
                'currency' => 'usd',
                'source' => StripeTestToken::cvcFail(),
        ]);

} catch (\Stripe\Error\Card $e) {
        // handle errors
}

Docs

Find full descriptions at original Stripe Docs Reference, (*4)

Using Methods

To use any of the methods below, call the listed method as a static on the StripeTestToken class. If you only want to return the corresponding card number, such as with Selenium or Laravel Dusk, you can call the same method on the StripeCardNumber class., (*5)

<?php 

\JacobBennett\StripeCardNumber::validVisa(); // Returns the valid Visa card number 4012888888881881
\JacobBennett\StripeTestToken::validVisa(); // Attempts to generate a token against the Stripe API for a valid Visa card

Test card numbers

Genuine card information cannot be used in test mode. Instead, use any of the following test card methods to create a successful payment token:, (*6)

Method
validVisa
validVisaDebit
validMastercard
validMastercardDebit
validMastercardPrepaid
validAmex
validDiscover
validDinersClub
validJCB

Testing for specific responses and errors

The following methods can be used to create tokens that produce specific responses—useful for testing different scenarios and error codes. Verification checks only run when the required information is provided (e.g., for cvc_check to fail, a CVC code must be provided)., (*7)

Method Description
successDirectToBalance Charge succeeds and funds will be added directly to your available balance (bypassing your pending balance).
addressZipFail The address_line1_check and address_zip_check verifications fail. If your account is blocking payments that fail ZIP code validation, the charge is declined.
addressFail Charge succeeds but the address_line1_check verification fails.
zipFail The address_zip_check verification fails. If your account is blocking payments that fail ZIP code validation, the charge is declined.
addressZipUnavailable Charge succeeds but the address_zip_check and address_line1_check verifications are both unavailable.
cvcFail 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.
customerChargeFail Attaching this card to a Customer object succeeds, but attempts to charge the customer fail.
successWithReview Charge succeeds with a risk_level of elevated and placed into review.
declineCard Charge is declined with a card_declined code.
declineFraudulentCard Charge is declined with a card_declined code and a fraudulent reason.
declineIncorrectCvc Charge is declined with an incorrect_cvc code.
declineExpiredCard Charge is declined with an expired_card code.
declineProcessingError Charge is declined with a processing_error code.
declineIncorrectNumber Charge is declined with an incorrect_number code as the card number fails the Luhn check.

Testing

In order to run the full test suite, you must have STRIPE_KEY set in your environment, as the test will hit the Stripe API in order to generate a test token., (*8)

$ STRIPE_KEY=sk_test_YourTestKeyHere phpunit tests/

License

This project is open-sourced software licensed under the MIT license, (*9)

The Versions

20/03 2018

dev-master

9999999-dev https://github.com/JacobBennett/StripeTestToken

Quickly create Stripe test tokens for successful and exceptional Stripe responses.

  Sources   Download

MIT

The Requires

 

The Development Requires

stripe stripe-test-token

20/03 2018

v1.0.2

1.0.2.0 https://github.com/JacobBennett/StripeTestToken

Quickly create Stripe test tokens for successful and exceptional Stripe responses.

  Sources   Download

MIT

The Requires

 

The Development Requires

stripe stripe-test-token

24/10 2017

v1.0.1

1.0.1.0 https://github.com/JacobBennett/StripeTestToken

Quickly create Stripe test tokens for successful and exceptional Stripe responses.

  Sources   Download

MIT

The Requires

 

The Development Requires

stripe stripe-test-token

18/07 2017

dev-patch-2

dev-patch-2 https://github.com/JacobBennett/StripeTestToken

Quickly create Stripe test tokens for successful and exceptional Stripe responses.

  Sources   Download

MIT

The Requires

 

The Development Requires

stripe stripe-test-token

18/07 2017

dev-patch-1

dev-patch-1 https://github.com/JacobBennett/StripeTestToken

Quickly create Stripe test tokens for successful and exceptional Stripe responses.

  Sources   Download

MIT

The Requires

 

The Development Requires

stripe stripe-test-token

04/01 2017

v1.0.0

1.0.0.0 https://github.com/JacobBennett/StripeTestToken

Quickly create Stripe test tokens for successful and exceptional Stripe responses.

  Sources   Download

MIT

The Requires

 

The Development Requires

stripe stripe-test-token

04/01 2017

dev-docs/jb_readme

dev-docs/jb_readme https://github.com/JacobBennett/StripeTestToken

Quickly create Stripe test tokens for successful and exceptional Stripe responses.

  Sources   Download

MIT

The Requires

 

The Development Requires

stripe stripe-test-token

04/01 2017

v0.4

0.4.0.0 https://github.com/JacobBennett/StripeTestToken

Quickly create Stripe test tokens for successful and exceptional Stripe responses.

  Sources   Download

MIT

The Requires

 

The Development Requires

stripe stripe-test-token

29/12 2016

v0.3

0.3.0.0 https://github.com/JacobBennett/StripeTestToken

Quickly create Stripe test tokens for successful and exceptional Stripe responses.

  Sources   Download

MIT

The Requires

 

stripe stripe-test-token

28/12 2016

v0.2

0.2.0.0 https://github.com/JacobBennett/StripeTestToken

Quickly create Stripe test tokens for successful and exceptional Stripe responses.

  Sources   Download

MIT

The Requires

 

stripe stripe-test-token

18/12 2016

v0.1

0.1.0.0 https://github.com/JacobBennett/StripeTestToken

Quickly create Stripe test tokens for successful and exceptional Stripe responses.

  Sources   Download

MIT

The Requires

 

stripe stripe-test-token