-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #126 from formancehq/feat/update-pi-from-payment
feat(payments): update payment initiation from payment
- Loading branch information
Showing
17 changed files
with
239 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...rnal/connectors/engine/activities/storage_payment_initiations_ids_list_from_payment_id.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package activities | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/formancehq/payments/internal/models" | ||
"go.temporal.io/sdk/workflow" | ||
) | ||
|
||
func (a Activities) StoragePaymentInitiationIDsListFromPaymentID(ctx context.Context, paymentID models.PaymentID) ([]models.PaymentInitiationID, error) { | ||
return a.storage.PaymentInitiationIDsListFromPaymentID(ctx, paymentID) | ||
} | ||
|
||
var StoragePaymentInitiationIDsListFromPaymentIDActivity = Activities{}.StoragePaymentInitiationIDsListFromPaymentID | ||
|
||
func StoragePaymentInitiationIDsListFromPaymentID(ctx workflow.Context, paymentID models.PaymentID) ([]models.PaymentInitiationID, error) { | ||
ret := []models.PaymentInitiationID{} | ||
if err := executeActivity(ctx, StoragePaymentInitiationIDsListFromPaymentIDActivity, &ret, paymentID); err != nil { | ||
return nil, err | ||
} | ||
return ret, nil | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
internal/connectors/engine/workflow/update_payment_initiation_from_payment.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package workflow | ||
|
||
import ( | ||
"github.com/formancehq/payments/internal/connectors/engine/activities" | ||
"github.com/formancehq/payments/internal/models" | ||
"go.temporal.io/sdk/workflow" | ||
) | ||
|
||
type UpdatePaymentInitiationFromPayment struct { | ||
Payment *models.Payment | ||
} | ||
|
||
func (w Workflow) runUpdatePaymentInitiationFromPayment( | ||
ctx workflow.Context, | ||
updatePaymentInitiationFromPayment UpdatePaymentInitiationFromPayment, | ||
) error { | ||
piIDs, err := activities.StoragePaymentInitiationIDsListFromPaymentID( | ||
infiniteRetryContext(ctx), | ||
updatePaymentInitiationFromPayment.Payment.ID, | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if len(piIDs) == 0 { | ||
// Nothing to do here | ||
return nil | ||
} | ||
|
||
for _, piID := range piIDs { | ||
adjustment := models.FromPaymentToPaymentInitiationAdjustment( | ||
updatePaymentInitiationFromPayment.Payment, | ||
piID, | ||
) | ||
|
||
if adjustment == nil { | ||
continue | ||
} | ||
|
||
if err := activities.StoragePaymentInitiationsAdjustmentsStore( | ||
infiniteRetryContext(ctx), | ||
*adjustment, | ||
); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
var RunUpdatePaymentInitiationFromPayment any | ||
|
||
func init() { | ||
RunUpdatePaymentInitiationFromPayment = Workflow{}.runUpdatePaymentInitiationFromPayment | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.