7
7
use AvoRed \Framework \Models \Database \Configuration ;
8
8
use AvoRed \Framework \Payment \Payment as PaymentEcommerce ;
9
9
use AvoRed \Framework \Payment \Contracts \Payment as PaymentContracts ;
10
+ use AvoRed \Ecommerce \Models \Database \User ;
10
11
11
12
class Payment extends PaymentEcommerce implements PaymentContracts
12
13
{
13
- const CONFIG_KEY = 'payment_stripe_enabled ' ;
14
+ const CONFIG_KEY = 'payment_stripe_enabled ' ;
14
15
15
- const CONFIG_PUBLISHABLE_KEY = 'payment_stripe_publishable_key ' ;
16
+ const CONFIG_PUBLISHABLE_KEY = 'payment_stripe_publishable_key ' ;
16
17
17
- const CONFIG_SECRET_KEY = 'payment_stripe_secret_key ' ;
18
+ const CONFIG_SECRET_KEY = 'avored_stripe_secret_key ' ;
18
19
/**
19
20
* Payment Option Identifier.
20
21
*
@@ -80,8 +81,8 @@ public function process($orderData, $cartProducts, $request)
80
81
$ taxTotal = 0 ;
81
82
82
83
foreach ($ cartProducts as $ product ) {
83
- $ subTotal += $ product[ ' price ' ] * $ product[ ' qty ' ] ;
84
- $ taxTotal += $ product[ ' tax_amount ' ] * $ product[ ' qty ' ] ;
84
+ $ subTotal += $ product-> price () * $ product-> qty () ;
85
+ $ taxTotal += $ product-> tax () * $ product-> qty () ;
85
86
}
86
87
87
88
$ total = (round ($ subTotal , 2 ) + round ($ taxTotal , 2 )) * 100 ;
@@ -90,12 +91,22 @@ public function process($orderData, $cartProducts, $request)
90
91
$ apiKey = Configuration::getConfiguration (self ::CONFIG_SECRET_KEY );
91
92
92
93
Stripe::setApiKey ($ apiKey );
94
+ //dd($orderData);
95
+ //$user = User::find($orderData['user_id']);
96
+ //$customer = \Stripe\Customer::create([
97
+ // 'email' => $user->email,
98
+ // 'description' => 'Customer for One of Charge ' . $user->id,
99
+ // 'source' => $request->get('stripeToken')
100
+ // ]);
101
+
102
+ //dd($request->all());
103
+ //dd($request->get('stripeToken'));
93
104
94
105
$ response = Charge::create ([
95
106
'amount ' => $ totalCents ,
96
107
'currency ' => 'nzd ' ,
97
108
'source ' => $ request ->get ('stripeToken ' ), // obtained with Stripe.js
98
- 'description ' => 'AvoRed E commerce ' ,
109
+ 'description ' => 'AvoRed E commerce Payment ' ,
99
110
]);
100
111
101
112
return $ response ;
0 commit comments