@@ -61,6 +61,20 @@ public function __construct($billingSettings = [])
61
61
$ this ->config = $ billingSettings ;
62
62
$ this ->provider = new StripeClient ($ config );
63
63
64
+ if (storage ()->exists (StoragePath ('billing/stripe.json ' ))) {
65
+ $ provider = storage ()->read (StoragePath ('billing/stripe.json ' ));
66
+ $ provider = json_decode ($ provider , true );
67
+
68
+ $ this ->product = $ provider ['product ' ];
69
+ $ this ->tiers = $ provider ['tiers ' ];
70
+ }
71
+ }
72
+
73
+ /**
74
+ * @inheritDoc
75
+ */
76
+ public function initialize (): bool
77
+ {
64
78
if (storage ()->exists (StoragePath ('billing/stripe.json ' ))) {
65
79
$ provider = storage ()->read (StoragePath ('billing/stripe.json ' ));
66
80
$ provider = json_decode ($ provider , true );
@@ -73,13 +87,20 @@ public function __construct($billingSettings = [])
73
87
]);
74
88
75
89
$ this ->product = $ stripeProduct ->id ;
76
- $ this -> initTiers ( $ billingSettings [ ' tiers ' ]);
90
+ }
77
91
78
- storage ()-> createFile ( StoragePath ( ' billing/stripe.json ' ), json_encode ([
79
- ' product ' => $ this ->product ,
80
- ' tiers ' => $ this -> tiers ,
81
- ]), [ ' recursive ' => true ]) ;
92
+ try {
93
+ $ this -> initTiers ( $ this ->config [ ' tiers ' ]);
94
+ } catch ( \ Throwable $ th ) {
95
+ return false ;
82
96
}
97
+
98
+ storage ()->createFile (StoragePath ('billing/stripe.json ' ), json_encode ([
99
+ 'product ' => $ this ->product ,
100
+ 'tiers ' => $ this ->tiers ,
101
+ ]), ['recursive ' => true ]);
102
+
103
+ return true ;
83
104
}
84
105
85
106
protected function initTiers (array $ tierSettings )
0 commit comments