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

v5.0: Improve DX of Gateways #811

Merged
merged 18 commits into from
Feb 13, 2023
Merged

v5.0: Improve DX of Gateways #811

merged 18 commits into from
Feb 13, 2023

Conversation

duncanmcclean
Copy link
Owner

@duncanmcclean duncanmcclean commented Feb 11, 2023

This pull request aims to improve the developer experience around building custom payment gateways.

The signatures for gateway methods have changed. Instead of dealing with custom objects, you're now dealing with simple arrays.

For developers building gateways for the first time, the Gateway contract now includes some documentation about each of the methods in docblocks.

Upgrade Guide

As part of improving the developer experience, there's been some changes the API for implementing custom gateways.

If you're using a custom gateway, you will need to make some manual changes:

prepare

  • The parameters for this method have changed. It now accepts $request and $order parameters, instead of a Prepare object.
  • This method no longer returns a Response, instead it simply returns an array.

purchase

  • This method has been renamed checkout
  • The parameters for this method have changed. It now accepts $request and $order parameters, instead of a Prepare object.
  • This method no longer returns a Response, instead it simply returns an array.

purchaseRules

  • This method has been renamed checkoutRules

purchaseMessages

  • This method has been renamed checkoutMessages

getCharge

  • This method has been removed. It wasn't used by Simple Commerce anywhere so it didn't make sense to keep it.
  • If you use it inside your gateway's class, you can keep it.

refundCharge

  • This method has been renamed refund
  • This method now returns an array. The contents of which will be saved to the order's gateway data for future reference.

paymentDisplay

  • This method has been renamed fieldtypeDisplay

To Do

  • Update documentation around writing custom gateways
  • Add notes to upgrade guide
  • Update on-site/off-site stubs
  • Save returned array of refund method for future reference
  • Implement any other TODOs

@duncanmcclean duncanmcclean added this to the v5.0 milestone Feb 11, 2023
@duncanmcclean duncanmcclean marked this pull request as ready for review February 13, 2023 22:35
@duncanmcclean duncanmcclean merged commit eb3b50e into 5.x Feb 13, 2023
@duncanmcclean duncanmcclean deleted the simplify-gateway-dx branch February 13, 2023 22:48
@github-actions
Copy link

Released as part of v5.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant