| 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 ApiPaymentRequest extends DataObject |
| 15: | { |
| 16: | |
| 17: | |
| 18: | |
| 19: | public $amount = null; |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | public $authorizationType = null; |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | public $cardPaymentData = null; |
| 30: | |
| 31: | |
| 32: | |
| 33: | |
| 34: | public $dynamicCurrencyConversion = null; |
| 35: | |
| 36: | |
| 37: | |
| 38: | |
| 39: | public $merchant = null; |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: | public $operationId = null; |
| 45: | |
| 46: | |
| 47: | |
| 48: | |
| 49: | public $references = null; |
| 50: | |
| 51: | |
| 52: | |
| 53: | |
| 54: | public $terminalData = null; |
| 55: | |
| 56: | |
| 57: | |
| 58: | |
| 59: | public $transactionTimestamp = null; |
| 60: | |
| 61: | |
| 62: | |
| 63: | |
| 64: | public function toObject() |
| 65: | { |
| 66: | $object = parent::toObject(); |
| 67: | if (!is_null($this->amount)) { |
| 68: | $object->amount = $this->amount->toObject(); |
| 69: | } |
| 70: | if (!is_null($this->authorizationType)) { |
| 71: | $object->authorizationType = $this->authorizationType; |
| 72: | } |
| 73: | if (!is_null($this->cardPaymentData)) { |
| 74: | $object->cardPaymentData = $this->cardPaymentData->toObject(); |
| 75: | } |
| 76: | if (!is_null($this->dynamicCurrencyConversion)) { |
| 77: | $object->dynamicCurrencyConversion = $this->dynamicCurrencyConversion->toObject(); |
| 78: | } |
| 79: | if (!is_null($this->merchant)) { |
| 80: | $object->merchant = $this->merchant->toObject(); |
| 81: | } |
| 82: | if (!is_null($this->operationId)) { |
| 83: | $object->operationId = $this->operationId; |
| 84: | } |
| 85: | if (!is_null($this->references)) { |
| 86: | $object->references = $this->references->toObject(); |
| 87: | } |
| 88: | if (!is_null($this->terminalData)) { |
| 89: | $object->terminalData = $this->terminalData->toObject(); |
| 90: | } |
| 91: | if (!is_null($this->transactionTimestamp)) { |
| 92: | $object->transactionTimestamp = $this->transactionTimestamp->format('Y-m-d\\TH:i:s.vP'); |
| 93: | } |
| 94: | return $object; |
| 95: | } |
| 96: | |
| 97: | |
| 98: | |
| 99: | |
| 100: | |
| 101: | |
| 102: | public function fromObject($object) |
| 103: | { |
| 104: | parent::fromObject($object); |
| 105: | if (property_exists($object, 'amount')) { |
| 106: | if (!is_object($object->amount)) { |
| 107: | throw new UnexpectedValueException('value \'' . print_r($object->amount, true) . '\' is not an object'); |
| 108: | } |
| 109: | $value = new AmountData(); |
| 110: | $this->amount = $value->fromObject($object->amount); |
| 111: | } |
| 112: | if (property_exists($object, 'authorizationType')) { |
| 113: | $this->authorizationType = $object->authorizationType; |
| 114: | } |
| 115: | if (property_exists($object, 'cardPaymentData')) { |
| 116: | if (!is_object($object->cardPaymentData)) { |
| 117: | throw new UnexpectedValueException('value \'' . print_r($object->cardPaymentData, true) . '\' is not an object'); |
| 118: | } |
| 119: | $value = new CardPaymentData(); |
| 120: | $this->cardPaymentData = $value->fromObject($object->cardPaymentData); |
| 121: | } |
| 122: | if (property_exists($object, 'dynamicCurrencyConversion')) { |
| 123: | if (!is_object($object->dynamicCurrencyConversion)) { |
| 124: | throw new UnexpectedValueException('value \'' . print_r($object->dynamicCurrencyConversion, true) . '\' is not an object'); |
| 125: | } |
| 126: | $value = new DccData(); |
| 127: | $this->dynamicCurrencyConversion = $value->fromObject($object->dynamicCurrencyConversion); |
| 128: | } |
| 129: | if (property_exists($object, 'merchant')) { |
| 130: | if (!is_object($object->merchant)) { |
| 131: | throw new UnexpectedValueException('value \'' . print_r($object->merchant, true) . '\' is not an object'); |
| 132: | } |
| 133: | $value = new MerchantData(); |
| 134: | $this->merchant = $value->fromObject($object->merchant); |
| 135: | } |
| 136: | if (property_exists($object, 'operationId')) { |
| 137: | $this->operationId = $object->operationId; |
| 138: | } |
| 139: | if (property_exists($object, 'references')) { |
| 140: | if (!is_object($object->references)) { |
| 141: | throw new UnexpectedValueException('value \'' . print_r($object->references, true) . '\' is not an object'); |
| 142: | } |
| 143: | $value = new PaymentReferences(); |
| 144: | $this->references = $value->fromObject($object->references); |
| 145: | } |
| 146: | if (property_exists($object, 'terminalData')) { |
| 147: | if (!is_object($object->terminalData)) { |
| 148: | throw new UnexpectedValueException('value \'' . print_r($object->terminalData, true) . '\' is not an object'); |
| 149: | } |
| 150: | $value = new TerminalData(); |
| 151: | $this->terminalData = $value->fromObject($object->terminalData); |
| 152: | } |
| 153: | if (property_exists($object, 'transactionTimestamp')) { |
| 154: | $this->transactionTimestamp = new DateTime($object->transactionTimestamp); |
| 155: | } |
| 156: | return $this; |
| 157: | } |
| 158: | } |
| 159: | |