File tree Expand file tree Collapse file tree 3 files changed +34
-2
lines changed Expand file tree Collapse file tree 3 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ Stripe Concepts:
64
64
- Create a new stripe account
65
65
- Use the stripe CLI to login to newly created account
66
66
- Create a [ stripe test clock] ( https://dashboard.stripe.com/test/billing/subscriptions/test-clocks ) to simulate time
67
- - This can be done through either the API or dashboard . You should get a test clock id that you'll add to your .env file (needed to run the fixture)
67
+ - This can be done through API. You should get a test clock id that you'll add to your .env file (needed to run the fixture)
68
68
- Example: ` STRIPE_TEST_CLOCK=clock_1PesQ4CAFqbekblQs2oyiGaq `
69
69
- Once you've added your test clock you can use stripe cli to run your fixture. Fixture is located at fixtures/seed.json
70
70
- The fixture will populate customer and subscription data into your stripe account
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ if (!function_exists ('writeNewEnvironmentFileWithClock ' )) {
4
+ function writeNewEnvironmentFileWithClock ($ clockId ): bool
5
+ {
6
+ $ replaced = preg_replace (
7
+ clockReplacementPattern (),
8
+ 'STRIPE_TEST_CLOCK= ' .$ clockId ,
9
+ $ input = file_get_contents (app ()->environmentFilePath ())
10
+ );
11
+
12
+ if ($ replaced === $ input || $ replaced === null ) {
13
+ throw new Exception ('Unable to set application key. No STRIPE_TEST_CLOCK variable was found in the .env file. ' );
14
+ }
15
+
16
+ file_put_contents (app ()->environmentFilePath (), $ replaced );
17
+
18
+ return true ;
19
+ }
20
+ }
21
+
22
+ if (!function_exists ('clockReplacementPattern ' )) {
23
+ function clockReplacementPattern (): string
24
+ {
25
+ $ escaped = preg_quote ('= ' .env ('STRIPE_TEST_CLOCK ' ), '/ ' );
26
+
27
+ return "/^STRIPE_TEST_CLOCK {$ escaped }/m " ;
28
+ }
29
+ }
Original file line number Diff line number Diff line change 23
23
"App\\ " : " app/" ,
24
24
"Database\\ Factories\\ " : " database/factories/" ,
25
25
"Database\\ Seeders\\ " : " database/seeders/"
26
- }
26
+ },
27
+ "files" : [
28
+ " app/helpers.php"
29
+ ]
27
30
},
28
31
"autoload-dev" : {
29
32
"psr-4" : {
You can’t perform that action at this time.
0 commit comments