-
Notifications
You must be signed in to change notification settings - Fork 308
[Shopify] Improve synchronization with targeted updates for payment transactions and payouts #6085
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
base: main
Are you sure you want to change the base?
Conversation
…yment transactions and payouts
|
Could not find a linked ADO work item. Please link one by using the pattern 'AB#' followed by the relevant work item number. You may use the 'Fixes' keyword to automatically resolve the work item when the pull request is merged. E.g. 'Fixes AB#1234' |
| if PaymentTransaction.Get(Id) then begin | ||
| PaymentTransaction."Payout Id" := CommunicationMgt.GetIdOfGId(JsonHelper.GetValueAsText(JTransaction, 'associatedPayout.id')); | ||
| PaymentTransaction.Modify(); | ||
| // TODONAT: Anything else to update? |
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 think we are importing new transactions, so I don't expect Get(id) to return anything ever. Ok to keep modification of Payout Id.
| if JsonHelper.GetJsonArray(JResponse, JTransactions, 'data.shopifyPaymentsAccount.balanceTransactions.nodes') then | ||
| foreach JNode in JTransactions do begin | ||
| Id := CommunicationMgt.GetIdOfGId(JsonHelper.GetValueAsText(JNode.AsObject(), 'id')); | ||
| PayoutId := CommunicationMgt.GetIdOfGId(JsonHelper.GetValueAsText(JNode.AsObject(), 'associatedPayout.id')); |
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.
do you want to parse json before get transaction? Maybe move it inside If-Then below.
though we expect both will be executed.
On the other hand. Do we always want to update Payout Id? shall we check that old value is 0 and new value is not 0?
Will server skip modify if Rec.Payout Id = xRec.Payout Id?
| if PaymentTransaction.Get(Id) then begin | ||
| PaymentTransaction."Payout Id" := PayoutId; | ||
| PaymentTransaction.Modify(); | ||
| end; |
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.
don't we need:
DataCapture.Add(Database::"Shpfy Payment Transaction", PaymentTransaction.SystemId, JNode);
| if JsonHelper.GetJsonObject(JResponse, JPaymentsAccount, 'data.shopifyPaymentsAccount') then | ||
| if JsonHelper.GetJsonArray(JResponse, JPayouts, 'data.shopifyPaymentsAccount.payouts.nodes') then | ||
| foreach JNode in JPayouts do begin | ||
| Id := CommunicationMgt.GetIdOfGId(JsonHelper.GetValueAsText(JNode.AsObject(), 'id')); |
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.
Don't we need
DataCapture.Add(Database::"Shpfy Payout", Payout.SystemId, JNode);
| end; | ||
| end; | ||
|
|
||
| internal procedure UpdatePayouts(IdFilter: Text) |
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.
Shouldn't it be more specific "UpdatePayoutStatus("?
Summary
This PR improves the Shopify Payments synchronization logic by implementing targeted GraphQL queries to update payment transaction payout IDs and payout statuses in batches, rather than relying on the previous approach that coupled transaction imports with payout imports.
Changes
New GraphQL Codeunits
GraphQL Type Enum Extension
GetPaymTransByIds(145) andGetPayoutsByIds(146) to ShpfyGraphQLType.Enum.al with implementations pointing to the new codeunitsPayments Codeunit Refactoring
SyncPaymentTransactionstoSyncPayoutsfor clarityUpdatePaymentTransactionPayoutIdsandUpdatePendingPayouts#region Payoutsand#region DisputessectionsPayments API Enhancements
UpdatePaymentTransactionPayoutIds(IdFilter: Text)- queries Shopify for transactions by ID and updates their payout IDsUpdatePayouts(IdFilter: Text)- queries Shopify for payouts by ID and updates their statusesImportPaymentTransactionssignature (removed var parameter)ImportPaymentTransactionto handle both new record creation and existing record updatesReport Update
SyncPayoutsprocedurePermission Set Update
Test Updates
ImportPaymentTransactionsignatureBenefits
first: 200reduces API calls when updating multiple recordsWork Item(s)
Fixes #