/** * Tests the hash calculation for a payer-edit transaction. */ public function testPayerEditHashGeneration() { $payer = new Payer(); $payer->addRef(SampleXmlValidationUtils::PAYER_EDIT_PAYER_REF); $request = new PaymentRequest(); $request->addType(PaymentType::PAYER_EDIT)->addTimeStamp(SampleXmlValidationUtils::PAYER_EDIT_TIMESTAMP)->addMerchantId(SampleXmlValidationUtils::PAYER_EDIT_MERCHANT_ID)->addOrderId(SampleXmlValidationUtils::PAYER_EDIT_ORDER_ID)->addPayer($payer); $request->hash(SampleXmlValidationUtils::SECRET); $this->assertEquals(SampleXmlValidationUtils::PAYER_EDIT_REQUEST_HASH, $request->getHash()); }
/** * Checks whether the given class is supported for denormalization by this normalizer. * * @param mixed $data Data to denormalize from. * @param string $type The class to which the data should be denormalized. * @param string $format The format being deserialized from. * * @return bool */ public function supportsDenormalization($data, $type, $format = null) { if ($format == "xml" && $type == Payer::GetClassName()) { return true; } return false; }
private function denormalizePayer($array) { return $this->serializer->denormalize($array['payer'], Payer::GetClassName(), $this->format, $this->context); }
/** * Tests conversion of {@link PaymentRequest} to and from XML using setters for Payer. */ public function testPaymentRequestXmlPayerFluentSetters() { $request = new PaymentRequest(); $request->addAccount(SampleXmlValidationUtils::PAYER_NEW_ACCOUNT)->addMerchantId(SampleXmlValidationUtils::PAYER_NEW_MERCHANT_ID)->addType(PaymentType::PAYER_NEW); $payer = new Payer(); $payer->addType(SampleXmlValidationUtils::PAYER_NEW_PAYER_TYPE)->addRef(SampleXmlValidationUtils::PAYER_NEW_PAYER_REF)->addTitle(SampleXmlValidationUtils::PAYER_NEW_PAYER_TITLE)->addFirstName(SampleXmlValidationUtils::PAYER_NEW_PAYER_FIRSTNAME)->addSurname(SampleXmlValidationUtils::PAYER_NEW_PAYER_SURNAME)->addCompany(SampleXmlValidationUtils::PAYER_NEW_PAYER_COMPANY)->addEmail(SampleXmlValidationUtils::PAYER_NEW_PAYER_EMAIL); $address = new PayerAddress(); $address->addLine1(SampleXmlValidationUtils::PAYER_NEW_PAYER_ADDRESS_LINE_1)->addLine2(SampleXmlValidationUtils::PAYER_NEW_PAYER_ADDRESS_LINE_2)->addLine3(SampleXmlValidationUtils::PAYER_NEW_PAYER_ADDRESS_LINE_3)->addCity(SampleXmlValidationUtils::PAYER_NEW_PAYER_ADDRESS_CITY)->addCounty(SampleXmlValidationUtils::PAYER_NEW_PAYER_ADDRESS_COUNTY)->addPostcode(SampleXmlValidationUtils::PAYER_NEW_PAYER_ADDRESS_POSTCODE)->addCountryCode(SampleXmlValidationUtils::PAYER_NEW_PAYER_ADDRESS_COUNTRY_CODE)->addCountryName(SampleXmlValidationUtils::PAYER_NEW_PAYER_ADDRESS_COUNTRY_NAME); $payer->addAddress($address)->addComment(SampleXmlValidationUtils::PAYER_NEW_PAYER_COMMENT_1)->addComment(SampleXmlValidationUtils::PAYER_NEW_PAYER_COMMENT_2)->addHomePhoneNumber(SampleXmlValidationUtils::PAYER_NEW_PAYER_HOME_NUMBER)->addWorkPhoneNumber(SampleXmlValidationUtils::PAYER_NEW_PAYER_WORK_NUMBER)->addFaxPhoneNumber(SampleXmlValidationUtils::PAYER_NEW_PAYER_FAX_NUMBER)->addMobilePhoneNumber(SampleXmlValidationUtils::PAYER_NEW_PAYER_MOBILE_NUMBER); $request->addPayer($payer)->addTimeStamp(SampleXmlValidationUtils::PAYER_NEW_TIMESTAMP)->addOrderId(SampleXmlValidationUtils::PAYER_NEW_ORDER_ID)->addHash(SampleXmlValidationUtils::PAYER_NEW_REQUEST_HASH); // convert to XML $xml = $request->toXml(); // Convert from XML back to PaymentRequest /* @var PaymentRequest $fromXmlRequest */ $fromXmlRequest = new PaymentRequest(); $fromXmlRequest = $fromXmlRequest->fromXml($xml); SampleXmlValidationUtils::checkUnmarshalledPayerNewPaymentRequest($fromXmlRequest, $this); }