private function validate(\CivicInfoBC\Beanstream\EXactHostedCheckout $hco, \CivicInfoBC\Framework\Request $request) { $trans = $hco->CreateTransaction(); $trans->metadata = new \stdClass(); $pattern = '/^x_/u'; foreach ($request->Post() as $key => $value) { // We already processed this higher up the // stack if ($key === 'x_login') { continue; } if ($key === 'x_amount') { if (!is_string($value)) { self::expected('x_amount', 'string', $value); } $trans->amount = \CivicInfoBC\Convert::ToFloat($value); if (is_null($trans->amount)) { self::could_not_convert('x_amount', $value, 'decimal'); } continue; } if (!\CivicInfoBC\Regex::IsMatch($pattern, $key)) { continue; } $trans->metadata->{$key} = $value; } if (is_null($trans->amount)) { self::no_value('x_amount'); } $this->verify($trans->amount, $trans->metadata, $hco); return $trans; }