| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | namespace Worldline\Connect\Sdk\V1\Merchant\Hostedcheckouts; |
| 7: | |
| 8: | use Worldline\Connect\Sdk\ApiResource; |
| 9: | use Worldline\Connect\Sdk\CallContext; |
| 10: | use Worldline\Connect\Sdk\Communication\ErrorResponseException; |
| 11: | use Worldline\Connect\Sdk\Communication\InvalidResponseException; |
| 12: | use Worldline\Connect\Sdk\Communication\ResponseClassMap; |
| 13: | use Worldline\Connect\Sdk\V1\ApiException; |
| 14: | use Worldline\Connect\Sdk\V1\AuthorizationException; |
| 15: | use Worldline\Connect\Sdk\V1\Domain\CreateHostedCheckoutRequest; |
| 16: | use Worldline\Connect\Sdk\V1\Domain\CreateHostedCheckoutResponse; |
| 17: | use Worldline\Connect\Sdk\V1\Domain\GetHostedCheckoutResponse; |
| 18: | use Worldline\Connect\Sdk\V1\ExceptionFactory; |
| 19: | use Worldline\Connect\Sdk\V1\IdempotenceException; |
| 20: | use Worldline\Connect\Sdk\V1\PlatformException; |
| 21: | use Worldline\Connect\Sdk\V1\ReferenceException; |
| 22: | use Worldline\Connect\Sdk\V1\ValidationException; |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | class HostedcheckoutsClient extends ApiResource |
| 28: | { |
| 29: | |
| 30: | private $responseExceptionFactory = null; |
| 31: | |
| 32: | |
| 33: | |
| 34: | |
| 35: | |
| 36: | |
| 37: | |
| 38: | |
| 39: | |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: | |
| 45: | |
| 46: | |
| 47: | |
| 48: | public function create(CreateHostedCheckoutRequest $body, CallContext $callContext = null) |
| 49: | { |
| 50: | $responseClassMap = new ResponseClassMap(); |
| 51: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\CreateHostedCheckoutResponse'; |
| 52: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
| 53: | try { |
| 54: | return $this->getCommunicator()->post( |
| 55: | $responseClassMap, |
| 56: | $this->instantiateUri('/v1/{merchantId}/hostedcheckouts'), |
| 57: | $this->getClientMetaInfo(), |
| 58: | $body, |
| 59: | null, |
| 60: | $callContext |
| 61: | ); |
| 62: | } catch (ErrorResponseException $e) { |
| 63: | throw $this->getResponseExceptionFactory()->createException( |
| 64: | $e->getHttpStatusCode(), |
| 65: | $e->getErrorResponse(), |
| 66: | $callContext |
| 67: | ); |
| 68: | } |
| 69: | } |
| 70: | |
| 71: | |
| 72: | |
| 73: | |
| 74: | |
| 75: | |
| 76: | |
| 77: | |
| 78: | |
| 79: | |
| 80: | |
| 81: | |
| 82: | |
| 83: | |
| 84: | |
| 85: | |
| 86: | |
| 87: | public function get($hostedCheckoutId, CallContext $callContext = null) |
| 88: | { |
| 89: | $this->context['hostedCheckoutId'] = $hostedCheckoutId; |
| 90: | $responseClassMap = new ResponseClassMap(); |
| 91: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\GetHostedCheckoutResponse'; |
| 92: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
| 93: | try { |
| 94: | return $this->getCommunicator()->get( |
| 95: | $responseClassMap, |
| 96: | $this->instantiateUri('/v1/{merchantId}/hostedcheckouts/{hostedCheckoutId}'), |
| 97: | $this->getClientMetaInfo(), |
| 98: | null, |
| 99: | $callContext |
| 100: | ); |
| 101: | } catch (ErrorResponseException $e) { |
| 102: | throw $this->getResponseExceptionFactory()->createException( |
| 103: | $e->getHttpStatusCode(), |
| 104: | $e->getErrorResponse(), |
| 105: | $callContext |
| 106: | ); |
| 107: | } |
| 108: | } |
| 109: | |
| 110: | |
| 111: | |
| 112: | |
| 113: | |
| 114: | |
| 115: | |
| 116: | |
| 117: | |
| 118: | |
| 119: | |
| 120: | |
| 121: | |
| 122: | |
| 123: | |
| 124: | |
| 125: | |
| 126: | public function delete($hostedCheckoutId, CallContext $callContext = null) |
| 127: | { |
| 128: | $this->context['hostedCheckoutId'] = $hostedCheckoutId; |
| 129: | $responseClassMap = new ResponseClassMap(); |
| 130: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse'; |
| 131: | try { |
| 132: | return $this->getCommunicator()->delete( |
| 133: | $responseClassMap, |
| 134: | $this->instantiateUri('/v1/{merchantId}/hostedcheckouts/{hostedCheckoutId}'), |
| 135: | $this->getClientMetaInfo(), |
| 136: | null, |
| 137: | $callContext |
| 138: | ); |
| 139: | } catch (ErrorResponseException $e) { |
| 140: | throw $this->getResponseExceptionFactory()->createException( |
| 141: | $e->getHttpStatusCode(), |
| 142: | $e->getErrorResponse(), |
| 143: | $callContext |
| 144: | ); |
| 145: | } |
| 146: | } |
| 147: | |
| 148: | |
| 149: | private function getResponseExceptionFactory() |
| 150: | { |
| 151: | if (is_null($this->responseExceptionFactory)) { |
| 152: | $this->responseExceptionFactory = new ExceptionFactory(); |
| 153: | } |
| 154: | return $this->responseExceptionFactory; |
| 155: | } |
| 156: | } |
| 157: | |