Skip to content

Commit

Permalink
Merge pull request #19 from adyen-examples/fix-return-url
Browse files Browse the repository at this point in the history
Fix return url provided to Hosted Onboarding app
  • Loading branch information
gcatanese authored Dec 1, 2023
2 parents b87c655 + 2b79323 commit aeab941
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
4 changes: 3 additions & 1 deletion react-app/src/dashboard/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export default function Dashboard() {
}, []);

const generateOnboardingLink = () => {
axios.post('/api/dashboard/getOnboardingLink')
axios.post('/api/dashboard/getOnboardingLink', {
host: window.location.origin
})
.then((response) => {
window.location.href = response.data;
})
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/adyen/controller/DashboardController.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.adyen.controller;

import com.adyen.model.OnboardingLinkProperties;
import com.adyen.model.User;
import com.adyen.model.balanceplatform.AccountHolder;
import com.adyen.model.legalentitymanagement.LegalEntity;
import com.adyen.model.legalentitymanagement.OnboardingLink;
import com.adyen.service.ConfigurationAPIService;
import com.adyen.service.LegalEntityManagementAPIService;
import com.adyen.util.LegalEntityHandler;
import jakarta.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -62,7 +62,7 @@ ResponseEntity<User> getUser() {
}

@PostMapping("/getOnboardingLink")
ResponseEntity<String> getOnboardingLink(HttpServletRequest request) {
ResponseEntity<String> getOnboardingLink(@RequestBody OnboardingLinkProperties onboardingLinkProperties) {

String legalEntityId;

Expand All @@ -72,7 +72,7 @@ ResponseEntity<String> getOnboardingLink(HttpServletRequest request) {
}

// get host (used to generate the returnUrl)
String host = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort();
String host = onboardingLinkProperties.getHost();

Optional<AccountHolder> accountHolder = getConfigurationAPIService().getAccountHolder(getUserIdOnSession());

Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/adyen/model/OnboardingLinkProperties.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.adyen.model;

public class OnboardingLinkProperties {

private String host;

public String getHost() {
return host;
}

public void setHost(String host) {
this.host = host;
}
}

0 comments on commit aeab941

Please sign in to comment.