laravel-shopify
laravel-shopify copied to clipboard
Usage Charge is not working in v17
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?
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
-
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
-
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 same issue
Fixed in v17.3.1