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

🧹 Marketplace: Cache the fee amount on the Order #1701

Merged

Conversation

zspencer
Copy link
Member

In order to pull the splitting of the payment to a retriable background job; we need to cache the payment processor fee information.

- #1327

In order to pull the splitting of the payment to a retriable background
job; we need to cache the payment processor fee information.
@zspencer
Copy link
Member Author

See #1702 for the usage of this cached value

@zspencer zspencer added the 🧹 refactor Includes non-behavioral changes label Jul 25, 2023
Copy link
Member

@anaulin anaulin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments below.

def vendors_share
product_total - payment_processor_fee
end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should product_total be monetized as well? It seems odd to be substracting two values, one of which is monetized and the other one isn't.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

product_total is monetized, in that it sums the monetized product_price * quantity

@@ -21,7 +21,7 @@ def create
latest_charge = Stripe::Charge.retrieve(payment_intent.latest_charge, api_key: marketplace.stripe_api_key)
balance_transaction = Stripe::BalanceTransaction.retrieve(latest_charge.balance_transaction, api_key: marketplace.stripe_api_key)

order.update(status: :paid, placed_at: DateTime.now)
order.update(status: :paid, placed_at: DateTime.now, payment_processor_fee_cents: balance_transaction.fee)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not from this PR, but I'm noticing that we do this .update and don't seem to be checking for success, opening us up to the possibility that this update will fail, the order won't be marked as paid, but notifications and other parts of the "order pipeline" would continue as if everything was fine.

One quick fix would be to throw a ! onto the order.update call.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Will do!

@zspencer zspencer merged commit 3186adf into main Jul 27, 2023
@zspencer zspencer deleted the marketplace/perform-transfer-in-background-so-it-can-retry branch July 27, 2023 00:09
zspencer added a commit that referenced this pull request Jul 28, 2023
zspencer added a commit that referenced this pull request Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧹 refactor Includes non-behavioral changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants