| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | namespace Worldline\Acquiring\Sdk\V1\Domain; |
| 6: | |
| 7: | use DateTime; |
| 8: | use UnexpectedValueException; |
| 9: | use Worldline\Acquiring\Sdk\Domain\DataObject; |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | class ApiRefundResponse extends DataObject |
| 15: | { |
| 16: | |
| 17: | |
| 18: | |
| 19: | public $additionalResponseData = null; |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | public $authorizationCode = null; |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | public $cardPaymentData = null; |
| 30: | |
| 31: | |
| 32: | |
| 33: | |
| 34: | public $emvData = null; |
| 35: | |
| 36: | |
| 37: | |
| 38: | |
| 39: | public $operationId = null; |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: | public $referencedPaymentId = null; |
| 45: | |
| 46: | |
| 47: | |
| 48: | |
| 49: | public $references = null; |
| 50: | |
| 51: | |
| 52: | |
| 53: | |
| 54: | public $refundId = null; |
| 55: | |
| 56: | |
| 57: | |
| 58: | |
| 59: | public $responder = null; |
| 60: | |
| 61: | |
| 62: | |
| 63: | |
| 64: | public $responseCode = null; |
| 65: | |
| 66: | |
| 67: | |
| 68: | |
| 69: | public $responseCodeCategory = null; |
| 70: | |
| 71: | |
| 72: | |
| 73: | |
| 74: | public $responseCodeDescription = null; |
| 75: | |
| 76: | |
| 77: | |
| 78: | |
| 79: | public $status = null; |
| 80: | |
| 81: | |
| 82: | |
| 83: | |
| 84: | public $statusTimestamp = null; |
| 85: | |
| 86: | |
| 87: | |
| 88: | |
| 89: | public $totalAuthorizedAmount = null; |
| 90: | |
| 91: | |
| 92: | |
| 93: | |
| 94: | public function toObject() |
| 95: | { |
| 96: | $object = parent::toObject(); |
| 97: | if (!is_null($this->additionalResponseData)) { |
| 98: | $object->additionalResponseData = $this->additionalResponseData->toObject(); |
| 99: | } |
| 100: | if (!is_null($this->authorizationCode)) { |
| 101: | $object->authorizationCode = $this->authorizationCode; |
| 102: | } |
| 103: | if (!is_null($this->cardPaymentData)) { |
| 104: | $object->cardPaymentData = $this->cardPaymentData->toObject(); |
| 105: | } |
| 106: | if (!is_null($this->emvData)) { |
| 107: | $object->emvData = []; |
| 108: | foreach ($this->emvData as $element) { |
| 109: | if (!is_null($element)) { |
| 110: | $object->emvData[] = $element->toObject(); |
| 111: | } |
| 112: | } |
| 113: | } |
| 114: | if (!is_null($this->operationId)) { |
| 115: | $object->operationId = $this->operationId; |
| 116: | } |
| 117: | if (!is_null($this->referencedPaymentId)) { |
| 118: | $object->referencedPaymentId = $this->referencedPaymentId; |
| 119: | } |
| 120: | if (!is_null($this->references)) { |
| 121: | $object->references = $this->references->toObject(); |
| 122: | } |
| 123: | if (!is_null($this->refundId)) { |
| 124: | $object->refundId = $this->refundId; |
| 125: | } |
| 126: | if (!is_null($this->responder)) { |
| 127: | $object->responder = $this->responder; |
| 128: | } |
| 129: | if (!is_null($this->responseCode)) { |
| 130: | $object->responseCode = $this->responseCode; |
| 131: | } |
| 132: | if (!is_null($this->responseCodeCategory)) { |
| 133: | $object->responseCodeCategory = $this->responseCodeCategory; |
| 134: | } |
| 135: | if (!is_null($this->responseCodeDescription)) { |
| 136: | $object->responseCodeDescription = $this->responseCodeDescription; |
| 137: | } |
| 138: | if (!is_null($this->status)) { |
| 139: | $object->status = $this->status; |
| 140: | } |
| 141: | if (!is_null($this->statusTimestamp)) { |
| 142: | $object->statusTimestamp = $this->statusTimestamp->format('Y-m-d\\TH:i:s.vP'); |
| 143: | } |
| 144: | if (!is_null($this->totalAuthorizedAmount)) { |
| 145: | $object->totalAuthorizedAmount = $this->totalAuthorizedAmount->toObject(); |
| 146: | } |
| 147: | return $object; |
| 148: | } |
| 149: | |
| 150: | |
| 151: | |
| 152: | |
| 153: | |
| 154: | |
| 155: | public function fromObject($object) |
| 156: | { |
| 157: | parent::fromObject($object); |
| 158: | if (property_exists($object, 'additionalResponseData')) { |
| 159: | if (!is_object($object->additionalResponseData)) { |
| 160: | throw new UnexpectedValueException('value \'' . print_r($object->additionalResponseData, true) . '\' is not an object'); |
| 161: | } |
| 162: | $value = new AdditionalResponseData(); |
| 163: | $this->additionalResponseData = $value->fromObject($object->additionalResponseData); |
| 164: | } |
| 165: | if (property_exists($object, 'authorizationCode')) { |
| 166: | $this->authorizationCode = $object->authorizationCode; |
| 167: | } |
| 168: | if (property_exists($object, 'cardPaymentData')) { |
| 169: | if (!is_object($object->cardPaymentData)) { |
| 170: | throw new UnexpectedValueException('value \'' . print_r($object->cardPaymentData, true) . '\' is not an object'); |
| 171: | } |
| 172: | $value = new CardPaymentDataForResponse(); |
| 173: | $this->cardPaymentData = $value->fromObject($object->cardPaymentData); |
| 174: | } |
| 175: | if (property_exists($object, 'emvData')) { |
| 176: | if (!is_array($object->emvData) && !is_object($object->emvData)) { |
| 177: | throw new UnexpectedValueException('value \'' . print_r($object->emvData, true) . '\' is not an array or object'); |
| 178: | } |
| 179: | $this->emvData = []; |
| 180: | foreach ($object->emvData as $element) { |
| 181: | $value = new EmvDataItem(); |
| 182: | $this->emvData[] = $value->fromObject($element); |
| 183: | } |
| 184: | } |
| 185: | if (property_exists($object, 'operationId')) { |
| 186: | $this->operationId = $object->operationId; |
| 187: | } |
| 188: | if (property_exists($object, 'referencedPaymentId')) { |
| 189: | $this->referencedPaymentId = $object->referencedPaymentId; |
| 190: | } |
| 191: | if (property_exists($object, 'references')) { |
| 192: | if (!is_object($object->references)) { |
| 193: | throw new UnexpectedValueException('value \'' . print_r($object->references, true) . '\' is not an object'); |
| 194: | } |
| 195: | $value = new ApiReferencesForResponses(); |
| 196: | $this->references = $value->fromObject($object->references); |
| 197: | } |
| 198: | if (property_exists($object, 'refundId')) { |
| 199: | $this->refundId = $object->refundId; |
| 200: | } |
| 201: | if (property_exists($object, 'responder')) { |
| 202: | $this->responder = $object->responder; |
| 203: | } |
| 204: | if (property_exists($object, 'responseCode')) { |
| 205: | $this->responseCode = $object->responseCode; |
| 206: | } |
| 207: | if (property_exists($object, 'responseCodeCategory')) { |
| 208: | $this->responseCodeCategory = $object->responseCodeCategory; |
| 209: | } |
| 210: | if (property_exists($object, 'responseCodeDescription')) { |
| 211: | $this->responseCodeDescription = $object->responseCodeDescription; |
| 212: | } |
| 213: | if (property_exists($object, 'status')) { |
| 214: | $this->status = $object->status; |
| 215: | } |
| 216: | if (property_exists($object, 'statusTimestamp')) { |
| 217: | $this->statusTimestamp = new DateTime($object->statusTimestamp); |
| 218: | } |
| 219: | if (property_exists($object, 'totalAuthorizedAmount')) { |
| 220: | if (!is_object($object->totalAuthorizedAmount)) { |
| 221: | throw new UnexpectedValueException('value \'' . print_r($object->totalAuthorizedAmount, true) . '\' is not an object'); |
| 222: | } |
| 223: | $value = new AmountData(); |
| 224: | $this->totalAuthorizedAmount = $value->fromObject($object->totalAuthorizedAmount); |
| 225: | } |
| 226: | return $this; |
| 227: | } |
| 228: | } |
| 229: | |