-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PP-13623 Set transaction ID for Worldpay refunds on creation
For Worldpay, the gateway transaction ID (how Worldpay refers to the refund) is always the same as the external ID of the refund. Set the gateway transaction ID as soon as the refund entity is created, rather than when we process the response to the refund request to Worldpay, to avoid a possible race condition if we receive a refund notification from Worldpay immediately. To do this, introduce a RefundEntityFactory interface so the code for different payment gateways can supply one with the desired behaviour. Co-authored-by: Alex Bishop <alexbishop1@users.noreply.github.com> Co-authored-by: Hugo Jeffreys <hugo.jeffreys@digital.cabinet-office.gov.uk> Co-authored-by: Idris Abdirizak <idris.abdirizak@digital.cabinet-office.gov.uk> Co-authored-by: Marco Tranchino <marco.tranchino@digital.cabinet-office.gov.uk> Co-authored-by: Sandor Arpa <SandorArpa@users.noreply.github.com>
- Loading branch information
1 parent
6ef2a3f
commit 82ed499
Showing
20 changed files
with
225 additions
and
56 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
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
12 changes: 12 additions & 0 deletions
12
src/main/java/uk/gov/pay/connector/refund/service/DefaultRefundEntityFactory.java
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,12 @@ | ||
package uk.gov.pay.connector.refund.service; | ||
|
||
import uk.gov.pay.connector.refund.model.domain.RefundEntity; | ||
|
||
public class DefaultRefundEntityFactory implements RefundEntityFactory { | ||
|
||
@Override | ||
public RefundEntity create(long amount, String userExternalId, String refundUserEmail, String chargeExternalId) { | ||
return new RefundEntity(amount, userExternalId, refundUserEmail, chargeExternalId); | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/uk/gov/pay/connector/refund/service/RefundEntityFactory.java
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,9 @@ | ||
package uk.gov.pay.connector.refund.service; | ||
|
||
import uk.gov.pay.connector.refund.model.domain.RefundEntity; | ||
|
||
public interface RefundEntityFactory { | ||
|
||
RefundEntity create(long amount, String userExternalId, String refundUserEmail, String chargeExternalId); | ||
|
||
} |
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
15 changes: 15 additions & 0 deletions
15
src/main/java/uk/gov/pay/connector/refund/service/WorldpayRefundEntityFactory.java
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,15 @@ | ||
package uk.gov.pay.connector.refund.service; | ||
|
||
import uk.gov.pay.connector.refund.model.domain.RefundEntity; | ||
|
||
public class WorldpayRefundEntityFactory implements RefundEntityFactory { | ||
|
||
@Override | ||
public RefundEntity create(long amount, String userExternalId, String refundUserEmail, String chargeExternalId) { | ||
var refundEntity = new RefundEntity(amount, userExternalId, refundUserEmail, chargeExternalId); | ||
// We set the Worldpay’s gateway transaction ID to be the same as the refund external ID | ||
refundEntity.setGatewayTransactionId(refundEntity.getExternalId()); | ||
return refundEntity; | ||
} | ||
|
||
} |
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
Oops, something went wrong.