$payload['appPaymentMethod'
]['appId'
] =
$appId;
$payload['appPaymentMethod'
]['appName'
] =
$manifest->
getMetadata()->
getName();
$payload['appPaymentMethod'
]['originalMediaId'
] =
$this->
getMediaId($manifest,
$paymentMethod,
$context,
$existingAppPaymentMethod);
if ($existing &&
$existingAppPaymentMethod) { $existingPaymentMethods->
remove($existing->
getId());
$payload['id'
] =
$existing->
getId();
$payload['appPaymentMethod'
]['id'
] =
$existingAppPaymentMethod->
getId();
$media =
$existing->
getMedia();
$originalMedia =
$existingAppPaymentMethod->
getOriginalMedia();
if (($media === null &&
$originalMedia === null
) || ($media !== null &&
$originalMedia !== null &&
$originalMedia->
getId() ===
$media->
getId()) ) { // user has not overwritten media, set new
$payload['mediaId'
] =
$payload['appPaymentMethod'
]['originalMediaId'
];
} } else { $payload['afterOrderEnabled'
] = true;
$payload['mediaId'
] =
$payload['appPaymentMethod'
]['originalMediaId'
];
}