Kyon147 / laravel-shopify

A full-featured Laravel package for aiding in Shopify App development
MIT License
336 stars 99 forks source link

Undefined array key "billing_on" on usage charge #254

Open pengbo37877 opened 6 months ago

pengbo37877 commented 6 months ago

For bug reporting only! If you're posting a feature request or discussion, please ignore.

Expected Behavior

Please describe the behavior you are expecting.

Current Behavior

usage charge error

Failure Information

Undefined array key "billing_on"

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. call usage charge url

Context

Failure Logs

{ "exception": { "class": "ErrorException", "message": "Undefined array key "billing_on"", "code": 0, "file": "/var/task/vendor/gnikyt/basic-shopify-api/src/ResponseAccess.php:66" } }

Kyon147 commented 6 months ago

Can you screenshot your plans table and the code you are using the generate the usage charge

pengbo37877 commented 6 months ago

I commented out line 97 of ActivateUsageCharge.php, line 102 of Charge.php to make it work.

talktohenryj commented 3 months ago

Yes, the problem is Shopify removed that from the API. We need to make a change to the ActivateUsageCharge.php file in this repo because of this part of the code:

        // Create the transfer
        $uct = new UsageChargeTransfer();
        $uct->shopId = $shopId;
        $uct->planId = $shop->plan->getId();
        $uct->chargeReference = ChargeReference::fromNative((int) $response['id']);
        $uct->billingOn = new Carbon($response['billing_on']);
        $uct->details = $ucd;

Below is the Shopify changelog info. That explains why.

https://shopify.dev/changelog/removal-of-usagecharge-billing_on-field-on-admin-rest-api

I don't have time to fix it myself right now. I am going to do what @pengbo37877 said in regard to just commenting it out but if @Kyon147 agrees, I will take some time and look into it over the next week or two.

talktohenryj commented 3 months ago

@pengbo37877 I just found a quicker and easier short term fix. Just move your Shopify API to 2023-07. We can use that until July 1. As long as we fix this before July 1 we will be all good.