How to use Stripe Connect Plugin with Hikamarket

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
5 years 7 months ago #296543

Hello,

Sure, if you do not provide the "additional data" (which is an existing variable in the view) it won't work as expected because you do not provide the required information for the process.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 128
  • Thank you received: 2
5 years 7 months ago #296574

Hi Jerome,

But with the additionalData as it is in your code is NOT working, the form does NOT even get submitted that way. Please try it.

By looking at the example in the Stripe documentation: stripe.com/docs/stripe-js/elements/quickstart#create-token

You will see they do it like this:

 stripe.createToken(card).then(function(result) {

Because the JavaScript was getting blocked at that line, I thought the additionalData variable was badly formatted so I tried like this as well
  stripe.createToken(card, JSON.stringify(additionalData) ).then(function(result) {

And that gets the form submitted as well but it ends in the same error as when removing the additionalData completely from the createToken call:
 {
  "error": {
    "code": "missing",
    "doc_url": "https://stripe.com/docs/error-codes/missing",
    "message": "Cannot charge a customer that has no active card",
    "param": "card",
    "type": "card_error"
  }
}

Please test it and let me know what you find out

Many thanks!

Last edit: 5 years 7 months ago by sabroso.

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
5 years 7 months ago #296592

Hello,

The second parameter is there for a good reason : Support of Stripe Radar (anti fraud).
CF : stripe.com/docs/stripe-js/reference#stripe-create-token

Now, if you can provide concrete details about the JS error or your tests content ; it would help us to help you.
Because I'm sorry but I won't remove the additional data or modify the plugin without concrete details ; specially when I know that the plugin is currently used and working in several websites.

But knowing that you're using old version of HikaShop and HikaMarket ; it could be possible that you version do not have details or information that are required by the plugin to work properly.
In any case ; I need details to understand your issue.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 128
  • Thank you received: 2
5 years 7 months ago #296598

Hi Jerome,

I found where the problem was. The JavaScript Object sent to Stripe need to have all the properties as string.. Because I had two properties as null that was creating the problem. Now I remove from the $this->additionalDate array all the properties set to null before doing the jsonencode and that works, the form gets submitted.

BUT there is a problem after that. If it is the FIRST time the user pays, hikashop needs to
1) create a new user in Stripe
2) activate the card

I think step 2 is missing because I'm seeing this error in the Stripe logs when the charge to the card tries to get created

{
  "error": {
    "code": "missing",
    "doc_url": "https://stripe.com/docs/error-codes/missing",
    "message": "Cannot charge a customer that has no active card",
    "param": "card",
    "type": "card_error"
  }
}

If the user tries a SECOND time then it goes through because it uses the Stripe User ID stored in the hikashop_user table, user_params column
O:8:"stdClass":1:{s:25:"stripeconnect_customer_id";s:18:"cus_DOK41Aj8oQrGY8";}

So, to reproduce the problem just delete the stripeconnect_customer_id property from the user_params column before doing the payment (to simulate it is the FIRST time this user makes a stripe connect payment) and it should fail

Thanks

Last edit: 5 years 7 months ago by sabroso.

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
5 years 7 months ago #296610

Hello,

Okay !
So in order to avoid issue with empty additional fields ; we can add some code to remove them if they are empty.

if(!empty($order->cart->billing_address->address_street2))
	$this->additional_data['address_line2'] = $order->cart->billing_address->address_street2;
foreach($this->additional_data as $k => $v) {
	if(empty($v))
		unset($this->additional_data[$k]);
}
Please let me know if it fix the issue in your side or "pushing" empty strings would be better.

Regarding the workflow on the card/customer, the plugin is following that workflow : stripe.com/docs/saving-cards
I perform a test with a new account and I was able to see the problem with the token parameter.
I updated the plugin (hikashoppayment one) with the patch.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 128
  • Thank you received: 2
5 years 7 months ago #296627

Hi Jerome,

Thanks for that.

I fixed the JavaScript issue by doing:

$additional_data = array_filter($this->additional_data);

and then on the JavaScript code:
var additionalData = '.json_encode($additional_data).';

That avoids sending null values and it works. thanks for your code I'm sure it also works

OK I tested the problem with the first time a user pays with your new version of the plugin. And it is working fine as long as I choose "Preferred Charge Mode: Destination" in the payment method configuration-> thanks for adding this setting!

However payments don't work when setting "Preferred Charge Mode: Direct" and the error from Stripe is:
{
  "error": {
    "code": "resource_missing",
    "doc_url": "https://stripe.com/docs/error-codes/resource-missing",
    "message": "No such customer: cus_DOQJaWk2py3vU5",
    "param": "customer",
    "type": "invalid_request_error"
  }
}

That error appears in the log of the Vendor Stripe account (the connected account as per Stripe terminology) because now the charge is applied directly to the Vendor Stripe account. However the problem comes from the fact that the customer was added to my Stripe Account, which is the platform Stripe account and what I set in the Joomla Plugin.

So i think to be able to do DIRECT payments the plugin will need to add BOTH the customer and the charge to the the Vendor's Stripe account (the connected account as per Stripe terminology)

Please have a look and let me know, many thanks!

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
5 years 7 months ago #296628

Hello,

Indeed, the "direct" mode was more complicated that I originally though.
Since the customer is created in the main stripe account ; it require the usage of a "shared customer" or the generation of the temp token.
CF : stripe.com/docs/connect/shared-customers

I added some code in the plugin to generate a token when using direct payment.
Creating share customer would be too complicated to handle since it would require to store the customer ID for each vendor. I prefer to store just one single ID and then create the token dynamically when required. Vendor won't be able to create subscriptions for these customer but I don't think it would be required.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 128
  • Thank you received: 2
5 years 7 months ago #296675

Hi Jerome,

Thanks for that.

I tested direct payment and unfortunately it did NOT work.

I tested with a new user (i.e. a user in hikashop_user table without a Stripe Connect ID in user_params) and this is what I saw in the Stripe logs:

In the Stripe platform account (my stripe account):

  • Creates Token OK
  • Creates Customer OK

Then in the Stripe connected account (the Vendor Account):
  • generates new token OK
  • Create Charge -> FAILS

this is the error message:
{
  "error": {
    "code": "parameter_unknown",
    "doc_url": "https://stripe.com/docs/error-codes/parameter-unknown",
    "message": "Received unknown parameter: token",
    "param": "token",
    "type": "invalid_request_error"
  }
}


Please double check, thanks!

Last edit: 5 years 7 months ago by sabroso.

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
5 years 7 months ago #296676

Hello,

I made a new update on the plugin.
If the next test do not work ; I will remove the "direct payment" setting from the plugin.
I added that in a rush so if it require more development, I will do it later and with proper tests.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 128
  • Thank you received: 2
5 years 7 months ago #296709

Hi Jerome,

Sorry, but it is not my fault that the plugin didn’t work. In fact, I think I have been very generous with my time and help in order to help you test it and debug it.

I have very high respect for my customers, that’s why I test everything before implementing it in my live site.

However I’m not sure you have the same respect for your customers since you are sending us software that has been developed in a rush and that is untested.

I said I would buy this plugin if you implemented stripe direct charges and you said you had done it. That’s why I bought it, because I trusted you and thought that if you said you had done it you would have developed it professionally and fully tested. However I’m very disappointed that it wasn’t the case.

I have many customers interested in this payment solution and I’m sure you also have other people interested in getting this puglin. So I believe it is in your interest as much as in my interest that this plugin works well and reliably. So I hope you keep helping developing and fixing what does not work.

Coming back to the plugin, I tested again and it looks like direct charges are going through OK now. Thanks for that. However there are a lot of things to fix and improve in the plugin yet:

1. In the hikashop payment method configuration, in the “Specific Configuration” section I have:

  • Invalid Status: created
  • Pending Status: created
  • Verified Status: confirmed

As you can see, I don’t want to cancel the order if the payment fails or the customer abandons the payment. I want to allow buyers to come back later and pay their orders. This works for other payment plugins I have but it does NOT work for Stripe Connect. If the customer goes to his orders section, selects Stripe Connect as payment method and clicks the “Pay Now” button it is NOT asked to input his credit card. The same problem with the “pay now” button in the order created email notification.

2. If the card is declined by Stripe (test with card number 4000 0000 0000 0002), Hikashop goes back to the last step of the checkout process but there is no message whatsoever that says “your card has been declined”. This is horrible for usability, the customer needs to understand what happened.

3. In the step where the stripe widget/form is showed and the customer inputs his credit card, once he clicks the button “submit payment”, we need to show a message of “please wait and a loader icon” or similar, otherwise it looks like nothing is happening.

Here’s another chance for you to demonstrate you are willing to provide quality software and support your customers.

Many thanks

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
5 years 7 months ago #296716

Hello,

In the first page of that thread, we talked about what should be a little feature addition :
www.hikashop.com/forum/23-market-how-to/...?limitstart=0#295804

That very specific feature, has been added while I was in holidays because I wanted to be nice.
And as I explained in previous messages ; that feature was bigger than expected since it affected the way than customers are internally handled by Stripe. So it was not something which can be added in a short time.

Regarding the test of the Stripe Connect plugin, it has been tested and is currently working in several websites in production.
I noted your feedback and we will update the plugin soon, following our regular development workflow.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

Moderators: Obsidev
Time to create page: 0.064 seconds
Powered by Kunena Forum