File tree Expand file tree Collapse file tree 1 file changed +61
-0
lines changed Expand file tree Collapse file tree 1 file changed +61
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ namespace Code4mk \LaraStripe ;
3
+
4
+ /**
5
+ * @author @code4mk <[email protected] >
6
+ * @author @kawsarsoft <[email protected] >
7
+ * @copyright Kawsar Soft. (http://kawsarsoft.com)
8
+ */
9
+
10
+ use Stripe \Stripe ;
11
+ use Stripe \Token ;
12
+ use Stripe \Charge ;
13
+ use Stripe \Balance ;
14
+ use Stripe \PaymentIntent ;
15
+ use Config ;
16
+
17
+ class StripePaymentIntent
18
+ {
19
+ /**
20
+ * secret key
21
+ * @var string
22
+ */
23
+ private $ secretKey ;
24
+
25
+ public function __construct ()
26
+ {
27
+ if (config::get ('lara-stripe.driver ' ) === 'config ' ) {
28
+ $ this ->secretKey = config::get ('lara-stripe.secret_key ' );
29
+ }
30
+ }
31
+
32
+ /**
33
+ * Set secret key
34
+ * @param array $data
35
+ * @return $this
36
+ */
37
+ public function setup ($ data )
38
+ {
39
+ if ($ data ['secret_key ' ]) {
40
+ $ this ->secretKey = $ data ['secret_key ' ];
41
+ }
42
+ return $ this ;
43
+ }
44
+
45
+ /**
46
+ * Get balance
47
+ * @return object
48
+ */
49
+ public function create ()
50
+ {
51
+ try {
52
+ Stripe::setApiKey ($ this ->secretKey );
53
+ return PaymentIntent::create ([
54
+ 'amount ' => 1000 ,
55
+ 'currency ' => 'usd '
56
+ ]);
57
+ } catch (\Exception $ e ) {
58
+ return (object )['isError ' => 'true ' ,'message ' => $ e ->getMessage ()];
59
+ }
60
+ }
61
+ }
You can’t perform that action at this time.
0 commit comments