laravel-shopify icon indicating copy to clipboard operation
laravel-shopify copied to clipboard

Usage Charge is not working in v17

Open yasir-naseer-tetralogicx opened this issue 3 years ago • 3 comments

Im trying to follow the documentation of usage charge, so i can charge users based upon their usage, i tried the following code from the docs

App/Http/Controllers/Example

...

public function index() { // Description and price of usage charge (the only two parameters required) $charge = [ 'description' => 'Five e-mails', 'price' => 1.00, 'redirect' => route('example.success') // Optional, if not supplied redirect goes back to previous page with flash success=true ];

// Create a signature to prevent tampering
$signature = createHmac(['data' => $charge, 'buildQuery' => true], Config::get('shopify-app.api_secret'));

// Create the route
$usageChargeRoute = route('billing.usage_charge', array_merge($charge, ['signature' => $signature]));

return view('example.index', compact('usageChargeRoute'));

}

But seems like this cod is out dated and it not work in v17, firstly i get an error saying that method createHmac do not exists, then after some research i used the Util helper to call this method, later on i got error saying shop is not found, and i look for package code and it was getting shop from request object, which was returning null value, so in order to handle it for a while i manually pass the shop just to keep it running, and it work successfully by creating a charge in charges table, but it do not redirects to billing page for confirmation, anyone have idea about this please help

@yasir-naseer-tetralogicx is this the same issue you mentioned in #968?

Kyon147 avatar Nov 03 '21 11:11 Kyon147

No this is different,

1.firstly i get an error saying that method createHmac do not exists, then after some research i used the Util helper to call this method

  1. Later on i got error saying shop is not found, and i look for package code and it was getting shop from request object, which was returning null value, so in order to handle it for a while i manually pass the shop just to keep it running

  2. So after some manual work, it work successfully by creating a charge in charges table, but it do not redirects to billing page for confirmation

yasir-naseer avatar Nov 16 '21 17:11 yasir-naseer

@yasir-naseer same issue

pengbo37877 avatar Nov 20 '21 07:11 pengbo37877

Fixed in v17.3.1

Kyon147 avatar Oct 04 '22 18:10 Kyon147