File tree Expand file tree Collapse file tree 4 files changed +44
-1
lines changed
main/java/uk/gov/pay/connector/charge/model/domain
test/java/uk/gov/pay/connector Expand file tree Collapse file tree 4 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -214,6 +214,9 @@ public class ChargeEntity extends AbstractVersionedEntity {
214214
215215 @ Column (name = "requires_3ds" )
216216 private Boolean requires3ds ;
217+
218+ @ Column (name = "gateway_rejection_reason" )
219+ private String gatewayRejectionReason ;
217220
218221 public ChargeEntity () {
219222 //for jpa
@@ -289,7 +292,11 @@ public Optional<PaymentInstrumentEntity> getPaymentInstrument() {
289292 public void setPaymentInstrument (PaymentInstrumentEntity paymentInstrument ) {
290293 this .paymentInstrument = paymentInstrument ;
291294 }
292-
295+
296+ public void setGatewayRejectionReason (String gatewayRejectionReason ) {
297+ this .gatewayRejectionReason = gatewayRejectionReason ;
298+ }
299+
293300 public Long getAmount () {
294301 return amount ;
295302 }
@@ -625,6 +632,10 @@ public Instant getUpdatedDate() {
625632 return updatedDate ;
626633 }
627634
635+ public String getGatewayRejectionReason () {
636+ return gatewayRejectionReason ;
637+ }
638+
628639 public static final class WebChargeEntityBuilder {
629640 private Long amount ;
630641 private String returnUrl ;
Original file line number Diff line number Diff line change @@ -79,6 +79,7 @@ public class ChargeEntityFixture {
7979 private Boolean requires3ds ;
8080 private ChargeResponse .AuthorisationSummary authorisationSummary ;
8181 private AgreementPaymentType agreementPaymentType ;
82+ private String gatewayRejectionReason ;
8283
8384 public static ChargeEntityFixture aValidChargeEntity () {
8485 return new ChargeEntityFixture ();
@@ -178,6 +179,7 @@ public ChargeEntity build() {
178179 chargeEntity .setExemption3dsRequested (exemption3dsRequested );
179180 chargeEntity .setPaymentInstrument (paymentInstrument );
180181 chargeEntity .setUpdatedDate (updatedDate );
182+ chargeEntity .setGatewayRejectionReason (gatewayRejectionReason );
181183
182184 if (this .auth3DsRequiredEntity != null ) {
183185 chargeEntity .set3dsRequiredDetails (auth3DsRequiredEntity );
@@ -375,6 +377,11 @@ public ChargeEntityFixture withSavePaymentInstrumentToAgreement(boolean savePaym
375377 return this ;
376378 }
377379
380+ public ChargeEntityFixture withGatewayRejectionReason (String gatewayRejectionReason ) {
381+ this .gatewayRejectionReason = gatewayRejectionReason ;
382+ return this ;
383+ }
384+
378385 public ChargeEntityFixture withPaymentInstrument (PaymentInstrumentEntity paymentInstrument ) {
379386 this .paymentInstrument = paymentInstrument ;
380387 return this ;
Original file line number Diff line number Diff line change @@ -342,6 +342,22 @@ void shouldUpdateChargeWithExemption3dsType() {
342342 assertEquals (chargeDao .findByExternalId (chargeEntity .getExternalId ()).get ().getExemption3dsRequested (), Exemption3dsType .OPTIMISED );
343343 }
344344
345+ @ Test
346+ void shouldUpdateChargeWithGatewayRejectionReason () {
347+ ChargeEntity chargeEntity = aValidChargeEntity ()
348+ .withGatewayAccountEntity (gatewayAccount )
349+ .withGatewayAccountCredentialsEntity (gatewayAccountCredentialsEntity )
350+ .build ();
351+ chargeDao .persist (chargeEntity );
352+
353+ assertNull (chargeDao .findByExternalId (chargeEntity .getExternalId ()).get ().getGatewayRejectionReason ());
354+
355+ chargeEntity .setGatewayRejectionReason ("fraudulent" );
356+ chargeDao .merge (chargeEntity );
357+
358+ assertEquals (chargeDao .findByExternalId (chargeEntity .getExternalId ()).get ().getGatewayRejectionReason (), "fraudulent" );
359+ }
360+
345361 @ Test
346362 void shouldCreateNewChargeWithParityCheckStatus () {
347363 ChargeEntity chargeEntity = aValidChargeEntity ()
Original file line number Diff line number Diff line change @@ -234,4 +234,13 @@ void shouldSetRequires3dsToTrueWhenSettingAuth3dsRequiredEntity() {
234234
235235 assertTrue (chargeEntity .getRequires3ds ());
236236 }
237+
238+ @ Test
239+ void shouldReturnGatewayRejectionReason () {
240+ ChargeEntity chargeCreated = ChargeEntityFixture
241+ .aValidChargeEntity ()
242+ .build ();
243+ chargeCreated .setGatewayRejectionReason ("fraudulent" );
244+ assertThat (chargeCreated .getGatewayRejectionReason (), is ("fraudulent" ));
245+ }
237246}
You can’t perform that action at this time.
0 commit comments