protected function PaymentReferenceBase::buildCompletePaymentLink in Payment 8.2
Builds the "Complete payment" link.
Parameters
mixed[] $element: The root element.
\Drupal\Core\Form\FormStateInterface $form_state:
Return value
array A render array.
2 calls to PaymentReferenceBase::buildCompletePaymentLink()
- PaymentReferenceBase::ajaxPay in src/
Element/ PaymentReferenceBase.php - Implements form AJAX callback.
- PaymentReferenceBase::buildPaymentForm in src/
Element/ PaymentReferenceBase.php - Builds the payment form.
File
- src/
Element/ PaymentReferenceBase.php, line 415
Class
- PaymentReferenceBase
- Provides a base for payment reference elements.
Namespace
Drupal\payment\ElementCode
protected function buildCompletePaymentLink(array $element, FormStateInterface $form_state) {
$plugin_selector = $this
->getPluginSelector($element, $form_state);
/** @var \Drupal\payment\Plugin\Payment\Method\PaymentMethodInterface $payment_method */
$payment_method = $plugin_selector
->getSelectedPlugin();
$build = [];
if ($payment_method && !$payment_method
->getPayment()
->isNew()) {
$build['message'] = array(
'#markup' => $this
->t('@payment_method_label requires the payment to be completed in a new window.', array(
'@payment_method_label' => $payment_method
->getPluginDefinition()['label'],
)),
);
$build['link'] = array(
'#attributes' => array(
'class' => array(
'button',
'payment-reference-complete-payment-link',
),
'target' => '_blank',
),
'#url' => $payment_method
->getPayment()
->toUrl('complete'),
'#title' => $this
->t('Complete payment'),
'#type' => 'link',
);
}
return $build;
}