src/ShopifyApp/Requests/StoreUsageCharge.php
public function withValidator(Validator $validator)
    {
        // Determine if the HMAC is correct
        $validator->after(function (Validator $validator) {
            // Get the input values needed
            $data = [
                'price'       => $this->request->get('price'),
                'description' => $this->request->get('description'),
                'signature'   => $this->request->get('signature'),
            ];
            if ($this->request->has('redirect')) {
                $data['redirect'] = $this->request->get('redirect');
            }

            $signature = $data['signature'];
            unset($data['signature']);

            // Confirm the charge hasn't been tampered with
            $signatureLocal = ShopifyApp::createHmac(['data' => $data, 'buildQuery' => true]);
            if (!hash_equals($signature, $signatureLocal)) {
                // Possible tampering
                $validator->errors()->add('signature', 'Signature does not match.');
            }
        });
    }
public function withValidator(Validator $validator)
    {
        // Determine if the HMAC is correct
        $validator->after(function (Validator $validator) {
            // Get the input values needed
            $data = [
                'price'       => $this->request->get('price'),
                'description' => $this->request->get('description'),
                'signature'   => $this->request->get('signature'),
            ];
            if ($this->request->has('redirect')) {
                $data['redirect'] = $this->request->get('redirect');
            }

            $signature = $data['signature'];
            unset($data['signature']);

            // Confirm the charge hasn't been tampered with
            $signatureLocal = ShopifyApp::createHmac(['data' => $data, 'buildQuery' => true]);
            if (!hash_equals($signature, $signatureLocal)) {
                // Possible tampering
                $validator->errors()->add('signature', 'Signature does not match.');
            }
        });
    }
public function withValidator ( Validator $ validator ) { // Determine if the HMAC is correct $ validator -> after ( function ( Validator $ validator ) { // Get the input values needed $ data = [ 'price' => $ this -> request -> get ( 'price' ) , 'description' => $ this -> request -> get ( 'description' ) , 'signature' => $ this -> request -> get ( 'signature' ) , ] ; if ( $ this -> request -> has ( 'redirect' ) ) { $ data [ 'redirect' ] = $ this -> request -> get ( 'redirect' ) ; } $ signature = $ data [ 'signature' ] ; unset ( $ data [ 'signature' ] ) ; // Confirm the charge hasn't been tampered with $ signatureLocal = ShopifyApp :: createHmac ( [ 'data' => $ data , 'buildQuery' => true ] ) ; if ( ! hash_equals ( $ signature , $ signatureLocal ) ) { // Possible tampering $ validator -> errors ( ) -> add ( 'signature' , 'Signature does not match.' ) ; } } ) ; }
Configure the validator instance.

@param \Illuminate\Validation\Validator $validator

@return void
Configure the validator instance .