예제 #1
0
 public function test_serialize_signed_message_with_default_serializer()
 {
     $data = ['return_code' => 'SUCCESS'];
     $message = new Message($data);
     $message->setHashGenerator($this->getReferenceHashGenerator());
     $message->sign();
     $expected = '<xml><return_code><![CDATA[SUCCESS]]></return_code><sign><![CDATA[2C2B2A1D626E750FCFD0ED661E80E3AA]]></sign></xml>';
     $actual = $message->serialize();
     $this->assertEquals($expected, $actual);
 }
예제 #2
0
 /**
  * @param mixed $data
  *
  * @return ITC\Weixin\Payment\Contracts\Message $message
  */
 public function message($data = null)
 {
     $serializer = $this->getSerializer();
     $hashgen = $this->getHashGenerator();
     if (is_string($data) && $data) {
         $data = $serializer->unserialize($data);
     }
     $message = new Message\Message($data);
     $message->setSerializer($serializer);
     $message->setHashGenerator($hashgen);
     return $message;
 }