/** * @param CredentialsInterface $credentials * @param string $data * @param string|null $signatureHeader Signature can be null when notifyUrl starts with https * * @return OrderNotification */ public function process(CredentialsInterface $credentials, $data, $signatureHeader = null) { if (null !== $signatureHeader) { $this->validateSignature($credentials, $data, $signatureHeader); } return $this->serializer->fromJson($data, self::ORDER_NOTIFICATION_CLASS); }
/** * @param ConfigurationInterface $configuration * @param PayURequestInterface $request * * @return Request */ public function build(ConfigurationInterface $configuration, PayURequestInterface $request) { $curlRequest = new Request(); if (PayURequestInterface::METHOD_POST === $request->getMethod()) { $curlRequest->setContent($this->serializer->toJson($request->getDataObject())); } $curlRequest->setHost(sprintf('%s://%s/', $configuration->getProtocol(), $configuration->getDomain())); $curlRequest->setResource(sprintf('%s/%s/%s', $configuration->getPath(), $configuration->getVersion(), $request->getPath())); $curlRequest->setMethod($request->getMethod()); $this->addHeaders($curlRequest, $configuration); return $curlRequest; }
/** * @param MessageInterface $curlResponse * @param string $responseClass * * @return object * @throws RequestProcessException */ private function deserialize(MessageInterface $curlResponse, $responseClass) { try { return $this->serializer->fromJson($curlResponse->getContent(), $responseClass); } catch (SerializerException $exception) { throw new RequestProcessException(sprintf('Exception %s was thrown during deserialization. Message: "%s"', get_class($exception), $exception->getMessage()), $exception->getCode(), $exception); } }
public function testSerializedModelWithAmount() { $requestModel = new RefundRequestModel($this->getOrder(), self::REFUND_DESC, self::REFUND_DESC, new Money(self::AMOUNT_VALUE)); $serialized = $this->serializer->toJson($requestModel); $this->assertEquals(sprintf('{"order_id":"123456","refund":{"amount":1234,"bank_description":"Refund","description":"Refund"}}', self::AMOUNT_VALUE_WITHOUT_SEPARATION), $serialized); }
/** * Will return order serializable parameters in ascending order. * * @param OrderInterface $order * @return array */ public function getSortedParameters(OrderInterface $order) { $json = $this->serializer->toJson($order); return $this->serializer->fromJson($json, 'array'); }
public function let(SerializerInterface $serializer, OrderInterface $order) { $serializer->toJson($order)->willReturn(self::EXAMPLE_STRING); $serializer->fromJson(self::EXAMPLE_STRING, 'array')->willReturn([]); $this->beConstructedWith($serializer); }