コード例 #1
0
 /**
  * Denormalizes data back into an object of the given class.
  *
  * @param mixed $data data to restore
  * @param string $class the expected class to instantiate
  * @param string $format format the given data was extracted from
  * @param array $context options available to the denormalizer
  *
  * @return object
  */
 public function denormalize($data, $class, $format = null, array $context = array())
 {
     $request = new PaymentRequest();
     $array = new SafeArrayAccess($data);
     $request->addTimestamp($array['@timestamp'])->addType($array['@type'])->addMerchantId($array['merchantid'])->addAccount($array['account'])->addChannel($array['channel'])->addOrderId($array['orderid'])->addHash($array['sha1hash'])->addPaymentsReference($array['pasref'])->addAuthCode($array['authcode'])->addRefundHash($array['refundhash'])->addFraudFilter($array['fraudfilter'])->addMobile($array['mobile'])->addToken($array['token']);
     $autoSettle = $this->denormaliseAutoSettle($array);
     if ($autoSettle != null) {
         $request->addAutoSettle($autoSettle);
     }
     $card = $this->denormaliseCard($array);
     if ($card != null) {
         $request->addCard($card);
     }
     $recurring = $this->denormaliseRecurring($array);
     if ($recurring != null) {
         $request->addRecurring($recurring);
     }
     $tssInfo = $this->denormaliseTssInfo($array);
     if ($tssInfo != null) {
         $request->addTssInfo($tssInfo);
     }
     $mpi = $this->denormaliseMpi($array);
     if ($mpi != null) {
         $request->addMpi($mpi);
     }
     $request->setAmount($this->denormaliseAmount($array));
     $request->setComments($this->denormaliseComments($array));
     return $request;
 }
コード例 #2
0
 /**
  * Tests Fake reason code
  */
 public function testPaymentRequestCodeXmlFromCodeFailed()
 {
     $paymentRequest = new PaymentRequest();
     $paymentRequest->addAccount(SampleXmlValidationUtils::HOLD_ACCOUNT);
     $paymentRequest->addMerchantId(SampleXmlValidationUtils::HOLD_MERCHANT_ID);
     $paymentRequest->addTimestamp(SampleXmlValidationUtils::HOLD_TIMESTAMP);
     $paymentRequest->addOrderId(SampleXmlValidationUtils::HOLD_ORDER_ID);
     $paymentRequest->addHash(SampleXmlValidationUtils::HOLD_REQUEST_HASH);
     $paymentRequest->addType(PaymentType::HOLD);
     $paymentRequest->addReasonCode('fake reason');
     $reasons = array(ReasonCode::FRAUD, ReasonCode::FALSE_POSITIVE, ReasonCode::IN_STOCK, ReasonCode::NOT_GIVEN, ReasonCode::OTHER, ReasonCode::OUT_OF_STOCK);
     foreach ($reasons as $reason) {
         //marshal to XML
         $xml = $paymentRequest->toXml();
         //unmarshal back to response
         /* @var PaymentResponse $fromXmlResponse */
         $fromXmlResponse = new PaymentRequest();
         $fromXmlResponse = $fromXmlResponse->fromXML($xml);
         SampleXmlValidationUtils::checkUnmarshalledRequestCodeResponse($fromXmlResponse, $this, $reason, false);
     }
 }