Procházet zdrojové kódy

added email address for current user to donation homepage item

CauseFX před 4 roky
rodič
revize
8c2a39fab2
1 změnil soubory, kde provedl 6 přidání a 2 odebrání
  1. 6 2
      api/homepage/donate.php

+ 6 - 2
api/homepage/donate.php

@@ -117,7 +117,7 @@ trait DonateHomepageItem
 			$stripe = new \Stripe\StripeClient(
 				trim($this->config['homepageDonateSecretToken'])
 			);
-			$session = $stripe->checkout->sessions->create([
+			$sessionInfo = [
 				'payment_method_types' => ['card'],
 				'line_items' => [[
 					'price_data' => [
@@ -130,7 +130,11 @@ trait DonateHomepageItem
 				'mode' => 'payment',
 				'success_url' => $this->getServerPath() . 'api/v2/homepage/donate/success',
 				'cancel_url' => $this->getServerPath() . 'api/v2/homepage/donate/error',
-			]);
+			];
+			if ($this->user['email'] && stripos($this->user['email'], 'placeholder') == false) {
+				$sessionInfo = array_merge($sessionInfo, ['customer_email' => $this->user['email']]);
+			}
+			$session = $stripe->checkout->sessions->create($sessionInfo);
 			header('HTTP/1.1 303 See Other');
 			header('Location: ' . $session->url);
 		} catch (\Stripe\Exception\ApiErrorException $e) {