Commit e1d83fa0 authored by Ben Anderson's avatar Ben Anderson

Switched schema to use h2SQL

parent 733e7e76
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SqlDialectMappings">
<file url="file://$PROJECT_DIR$/src/main/resources/schema.sql" dialect="GenericSQL" />
</component>
</project>
\ No newline at end of file
...@@ -27,12 +27,10 @@ dependencies { ...@@ -27,12 +27,10 @@ dependencies {
// Project Lombok deps // Project Lombok deps
compileOnly 'org.projectlombok:lombok' compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok'
// Spring Boot + Azure Cosmos DB dependencies
implementation 'com.azure.spring:azure-spring-boot-starter'
implementation 'com.azure:azure-spring-data-cosmos:3.9.0'
// H2 dependencies used for the in memory database // H2 dependencies used for the in memory database
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb-reactive' implementation 'org.springframework.boot:spring-boot-starter-data-r2dbc'
implementation 'de.flapdoodle.embed:de.flapdoodle.embed.mongo' runtimeOnly 'com.h2database:h2'
runtimeOnly 'io.r2dbc:r2dbc-h2'
// Used for testing reactive Spring Boot // Used for testing reactive Spring Boot
testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.projectreactor:reactor-test' testImplementation 'io.projectreactor:reactor-test'
......
CREATE TABLE IF NOT EXISTS authorizations_succeeded_failed
(
id
INTEGER
PRIMARY
KEY
AUTO_INCREMENT
,
card_number
VARCHAR,
cvv
VARCHAR,
address
VARCHAR,
amount
DOUBLE,
result_code
VARCHAR,
auth_code
VARCHAR,
psp_reference
VARCHAR,
avs_result
VARCHAR,
card_summary
VARCHAR,
refusal_reason_raw
VARCHAR,
eci
VARCHAR,
acquirer_account_code
VARCHAR,
expiry_date
VARCHAR,
xid
VARCHAR,
cavv_algorithm
VARCHAR,
card_bin
VARCHAR,
three_d_authenticated
VARCHAR,
cvc_result_raw
VARCHAR,
payment_method_variant
VARCHAR,
acquirer_reference
VARCHAR,
card_issuing_country
VARCHAR,
liability_shift
VARCHAR,
card_holder_name
VARCHAR,
is_card_commercial
VARCHAR,
three_d_offered
VARCHAR,
three_d_offered_response
VARCHAR,
authorisation_mid
VARCHAR,
issuer_country
VARCHAR,
cvc_result
VARCHAR,
cavv
VARCHAR,
three_d_authenticated_response
VARCHAR,
avs_result_raw
VARCHAR,
payment_method
VARCHAR,
card_payment_method
VARCHAR,
acquirer_code
VARCHAR
);
package com.nisum.paymentgatewayazuredataservice.configuration;
import io.r2dbc.spi.ConnectionFactories;
import io.r2dbc.spi.ConnectionFactory;
import org.springframework.boot.r2dbc.ConnectionFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.r2dbc.config.AbstractR2dbcConfiguration;
import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories;
@Configuration
@EnableR2dbcRepositories
class ApplicationConfig extends AbstractR2dbcConfiguration {
@Bean
public ConnectionFactory connectionFactory() {
return ConnectionFactoryBuilder
.withUrl("r2dbc:h2:mem:///test?options=DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE")
.build();
}
}
package com.nisum.paymentgatewayazuredataservice.configuration;
import com.mongodb.reactivestreams.client.MongoClient;
import com.mongodb.reactivestreams.client.MongoClients;
import org.springframework.context.annotation.Bean;
import org.springframework.data.mongodb.config.AbstractReactiveMongoConfiguration;
import org.springframework.data.mongodb.repository.config.EnableReactiveMongoRepositories;
@EnableReactiveMongoRepositories
public class ReactiveMongoConfig extends AbstractReactiveMongoConfiguration {
@Bean
public MongoClient mongoClient() {
return MongoClients.create();
}
@Override
protected String getDatabaseName() {
return "authorizations";
}
}
package com.nisum.paymentgatewayazuredataservice.domain.model; package com.nisum.paymentgatewayazuredataservice.domain.model;
import com.azure.spring.data.cosmos.core.mapping.Container;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.relational.core.mapping.Table;
@Getter @Getter
@Setter @Setter
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@Document @Table(value = "authorizations_succeeded_failed")
public class PaymentAuthData { public class PaymentAuthData {
@Id @Id
private String id; private Integer id;
private String cardNumber; private String cardNumber;
private String cvv; private String cvv;
private String address; private String address;
private Number amount; private Number amount;
private CreditCardAuthorizeResponse creditCardAuthorizeResponse; private String resultCode;
private String authCode;
private String pspReference;
private String avsResult;
private String cardSummary;
private String refusalReasonRaw;
private String eci;
private String acquirerAccountCode;
private String expiryDate;
private String xid;
private String cavvAlgorithm;
private String cardBin;
private String threeDAuthenticated;
private String cvcResultRaw;
private String paymentMethodVariant;
private String acquirerReference;
private String cardIssuingCountry;
private String liabilityShift;
private String cardHolderName;
private String isCardCommercial;
private String threeDOffered;
private String threeDOfferedResponse;
private String authorisationMid;
private String issuerCountry;
private String cvcResult;
private String cavv;
private String threeDAuthenticatedResponse;
private String avsResultRaw;
private String paymentMethod;
private String cardPaymentMethod;
private String acquirerCode;
} }
package com.nisum.paymentgatewayazuredataservice.repository; package com.nisum.paymentgatewayazuredataservice.repository;
import com.nisum.paymentgatewayazuredataservice.domain.model.PaymentAuthData; import com.nisum.paymentgatewayazuredataservice.domain.model.PaymentAuthData;
import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
import org.springframework.data.repository.reactive.ReactiveCrudRepository; import org.springframework.data.repository.reactive.ReactiveCrudRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@Repository @Repository
public interface PaymentAuthH2Repository extends ReactiveMongoRepository<PaymentAuthData, String> { public interface PaymentAuthH2Repository extends ReactiveCrudRepository<PaymentAuthData, String> {
} }
...@@ -10,23 +10,21 @@ import reactor.core.publisher.Mono; ...@@ -10,23 +10,21 @@ import reactor.core.publisher.Mono;
import java.util.UUID; import java.util.UUID;
@Service @Service
@NoArgsConstructor
public class PaymentAuthH2Service { public class PaymentAuthH2Service {
@Autowired
private PaymentAuthH2Repository repository; private PaymentAuthH2Repository repository;
@Autowired
public PaymentAuthH2Service(PaymentAuthH2Repository repository) {
this.repository = repository;
}
public Mono<PaymentAuthData> getOneById(String id) { public Mono<PaymentAuthData> getOneById(String id) {
System.out.println("GET AUTHORIZATION ");
return repository.findById(id) return repository.findById(id)
.onErrorResume(Mono::error); .onErrorResume(Mono::error);
} }
public Mono<PaymentAuthData> create(PaymentAuthData data) { public Mono<PaymentAuthData> create(PaymentAuthData data) {
data.setId(UUID.randomUUID().toString());
System.out.println(repository);
Mono<PaymentAuthData> saved = repository.save(data); Mono<PaymentAuthData> saved = repository.save(data);
System.out.println(saved);
return saved; return saved;
} }
} }
CREATE TABLE IF NOT EXISTS authorizations_succeeded_failed
(
id
INTEGER
PRIMARY
KEY
AUTO_INCREMENT
,
card_number
VARCHAR,
cvv
VARCHAR,
address
VARCHAR,
amount
DOUBLE,
result_code
VARCHAR,
auth_code
VARCHAR,
psp_reference
VARCHAR,
avs_result
VARCHAR,
card_summary
VARCHAR,
refusal_reason_raw
VARCHAR,
eci
VARCHAR,
acquirer_account_code
VARCHAR,
expiry_date
VARCHAR,
xid
VARCHAR,
cavv_algorithm
VARCHAR,
card_bin
VARCHAR,
three_d_authenticated
VARCHAR,
cvc_result_raw
VARCHAR,
payment_method_variant
VARCHAR,
acquirer_reference
VARCHAR,
card_issuing_country
VARCHAR,
liability_shift
VARCHAR,
card_holder_name
VARCHAR,
is_card_commercial
VARCHAR,
three_d_offered
VARCHAR,
three_d_offered_response
VARCHAR,
authorisation_mid
VARCHAR,
issuer_country
VARCHAR,
cvc_result
VARCHAR,
cavv
VARCHAR,
three_d_authenticated_response
VARCHAR,
avs_result_raw
VARCHAR,
payment_method
VARCHAR,
card_payment_method
VARCHAR,
acquirer_code
VARCHAR
);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment