All Projects → JacobBennett → Stripetesttoken

JacobBennett / Stripetesttoken

Licence: mit
Use this to quickly generate Stripe test tokens for successful or exceptional responses from Stripe.

Labels

Projects that are alternatives of or similar to Stripetesttoken

React Native Stripe Payments
Lightweight, easy to integrate and use React native library for Stripe payments (using Payment Intents) compliant with SCA (strong customer authentication)
Stars: ✭ 78 (-45.83%)
Mutual labels:  stripe
Commerce.js
Open source, JS eCommerce SDK for building headless, Jamstack applications. Build custom storefronts, carts, and checkouts in any frontend framework, platform, or device. Integrates with Stripe, Square, PayPal, Paymill and Razorpay with support for 135+ currencies.
Stars: ✭ 112 (-22.22%)
Mutual labels:  stripe
Ngx Stripe
Angular 6+ wrapper for StripeJS
Stars: ✭ 128 (-11.11%)
Mutual labels:  stripe
Cordova Plugin Stripe
A Cordova plugin that lets you use Stripe's Native SDKs for Android and iOS.
Stars: ✭ 90 (-37.5%)
Mutual labels:  stripe
Creditcardform Ios
CreditCardForm is iOS framework that allows developers to create the UI which replicates an actual Credit Card.
Stars: ✭ 1,431 (+893.75%)
Mutual labels:  stripe
Stripe Sdk
A simple and flexible Stripe library for Flutter with complete support for SCA and PSD2.
Stars: ✭ 120 (-16.67%)
Mutual labels:  stripe
Firebase Stripe
Headless Stripe Payments Using Firebase Functions
Stars: ✭ 72 (-50%)
Mutual labels:  stripe
Stripe Firebase Extensions
Repository of Firebase Extensions built by Stripe.
Stars: ✭ 133 (-7.64%)
Mutual labels:  stripe
Invoice As A Service
💰 Simple invoicing service (REST API): from JSON to PDF
Stars: ✭ 106 (-26.39%)
Mutual labels:  stripe
Stripe Rs
Rust API bindings for the Stripe HTTP API.
Stars: ✭ 125 (-13.19%)
Mutual labels:  stripe
Chip
A drop-in subscription billing UI for Laravel
Stars: ✭ 91 (-36.81%)
Mutual labels:  stripe
Payumserver
Payment processing microservice. Written in Symfony4
Stars: ✭ 103 (-28.47%)
Mutual labels:  stripe
Payumlaravelpackage
Payum offers everything you need to work with payments. From simplest use cases to very advanced ones.
Stars: ✭ 121 (-15.97%)
Mutual labels:  stripe
Stripe Payments Demo
Sample store accepting universal payments on the web with Stripe Elements, Payment Request, Apple Pay, Google Pay, Microsoft Pay, and the PaymentIntents API. 💳🌍✨
Stars: ✭ 1,287 (+793.75%)
Mutual labels:  stripe
Developer Office Hours
A collection of Stripe Developer Office Hours demos 🎬
Stars: ✭ 130 (-9.72%)
Mutual labels:  stripe
Nuxt Stripe Module
A NuxtJS module to import Stripe client script.
Stars: ✭ 72 (-50%)
Mutual labels:  stripe
Firebase Subscription Payments
Example web client for the `firestore-stripe-subscriptions` Firebase Extension using Stripe Checkout and the Stripe Customer Portal.
Stars: ✭ 119 (-17.36%)
Mutual labels:  stripe
Terraform Provider Stripe
A Terraform Provider for Stripe
Stars: ✭ 143 (-0.69%)
Mutual labels:  stripe
Payum
PHP 7+ Payment processing library. It offers everything you need to work with payments: Credit card & offsite purchasing, subscriptions, payouts etc. - provided by Forma-Pro
Stars: ✭ 1,665 (+1056.25%)
Mutual labels:  stripe
Stripe Ruby
Ruby library for the Stripe API.
Stars: ✭ 1,634 (+1034.72%)
Mutual labels:  stripe

Stripe Test Tokens

Latest Version on Packagist Travis Software License

Use this to quickly create Stripe test tokens for successful and exceptional responses from Stripe.

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

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.

<?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:

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).

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.

$ STRIPE_KEY=sk_test_YourTestKeyHere phpunit tests/

License

This project is open-sourced software licensed under the MIT license

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].