File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,14 @@ public function process($planId = null)
4949 $ billingPlan ->setChargeId ($ chargeId );
5050 $ response = $ billingPlan ->activate ();
5151
52+ // Set old charge as cancelled, if one
53+ $ lastCharge = $ this ->getLastCharge ($ shop );
54+ if ($ lastCharge ) {
55+ $ lastCharge ->status = 'cancelled ' ;
56+ $ lastCharge ->cancelled_on = Carbon::today ()->format ('Y-m-d ' );
57+ $ lastCharge ->save ();
58+ }
59+
5260 // Create a charge
5361 $ charge = Charge::firstOrNew ([
5462 'type ' => $ plan ->type ,
@@ -78,14 +86,6 @@ public function process($planId = null)
7886 // Finally, save the charge
7987 $ charge ->save ();
8088
81- // Set old charge as cancelled, if one
82- $ lastCharge = $ this ->getLastCharge ($ shop );
83- if ($ lastCharge ) {
84- $ lastCharge ->status = 'cancelled ' ;
85- $ lastCharge ->cancelled_on = Carbon::today ()->format ('Y-m-d ' );
86- $ lastCharge ->save ();
87- }
88-
8989 // All good, update the shop's plan and take them off freemium (if applicable)
9090 $ shop ->freemium = false ;
9191 $ shop ->plan_id = $ plan ->id ;
You can’t perform that action at this time.
0 commit comments