jonpurvis/faker-stripe

Faker provider for generating fake Stripe IDs

v4.0.0 2024-08-26 00:36 UTC

This package is auto-updated.

Last update: 2024-11-19 02:43:10 UTC


README

FakerPHP Stripe ID Provider Banner

FakerPHP Stripe ID Provider

GitHub Workflow Status GitHub last commit Packagist PHP Version GitHub issues GitHub Packagist Downloads

👋 Introduction

This package allows FakerPHP to generate fake IDs which have the same structure you can expect to be returned from Stripe. The wonderful Pest is used to run tests contained within this package, which requires a minimum PHP Version of 8.1.

✨Features

This package can currently generate fake IDs for the following Stripe resources. To avoid any confusion, the names of resources should match what's in this package.

Core Resources

Payment Methods

Products

Checkout

Payment Links

Billing

Connect

Fraud

Issuing

Terminal

Treasury

Entitlements

Sigma

Reporting

Financial Connections

Tax

Identity

Crypto

Climate

Forwarding

Webhooks

📚 Usage / Examples

Pest

it('generates a well structured stripe account id', function () {
   fake()->addProvider(new Stripe(fake()));
   
   expect(fake()->stripeConnectAccountId())->toStartWith('acct_')->toHaveLength(21)->toBeString();
});

PHPUnit

public function testGeneratesWellStructuredStripeAccountId()
{
    $faker = Factory::create();
    $faker->addProvider(new Stripe($faker));

    $this->assertStringStartsWith('acct_', $faker->stripeConnectAccountId());
}

Laravel Factories

use WithFaker;

public function definition(): array
{
    $this->faker->addProvider(new Stripe($this->faker));
    
    return [
        'id' => $this->faker->stripeConnectAccountId(),
        'name' => 'John Doe',
        'email' => 'john.doe@testing.co.uk'
    ];   
}