-
Notifications
You must be signed in to change notification settings - Fork 112
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
feat(payment_providers): Add MoneyHash #3117
base: main
Are you sure you want to change the base?
Conversation
Hi @shahwan42, This is awesome! Thank you contributing such a large feature. I had a quick look and it looks great but first, we need to confirm with the product team how they feel about adding MoneyHash support. We'll review it but I had a quick look and it looks great. We'll have to do some QA testing to feel comfortable maintaining it in the future. I'm sure you can help to get a testing account and for any question we'll have. 👍 |
Thank you for seeing this. Regarding this particular PR, I updated it and
Should I do anything else? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I had a first pass and left some initial comments 🙏
case object&.payment_provider&.to_sym | ||
when :stripe | ||
object.stripe_customer | ||
when :gocardless | ||
object.gocardless_customer | ||
when :cashfree | ||
object.cashfree_customer | ||
when :adyen | ||
object.adyen_customer | ||
end | ||
return unless object | ||
|
||
provider_mapping = { | ||
stripe: :stripe_customer, | ||
gocardless: :gocardless_customer, | ||
cashfree: :cashfree_customer, | ||
adyen: :adyen_customer, | ||
moneyhash: :moneyhash_customer | ||
} | ||
|
||
method = provider_mapping[object.payment_provider&.to_sym] | ||
object.public_send(method) if method |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather avoid this kind of refactoring. I understand the feeling but we use case/when everywhere for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it because Rubocop complained because of the function complexity. Should I ignore it?
|
||
def perform(payable) | ||
result = PaymentRequests::Payments::MoneyhashService.new(payable).create | ||
PaymentRequestMailer.with(payment_request: payable).requested.deliver_later if result.payable&.payment_failed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this email seems already sent by the service: https://github.com/getlago/lago-api/pull/3117/files#diff-a2398e1f364bebdeee9aab55a0d5044ad225b890d3f58badb3eda1ffa9eaf6b2R80
PENDING_STATUSES = %w[processing] | ||
.freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PENDING_STATUSES = %w[processing] | |
.freeze | |
PENDING_STATUSES = %w[processing].freeze |
typo I guess
end | ||
|
||
def call | ||
PaymentRequests::Payments::MoneyhashService.new(@invoice).create |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd expect the opposite. The PaymentRequests::Payments:: MoneyhashService
service to rely on the PaymentProviders::Moneyhash::Payments::CreateService
to create the payment and then do specific things (like sending the email).
I think all the attributes are leftovers too.
PaymentRequestMailer.with(payment_request: payment.payable).requested.deliver_later if result.payable.payment_failed? | ||
result | ||
rescue BaseService::FailedResult => e | ||
result.fail_with_error!(e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We recently fixed a bug where emails weren't sent if we couldn't create the payment, I think you want the same.
https://github.com/getlago/lago-api/pull/3155/files
Hey @shahwan42 , We merged a big style change, nothing important but replaced all single quotes by double quotes for strings. This created tons of conflict so you might have some difficulties rebase your PR. I'd recommend doing it this way:
I can do it for you if you prefer! |
feat(moneyhash): generate graphql schema for moneyhash fix(moneyhash) customer creation fix(moneyhash): webhook feat(moneyhash): update required fields for connection creation/update feat(moneyhash): build webhook_end_point based on LAGO_API_URL feat(moneyhash): Use flow_id if exists fix(moneyhash): correct amount before sending it feat(moneyhash): remove redirect_url cleanup: remove commented code feat(moneyhash): make flow_id required during connection creation feat(moneyhash): Only use flow_id instead of operation feat(moneyhash): add more to custom_fields feat(moneyhash): Implement moneyhash/payments/create_service fix(moneyhash): get agreement_id from subscription_external_id fix(payment_providers): possible types regenerate graphql schema fix formatting according to rubocop revert unrelated change shorten Types::Customers::Object#provider_customer better refactor Types::Customers::Object#provider_customer feat(moneyhash): put-back-success-url-field Expected by code shared between providers feat(moneyhash): revert a refactor, disable rubocop rule cleanup: remove unncessary newline remove potential duplicate email calls Send email when can't create a payment, too Fix payment_url for one-off invoices Remove expire_after_seconds for invoice payments Revamp PaymentProviders::Moneyhash::Payments::CreateService
Hi @julienbourdeau For the There is some duplicate code since I have to move slowly and carefully because I'm still getting my hands into Ruby/Rails, and will improve it iteratively. Appreciate your effort and patience. |
Roadmap Task
NA
Feature Request
https://getlago.canny.io/feature-requests/p/integration-with-moneyhash-for-payment-orchestration
Context
MoneyHash is a leading payment infrastructure software in Africa and the Middle East. Our biggest features are providing a superior payment orchestration for many payment providers in the region, smart payment routing among other features.
We have common customers, and it's a needed feature to have MoneyHash integrated into Lago.
This PR integrates MoneyHash as a payment provider for Lago's customers.
Description
This PR implements the following changes
List any dependencies that are required.
NA