Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/stripe payment gateway support #256

Conversation

kidunot89
Copy link
Member

Your checklist for this pull request

Thanks for sending a pull request! Please make sure you click the link above to view the contribution guidelines, then fill out the blanks below.

🚨Please review the guidelines for contributing to this repository.

  • Make sure you are making a pull request against the develop branch (left side). Also you should start your branch off our develop.
  • Make sure you are requesting to pull request from a topic/feature/bugfix branch (right side). Don't pull request from your master!

What does this implement/fix? Explain your changes.

Adds supports for processing payments using the Stripe payment gateway and the checkout mutation.

  • To do this the IDs of the Stripe Customer, Source, and Payment Intent objects connected to the future order must be provided as _stripe_customer_id, _stripe_source_id, and _stripe_intent_id to the metaData field in the CheckoutInput when executing the mutation.
  • This only works with the Stripe payment gateway currently as far as I know, however other payment gateways may use WooCommerce order meta field to process order payments.
  • If you need a explain of sorts you can view this test. The stripe/stripe-php library is used to execute the Stripe API requests and create the stripe objects. This process can also be in client-side in Javascript with the Stripe JavaScript libraries and it's encouraged.

Does this close any currently open issues?

Any relevant logs, error output, GraphiQL screenshots, etc?

(If it’s long, please paste to https://ghostbin.com/ and insert the link here.)

Any other comments?

Where has this been tested?

Operating System: Linux Mint 19.2

WordPress Version: 5.2.3

@kidunot89 kidunot89 added the enhancement New feature or request label Apr 6, 2020
@kidunot89 kidunot89 self-assigned this Apr 6, 2020
@renatonascalves
Copy link
Contributor

Is this a first attempt/try at #25?

@kidunot89
Copy link
Member Author

kidunot89 commented Apr 6, 2020

Yes and no, that issue is kinda of broad and covers a larger part of the schema then just this. This is a small patch that uses the last parameter on the WC_Gateway_Stripe::process_payment() to force Stripe object ID retrieval from the order meta instead of the $_POST global. It's not a breaking change and Stripe has so much popularity that I didn't see an issue with adding it.

@kidunot89 kidunot89 added the work in progress Solution development in progress label Apr 6, 2020
@renatonascalves
Copy link
Contributor

Understood! I don't see an issue either. Just trying to understand the bigger picture with this PR. Tks for the feedback. :)

@kidunot89 kidunot89 merged commit 6d8bd52 into wp-graphql:release/v0.5.1 Apr 6, 2020
@kidunot89 kidunot89 deleted the feature/stripe-payment-gateway-support branch April 6, 2020 18:46
@kidunot89 kidunot89 mentioned this pull request Apr 15, 2020
7 tasks
@rodrigoreeis
Copy link

rodrigoreeis commented Apr 16, 2020

@kidunot89 I'm still a little lost in relation to this release how do I use it on the front application in me mutation ?

@kidunot89
Copy link
Member Author

kidunot89 commented Apr 23, 2020

@rodrigoreeis First you would need to create the end-user's Stripe Customer, Source, and Payment Intent objects using Stripe.js or one of the other Stripe libraries, then you would pass the IDs of each of those objects as meta on the order.

I plan on writing a guide or tutorial on this later, but for now I recommend just viewing this test as well as the Stripe helper functions using the stripe/stripe-php package. All of the functionality from that package is available in the other Stripe libraries on other platforms.

If it helps the part the may be the most complex is the creation of the source. The stripe source is the instrument of payment, e.g. credit card, bank info. The test uses a test source provide by the stripe api for the purpose of testing only.

@rodrigoreeis
Copy link

@kidunot89 anyway I will have to use some example stripe library stripe/react-stripe-elements ?? and I'm still not quite understanding what the role of these fields is _stripe_customer_id, _stripe_source_id and _stripe_intent_id. I need to confess im lost... 😅

@rodrigoreeis
Copy link

@kidunot89 I believe that it will not be necessary to answer my question above, I am understanding the fields and the code.

I would like to thank you for the great job you are doing with this plugin !! I will probably open some PR in the documentation to be able to make the plugin documentation !

Thanks God bless youuu

@jlundgren77
Copy link

Trying to use checkout mutation with Stripe and coming up empty.

Within the mutation I am passing in as metaData: [ {key: "_stripe_source_id", value: "xxx"}, {key: "_stripe_intent_id", value: "xxx"}, {key: "_stripe_customer_id, value:"xxx}]. These values are being generated server side.
The order shows up in the Wordpress dashboard, but it's not being processed. It shows up as processing.

Any thoughts on what could be going on?

@jonlovera
Copy link

jonlovera commented Jul 26, 2020

Just a quick note

For anyone who arrives at this pull request wondering if all metaData is required. No all of them are required at the same time. If you are working with Stripe.js or @stripe/react-stripe-js you could use the _stripe_source_id to process the order. You can create the _stripe_source_id using stripe.createSource for example.

@darrylmorley
Copy link

@kidunot89 Your link for the example of how this is implemented does not work, do you have an updated link please?

@MobyDigg
Copy link

@kidunot89 the links in your examples do not work anymore. Can you update them?

@jacobarriola
Copy link
Contributor

@MobyDigg @darrylmorley I think the test is here now: https://github.com/wp-graphql/wp-graphql-woocommerce/blob/develop/tests/wpunit/CheckoutMutationTest.php#L1153

@jacobarriola
Copy link
Contributor

@MobyDigg @darrylmorley I messed around with checkout + Stripe over the holidays (with Gatsby) and wrote a blog post about it -> https://jacobarriola.com/post/headless-woocommerce-stripe-checkout-graphql

I hope it helps!

cc @kidunot89

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request work in progress Solution development in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants