public static function getTransactionAuthenticationValue() { $json = "{\n" . "\t\"cardToken\": \"dT2bT-P5dvK0-3zCi9VByf_SUsXxLEmITJGLsWm_oYE\",\n" . "\t\"mctTransAuthId\": \"0f2e781e-1d38-4766-a635-8d906d3fdff7\",\n" . "\t\"ocTransAuthId\": \"TA20151130000000000020008\",\n" . "\t\"paymentAuthenticationDetail\": {\n" . "\t\t\"payMethod\": \"10\",\n" . "\t\t\"payAmount\": 1000,\n" . "\t\t\"offerAmount\": 0,\n" . "\t\t\"loyaltyAmount\": 0,\n" . "\t\t\"payInstallment\": \"00\",\n" . "\t\t\"payCurrency\": \"KRW\",\n" . "\t\t\"payFinanceCode\": \"17\",\n" . "\t\t\"isCardPointApplied\": false\n" . "\t}\n" . "}"; $j = json_decode($json); $t = SyrupPayTokenBuilder::fromJson(new TransactionAuthenticationValue(), $j); return $t; }
public function test_하위버전_1_3_4_버전_CJOSHOPPING_테스트() { SyrupPayTokenBuilder::uncheckValidationOfToken(); $tokenHistories = new TokenHistories(); $t = SyrupPayTokenBuilder::verify($tokenHistories->VERSION_1_3_4_BY_CJOSHOPPING->token, $tokenHistories->VERSION_1_3_4_BY_CJOSHOPPING->key); $this->assertNotNull($t->getTransactionInfo()->getMerchantTransactionAuthenticatedId()); $this->assertNotNull($t->getTransactionInfo()->getPaymentRestrictions()->getCardIssuerRegion()); }
public static function fromJson($dest, \stdClass $src) { $srcReflection = new \ReflectionObject($src); $srcProperties = $srcReflection->getProperties(); $destReflection = new \ReflectionObject($dest); foreach ($srcProperties as $srcProperty) { $propertyName = $srcProperty->getName(); $propertyValue = $srcProperty->getValue($src); if ($destReflection->hasProperty($propertyName)) { if (is_object($propertyValue)) { //single custom class variable $className = self::getAnnotation($dest, $propertyName); if (!isset($className)) { continue; } if (empty($className)) { throw new \InvalidArgumentException("No declared class name. There is annotaion '@var' missing at document comment: {$propertyName}"); } $newClassObject = self::fromJson(new $className(), $propertyValue); self::injectValue($dest, $propertyName, $newClassObject); } else { if (is_array($propertyValue)) { //custom class list or primitive list $className = SyrupPayTokenBuilder::getAnnotation($dest, $propertyName); //case on primitive list if (!isset($className) || empty($className)) { self::injectValue($dest, $propertyName, $propertyValue); continue; } //case on custom list $arrayNewClassObject = array(); foreach ($propertyValue as $arrayKey => $arrayValue) { //arrayKey : 0, arrayValue : stdClass $newClassObject = self::fromJson(new $className(), $arrayValue); $arrayNewClassObject[] = $newClassObject; } self::injectValue($dest, $propertyName, $arrayNewClassObject); } else { self::injectValue($dest, $propertyName, $propertyValue); } } } } return $dest; }