Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Usage Charge is not working in v17 #1002

Closed
yasir-naseer-tetralogicx opened this issue Nov 2, 2021 · 4 comments
Closed

Usage Charge is not working in v17 #1002

yasir-naseer-tetralogicx opened this issue Nov 2, 2021 · 4 comments
Labels
bug Bug with the code fix-in-progress In progress

Comments

@yasir-naseer-tetralogicx

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

@Kyon147
Copy link
Collaborator

Kyon147 commented Nov 3, 2021

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

@yasir-naseer
Copy link

yasir-naseer commented Nov 16, 2021

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

@pengbo37877
Copy link

@yasir-naseer same issue

@Kyon147 Kyon147 added bug Bug with the code fix-in-progress In progress labels Sep 13, 2022
@Kyon147
Copy link
Collaborator

Kyon147 commented Oct 4, 2022

Fixed in v17.3.1

@Kyon147 Kyon147 closed this as completed Oct 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bug with the code fix-in-progress In progress
Projects
None yet
Development

No branches or pull requests

4 participants