gnikyt / laravel-shopify

A full-featured Laravel package for aiding in Shopify App development
MIT License
1.24k stars 374 forks source link

Cancel app subscription pre17 URGENT #1205

Closed APdevelopments closed 2 years ago

APdevelopments commented 2 years ago

I'm using this code to downgrade user to free plan from paid plans:

public function downgrade() {
$shop = Auth::user();
        $cpa = resolve(CancelCurrentPlan::class);
$cancelled = $cpa($shop->getId());

    $shop->plan_id = null;
    $shop->shopify_freemium = true;
    $shop->save();
return redirect('home')->with('success', 'Your account has been downgraded to free plan.');

}

everything works fine but in SHopify admin page there is no added/ I dont see event 'Subscription charge canceled' for store.

WHy? Please suggest this is urgent.

Kyon147 commented 2 years ago

App charges from memory are handled by Shopify itself, they cancel them automatically if a plan changes or a store gets uninstalled.

I can't remember for sure without diving into the app code properly, but a really quick look the CancelCurrentPlan does not actually send any cancellation request via API or similar, it just logs the charges in the DB to keep a record if one is active or not.

The "cancel" command just saves to the DB.

    public function cancel(
        ChargeReference $chargeRef,
        ?Carbon $expiresOn = null,
        ?Carbon $trialEndsOn = null
    ): bool {
        $charge = $this->query->getByReference($chargeRef);
        $charge->status = ChargeStatus::CANCELLED()->toNative();
        $charge->cancelled_on = $expiresOn === null ? Carbon::today()->format('Y-m-d') : $expiresOn->format('Y-m-d');
        $charge->expires_on = $trialEndsOn === null ? Carbon::today()->format('Y-m-d') : $trialEndsOn->format('Y-m-d');

        return $charge->save();
    }

If you want to manually cancel a charge, you would need to create your own API request.

The easiest way to cancel and move a shop onto a free plan, is just create a free recurring plan in the plans table and move them onto that plan. It creates way less management of having to cancel charges yourself. You can then just point them to /billing/process/planId if you want to give them the choice.

APdevelopments commented 2 years ago

Ok, just Shopify review team doesnt accept that solution. Also capped amount cant be 0.00

Kyon147 commented 2 years ago

Hmm unless they have changed their mind, this is what I have done with two apps that are live on the store. I set capped amount to my highest possible plan.

APdevelopments commented 2 years ago

I set capped_amount to 0.01 but they dont accept that solution...

pet, 9. sep 2022. 16:03 Luke Walsh @.***> је написао/ла:

Hmm unless they have changed their mind, this is what I have done with two apps that are live on the store. I set capped amount to my highest possible plan.

— Reply to this email directly, view it on GitHub https://github.com/osiset/laravel-shopify/issues/1205#issuecomment-1242016127, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACQHR7QJE5YHC472IKE4EZDV5M7THANCNFSM6AAAAAAQID2UWU . You are receiving this because you authored the thread.Message ID: @.***>