mirror of
https://github.com/jlengrand/adyen-java-spark-online-payments.git
synced 2026-03-10 08:01:24 +00:00
@@ -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