Coder Social home page Coder Social logo

Comments (5)

brchristian avatar brchristian commented on August 19, 2024

We are looking at building out a subscription implementation on top of solidus_stripe, and persistent customer accounts are a critical first step, so adding a +1 to this. LMK if I can help with a PR...

from solidus_stripe.

brchristian avatar brchristian commented on August 19, 2024

It seems to me that in an ideal world, this extension would include a migration to add a stripe_gateway_customer_id to the Spree::Users table.

But, maybe there's another way to do it. When creating a new Spree::CreditCard object, we can attempt to populate the gateway_customer_id field like so:

gateway_customer_profile_id = source.user&.
payment_sources&.where&.not(gateway_customer_profile_id: nil)&.order(:updated_at)&.last&.
gateway_customer_profile_id

@spaghetticode What do you think about trying something like that?

from solidus_stripe.

brchristian avatar brchristian commented on August 19, 2024

Updating with two pieces of information. First is that I've created a (failing) spec at #77 to demonstrate this issue.

Second is that I have begun tracking down the cause. I believe the key lines are here:

response = gateway.store(creditcard, options)
if response.success?
if v3_intents?
payment.source.update!(
cc_type: payment.source.cc_type,
gateway_customer_profile_id: response.params['customer'],
gateway_payment_profile_id: response.params['id']
)
else
payment.source.update!(
cc_type: payment.source.cc_type,
gateway_customer_profile_id: response.params['id'],
gateway_payment_profile_id: response.params['default_source'] || response.params['default_card']
)
end
else
payment.send(:gateway_error, response.message)
end

Here you can see how we're setting the gateway_customer_profile_id. Of course, a trivial way to make the specs in #77 pass would be to change the lines that directly update the payment source, but this would not be sufficient because the data would look right to Solidus and in the database, but would not actually be correct in Stripe.

It seems that we need to link this to the customer either before or during the call to gateway.store. This method lives in ActiveMerchant. So, I'll keep digging and update this thread when I learn more.

from solidus_stripe.

brchristian avatar brchristian commented on August 19, 2024

Update: the specs are now green in #77, which should solve this issue.

from solidus_stripe.

stale avatar stale commented on August 19, 2024

This issue has been automatically marked as stale because it has not had recent activity. It might be closed if no further activity occurs. Thank you for your contributions.

from solidus_stripe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.