mirror of
https://github.com/jlengrand/adyen-java-spark-online-payments.git
synced 2026-03-09 23:51:20 +00:00
Set redirectUrl using hostname #16
Set redirectUrl using hostname #16 Closes #16
This commit is contained in:
@@ -22,11 +22,11 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.sparkjava:spark-core:2.9.1'
|
||||
implementation 'org.slf4j:slf4j-simple:1.7.25'
|
||||
implementation 'com.sparkjava:spark-core:2.9.3'
|
||||
implementation 'org.slf4j:slf4j-simple:1.7.36'
|
||||
implementation 'com.sparkjava:spark-template-jinjava:2.7.1'
|
||||
implementation 'org.apache.httpcomponents:httpclient:4.5.11'
|
||||
implementation 'com.adyen:adyen-java-api-library:17.2.0'
|
||||
implementation 'org.apache.httpcomponents:httpclient:4.5.13'
|
||||
implementation 'com.adyen:adyen-java-api-library:17.4.0'
|
||||
}
|
||||
|
||||
jar {
|
||||
|
||||
@@ -87,7 +87,7 @@ public class Application {
|
||||
});
|
||||
|
||||
post("/api/sessions", (req, res) -> {
|
||||
CreateCheckoutSessionResponse response = checkoutService.checkoutsessions();
|
||||
CreateCheckoutSessionResponse response = checkoutService.checkoutsessions(req);
|
||||
return gson.toJson(response);
|
||||
});
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.adyen.model.checkout.CreateCheckoutSessionRequest;
|
||||
import com.adyen.model.checkout.CreateCheckoutSessionResponse;
|
||||
import com.adyen.service.Checkout;
|
||||
import com.adyen.service.exception.ApiException;
|
||||
import spark.Request;
|
||||
|
||||
public class CheckoutService {
|
||||
|
||||
@@ -21,7 +22,7 @@ public class CheckoutService {
|
||||
checkout = new Checkout(new Client(prop.getProperty("apiKey"), Environment.TEST));
|
||||
}
|
||||
|
||||
public CreateCheckoutSessionResponse checkoutsessions() throws IOException, ApiException {
|
||||
public CreateCheckoutSessionResponse checkoutsessions(Request req) throws IOException, ApiException {
|
||||
String orderRef = UUID.randomUUID().toString();
|
||||
Amount amount = new Amount()
|
||||
.currency("EUR")
|
||||
@@ -30,7 +31,7 @@ public class CheckoutService {
|
||||
checkoutSession.merchantAccount(merchantAccount);
|
||||
checkoutSession.setChannel(CreateCheckoutSessionRequest.ChannelEnum.WEB);
|
||||
checkoutSession.setReference(orderRef); // Typically generated by customer CMS
|
||||
checkoutSession.setReturnUrl("http://localhost:8080/redirect?orderRef=" + orderRef);
|
||||
checkoutSession.setReturnUrl(req.scheme() + "://" + req.host() + "/redirect?orderRef=" + orderRef);
|
||||
checkoutSession.setAmount(amount);
|
||||
return checkout.sessions(checkoutSession);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user