4
4
5
5
namespace Canvas \Api \Controllers ;
6
6
7
- use Canvas \Models \AppsPlans ;
8
- use Stripe \Token as StripeToken ;
9
- use Phalcon \Http \Response ;
10
- use Stripe \Customer as StripeCustomer ;
11
- use Phalcon \Validation \Validator \PresenceOf ;
12
7
use Baka \Http \Exception \NotFoundException ;
13
- use Baka \Http \Exception \UnauthorizedException ;
14
8
use Baka \Http \Exception \UnprocessableEntityException ;
9
+ use Baka \Validation as CanvasValidation ;
10
+ use Canvas \Models \AppsPlans ;
11
+ use Canvas \Models \PaymentMethodsCredentials ;
15
12
use Canvas \Models \Subscription as CanvasSubscription ;
16
- use Phalcon \Cashier \Subscription ;
17
13
use Canvas \Models \UserCompanyApps ;
18
- use function Baka \paymentGatewayIsActive ;
19
- use Baka \Validation as CanvasValidation ;
20
- use Canvas \Models \PaymentMethodsCreds ;
14
+ use Phalcon \Cashier \Subscription ;
15
+ use Phalcon \Http \Response ;
16
+ use Phalcon \Validation \Validator \PresenceOf ;
17
+ use Stripe \Customer as StripeCustomer ;
18
+ use Stripe \Token as StripeToken ;
21
19
22
20
/**
23
21
* Class LanguagesController.
@@ -70,6 +68,7 @@ public function onConstruct()
70
68
* Update a given subscription.
71
69
*
72
70
* @param string $stripeId
71
+ *
73
72
* @return Response
74
73
*/
75
74
public function edit ($ stripeId ) : Response
@@ -127,9 +126,10 @@ public function edit($stripeId) : Response
127
126
* Cancel a given subscription.
128
127
*
129
128
* @param string $stripeId
129
+ *
130
130
* @return Response
131
131
*/
132
- public function delete ($ stripeId ): Response
132
+ public function delete ($ stripeId ) : Response
133
133
{
134
134
$ appPlan = $ this ->model ->findFirstByStripeId ($ stripeId );
135
135
@@ -154,9 +154,10 @@ public function delete($stripeId): Response
154
154
* Reactivate a given subscription.
155
155
*
156
156
* @param string $stripeId
157
+ *
157
158
* @return Response
158
159
*/
159
- public function reactivateSubscription ($ stripeId ): Response
160
+ public function reactivateSubscription ($ stripeId ) : Response
160
161
{
161
162
$ appPlan = $ this ->model ->findFirstByStripeId ($ stripeId );
162
163
@@ -179,10 +180,12 @@ public function reactivateSubscription($stripeId): Response
179
180
180
181
/**
181
182
* Update payment method.
182
- * @param integer $id
183
+ *
184
+ * @param int $id
185
+ *
183
186
* @return Response
184
187
*/
185
- public function updatePaymentMethod (string $ id ): Response
188
+ public function updatePaymentMethod (string $ id ) : Response
186
189
{
187
190
if (empty ($ this ->request ->hasPut ('card_token ' ))) {
188
191
$ validation = new CanvasValidation ();
@@ -235,9 +238,8 @@ public function updatePaymentMethod(string $id): Response
235
238
}
236
239
237
240
if (is_object ($ stripeCustomer ) && $ stripeCustomer instanceof StripeCustomer) {
238
-
239
241
//We now create a partially persist the payment method data
240
- PaymentMethodsCreds ::createByStripeToken ($ token );
242
+ PaymentMethodsCredentials ::createByStripeToken ($ token );
241
243
return $ this ->response ($ subscription );
242
244
}
243
245
return $ this ->response ('Card could not be updated ' );
0 commit comments