Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
buildValidatePayload example
$appPaymentMethod
=
$context
->
getPaymentMethod
(
)
->
getAppPaymentMethod
(
)
;
if
(
$appPaymentMethod
=== null
)
{
throw
PaymentException::
validatePreparedPaymentInterrupted
(
'Loaded data invalid'
)
;
}
$validateUrl
=
$appPaymentMethod
->
getValidateUrl
(
)
;
if
(
empty
(
$validateUrl
)
)
{
return
new
ArrayStruct
(
)
;
}
$payload
=
$this
->
buildValidatePayload
(
$cart
,
$requestDataBag
,
$context
)
;
$app
=
$appPaymentMethod
->
getApp
(
)
;
if
(
$app
=== null
)
{
throw
PaymentException::
validatePreparedPaymentInterrupted
(
'App not defined'
)
;
}
try
{
$response
=
$this
->payloadService->
request
(
$validateUrl
,
$payload
,
$app
, ValidateResponse::
class
,
$context
->
getContext
(
)
)
;
}
catch
(
ClientExceptionInterface
$exception
)
{
throw
PaymentException::
validatePreparedPaymentInterrupted
(
sprintf
(
'App error: %s',
$exception
->
getMessage
(
)
)
)
;
}