-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Rewrite placeOrder and support multiple payments for an order #4908
Conversation
Switch from placeOrderWithStripeCardPayment mutation to placeOrder mutation
to captureOrderPayments GraphQL mutation
And use captureOrderPayments GraphQL mutation
when placing an order
supported methods" check boxes
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.
@@ -97,7 +98,8 @@ class OrderTable extends Component { | |||
|
|||
renderOrderInfo(order) { | |||
const { displayMedia, moment } = this.props; | |||
const { invoice } = getPaymentForCurrentShop(order); | |||
const [payment] = order.payments || []; | |||
const { amount } = payment || {}; |
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.
Can you explain how this is working to me? I think it's just a syntax I haven't seen before, but if this is a payment in an array, how are we extracting amount directly from payment?
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.
const [payment]
takes the first payment and saves it in the payment
const (array destructuring). Then I destructure the amount
property off payment
.
Ideally we shouldn't be using only the first payment anywhere, but I was trying to avoid doing too many changes in this one PR.
That is something unrelated that I fixed in RC8 branch. I'll merge the fix into
I thought this was always the case but maybe not. Either way, what you say makes sense. I should be able to update the cancellation method to skip refunding if the payment isn't captured yet.
Good catch. I'll fix.
I'll investigate |
The cancellation button was hidden - you needed to click the down arrow next to the |
Right, but I seem to remember it didn't work for me until after capturing. It just did nothing when I clicked it. |
and update to avoid rounding errors
@kieckhafer All of the bugs you found should be fixed now. @dancastellon I fixed sending the order emails when payments don't have a billing address, and I added a way for payment methods to indicate they don't support refunding. Add |
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.
Code-wise this looks good to me. I did a quick bit of testing with my rewards payment method prototype and it still works.
…order-rewrite # Conflicts: # imports/plugins/core/versions/server/migrations/index.js
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.
On first start up, I'm seeing this message:
Exception from sub OrderImages id 9pSNCnMxnwNZXcecT TypeError: Cannot read property 'shipping' of undefined
at Subscription.Meteor.publish.orderId [as _handler] (imports/plugins/core/core/server/publications/collections/orders.js:223:28)
at currentArgumentChecker.withValue (packages/check/match.js:118:15)
at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1304:12)
at Object._failIfArgumentsAreNotAllChecked (packages/check/match.js:116:43)
at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1764:18)
at DDP._CurrentPublicationInvocation.withValue (packages/ddp-server/livedata_server.js:1043:15)
at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1304:12)
at Subscription._runHandler (packages/ddp-server/livedata_server.js:1041:51)
at Session._startSubscription (packages/ddp-server/livedata_server.js:859:9)
at Session.sub (packages/ddp-server/livedata_server.js:625:12)
at packages/ddp-server/livedata_server.js:559:43
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.
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.
All changes look good! Merging it! 👍
Resolves #4860
Impact: breaking
Type: feature
Changes
The primary change is that when placing an order, you can now pay with multiple payment methods. A variety of other changes needed to be made as a result.
MongoDB schema changes:
payment
property on each order fulfillment group. Rather there is apayments
array on the order itself, and payments are not associated with any particular fulfillment group.currencyCode
property is added toinvoice
for use by that resolvercaptureErrorCode
andcaptureErrorMessage
properties are added topayment
so that the operator UI can display capture error messagesinvoice
was previously on each fulfillment group and also on eachpayment
. It's no longer onpayment
because payments no longer correspond to just one group.payment.data.billingAddress
because it's already onpayment.address
GraphQL schema changes:
placeOrder
GraphQL mutation supports placing an order with multiple payments for it._id
is now optional onAddress
typeshippingAddress
andshop
fields added toFulfillmentGroup
typepayments
field added toOrder
typestatus
field is added toPayment
type and is defined by newPaymentStatus
enumplaceOrderWithExampleIOUPayment
mutation is removedplaceOrderWithStripeCardPayment
mutation is removedcaptureOrderPayments
mutation to replace the "orders/capturePayments" Meteor method. It has a similar API but allows you to pass an array of payment IDs to capture only certain payments.Meteor method changes:
orders/approvePayment
method signature changed from(order)
to(orderId, paymentId)
Refactoring:
payments
plugin rather than in the core plugin's startup code.createOrder
internal mutation function is removedmarketplace
plugin. That plugin should not require thestripe
plugin.Operator UI:
OrderPayment
React componentBug fixes:
Breaking changes
All of the individual
placeOrder*
GraphQL mutations provided by the built-in payment plugins are removed and replaced with a singleplaceOrder
mutation that supports multiple payments. ThecreateOrder
internal mutation that these used is also gone, so this will break any custom payment method plugins.See also any with BREAKING above.
Testing
It's easiest to test this along with the starter kit changes. See the testing instructions in reactioncommerce/example-storefront#477