PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.5
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.5
1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 All 49 releases
← All changes | app/Modules/PaymentMethods/StripeGateway/API/API.php +18 -4 1.6.0 → 1.6.5 View file →
@@ -127,18 +127,32 @@
127 127
128 128 return $data;
129 129 }
130 130
131 - public function getEvent($eventId)
131 + /**
132 + * Event ids are namespaced per mode, so a live id is unfetchable with a test key
133 + * and vice versa. The store's global mode toggle is not a reliable proxy — a
134 + * renewal is billed by Stripe on its own schedule, whatever the store is set to.
135 + *
136 + * @param string $eventId
137 + * @param bool|null $livemode Mode the event belongs to; null falls back to the store setting.
138 + * @return object|null|\WP_Error Null when the response body is not decodable JSON.
139 + */
140 + public function getEvent($eventId, $livemode = null)
132 141 {
133 - $api = $this->getApi();
142 + $mode = 'current';
143 + if (!is_null($livemode)) {
144 + $mode = $livemode ? 'live' : 'test';
145 + }
146 +
147 + $api = $this->getApi($mode);
134 148 return $api::request([], 'events/' . $eventId, 'GET');
135 149 }
136 150
137 - public function getApi()
151 + public function getApi($mode = 'current')
138 152 {
139 153 $api = new ApiRequest();
140 - $api::set_secret_key((new StripeSettingsBase())->getApiKey());
154 + $api::set_secret_key((new StripeSettingsBase())->getApiKey($mode));
141 155 return $api;
142 156 }
143 157
144 158 public function getApiKey($mode = 'current')