Fixed Payment gateway integration error

lifehome

Member
Hello there,

I have a fresh (test) installation of XF 2.0.4 with proper Stripe API configured, and when my test pilots try to purchase any of the membership upgrades, despite it is their card problem, an unexpected error was shown to the users as below. However, there is no error logged or visible through admin panel.

Received unknown parameters: name, statement_descriptor
mifaESI.png


Please kindly share if you know what's going on.

Regards,
Ivan
 
We have tested a bit more, and turns out the Stripe gateway returns this error even correct and valid credit card information inserted.
 
Unfortunately this is caused by a breaking change in the Stripe API.

Until we resolve it, you won't be able to accept Stripe for recurring payments.
Thanks for the clarification. However, is there any ETA for the bugfix? As we are "kinda" rely on the patron donation to keep our community running.
 
You would simply have to enable a different payment provider such as PayPal or Braintree. Braintree supports both PayPal payments and/or credit card.

PayPal is probably the easiest to set up for now.
 
You would simply have to enable a different payment provider such as PayPal or Braintree. Braintree supports both PayPal payments and/or credit card.

PayPal is probably the easiest to set up for now.
Thanks, we do have the other two and 2Checkout with us, but unfortunately we are unable to use'em for some regional reason. So I guess we will wait and seek possible alternatives meantime.
 
FWIW you can pass an Stripe-Version header with the specific API version to prevent anyone using an incorrect Stripe API version by default in their account from breaking things since Stripe does allow you to click a button to upgrade your default API but I don't think they let you downgrade

https://stripe.com/docs/api#versioning
 
FWIW you can pass an Stripe-Version header with the specific API version to prevent anyone using an incorrect Stripe API version by default in their account from breaking things since Stripe does allow you to click a button to upgrade your default API but I don't think they let you downgrade

https://stripe.com/docs/api#versioning
Thanks for the tip, we were actually aware of that, just not the right timing to. As the fact that we have a script to automagically update the API endpoint and notify us of it, thus we can be a step ahead to comply with some regulation checks. But when it comes to XF, our first thought was "version is new enough" and nothing else... (argh

We did have a 3-hour rollover gap(officially would be 72hrs, but we got SLA :/ ), so the bug did disappeared for a while when we tries to reproduce.
 
FWIW you can pass an Stripe-Version header with the specific API version to prevent anyone using an incorrect Stripe API version by default in their account from breaking things since Stripe does allow you to click a button to upgrade your default API but I don't think they let you downgrade

https://stripe.com/docs/api#versioning
I knew of this, but in retrospect, I think XF should be making use of this generally. We should be in control of when potential code breaking changes are rolled out to customers so that is going to be the solution in this case.
Thanks, we do have the other two and 2Checkout with us, but unfortunately we are unable to use'em for some regional reason. So I guess we will wait and seek possible alternatives meantime.
These are the changes required and what we will include in the next release. It will force the use of the API version prior to the changes which broke this.
Diff:
Index: src/XF/Payment/Stripe.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/XF/Payment/Stripe.php    (revision 466e882018942ddd1f087a00d09bcb926cc3cb7c)
+++ src/XF/Payment/Stripe.php    (date 1523437392000)
@@ -9,6 +9,10 @@
 
 class Stripe extends AbstractProvider
 {
+    // Force a specific Stripe version so we can better control when we are ready for potential code breaking changes.
+    // TODO: Changes required to support new "Billing" system so we can move beyond this API version.
+    protected $stripeVersion = '2018-01-23';
+
     public function getTitle()
     {
         return 'Stripe';
@@ -89,6 +93,7 @@
         try
         {
             $client = \XF::app()->http()->client();
+            $client->setDefaultOption('headers', ['Stripe-Version' => $this->stripeVersion]);
 
             $customerData = [
                 'email' => $purchase->purchaser->email,
@@ -249,6 +254,8 @@
         try
         {
             $client = \XF::app()->http()->client();
+            $client->setDefaultOption('headers', ['Stripe-Version' => $this->stripeVersion]);
+
             $response = $client->delete($this->getApiEndpoint() . '/v1/customers/' . $customerId . '/subscriptions/' . $subscriberId, [
                 'auth' => [$secretKey, '']
             ]);
@@ -459,6 +466,8 @@
         try
         {
             $client = \XF::app()->http()->client();
+            $client->setDefaultOption('headers', ['Stripe-Version' => $this->stripeVersion]);
+
             $response = $client->get($this->getApiEndpoint() . '/v1/events/' . $state->transactionId, [
                 'auth' => [$secretKey, '']
             ]);
 
Top Bottom