Stripe is a commonly using payment gateway. For integrating stripe in drupal 8 requires stripe library. We can install stripe library using composer. Use the following command to install stripe library.

public function buildForm(array $form, FormStateInterface $form_state) {
  $stripe=array("secret_key"=>
  "********************", //Give your api keys for stripe account
  "publishable_key"=>
  "********************" //Give your api keys for stripe account
  );
  \Stripe\Stripe: :setApiKey($stripe['secret_key']);
  $publishable_key=$stripe['publishable_key'];
  $stripe_email=$_SESSION['stripe_email']; //Give your mail id
  $amount=100; //Give your  amount to be transfer
  $stripe amount=$amount *100;
  $form ['pay_button']=array('#type'=>
  'markup',
  '#markup'=>
  new FormattableMarkup('<p><script             src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="' . $stripe['publishable_key'] . '"data- data-amount="' . $stripe amount . '"data-description="User Registration"data-currency="EUR"data-email="' .  $stripe_email . '">
  </script>
  </p>
  ', []),
);
  $form['submit']=array('#type'=>
  'submit',
  '#value'=>
  $this->
  t('Save'),
  '#button_type'=>
  'primary',
  );
  return $form;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &
$form, FormStateInterface $form_state) {
  $token=$_POST['stripeToken'];
  $stripe=array("secret_key"=>
  "********************",
  "publishable_key"=>
  "********************"
  );
  \Stripe\Stripe: :setApiKey($stripe['secret_key']);
  $customer=\Stripe\Customer: :create(array('email'=>
  $mail, //give your mail id
  'card'=>
  $token));
  $description="User Registration";
  $charge=\Stripe\Charge: :create(array("amount"=>
  $amount, //Give your  amount to be transfer,
  'customer'=>
  $customer->
  id,
  "currency"=>
  "EUR", //You can change the currency format
  "description"=>
  $description));
  $msg="Successfully charged ".$amount;
  drupal_set_message($msg);
}

The easiest way to solve an issue is to let it deal by experts. We can provide a wide range of services, which will help you maintain and manage your websites. Get in touch with us to know more.