/** * Tests the reasons code */ public function testAddFraudReasonChanging() { $request = new PaymentRequest(); $request->addReasonCode(ReasonCode::FALSE_POSITIVE); $request->setReasonCode(ReasonCode::FRAUD); $this->assertEquals($request->getReasonCode(), ReasonCode::FRAUD); }
/** * Tests all reasons code cases */ public function testPaymentRequestAllReasonCodeXmlFromCode() { $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); $reasons = array(ReasonCode::FRAUD, ReasonCode::FALSE_POSITIVE, ReasonCode::IN_STOCK, ReasonCode::NOT_GIVEN, ReasonCode::OTHER, ReasonCode::OUT_OF_STOCK); foreach ($reasons as $reason) { $paymentRequest->setReasonCode($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); } }