Skip to content

Commit

Permalink
Fix incorrect UK client id; use "UK" instead of "GB" throughout proje…
Browse files Browse the repository at this point in the history
…ct for consistency with iOS demo app; require country code query parameters
  • Loading branch information
scannillo committed Nov 6, 2019
1 parent f98eab2 commit ba317e3
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions bin/main/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ url=https://api.ppcpn.stage.paypal.com

us.client.id=${US_CLIENT_ID}
us.client.secret=${US_CLIENT_SECRET}
gb.client.id=${GB_CLIENT_ID}
gb.client.secret=${GB_CLIENT_SECRET}
uk.client.id=${UK_CLIENT_ID}
uk.client.secret=${UK_CLIENT_SECRET}
4 changes: 2 additions & 2 deletions bin/test/application-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ spring.profiles.active=test

us.client.id=test-us-client-id
us.client.secret=test-us-client-secret
gb.client.id=test-gb-client-id
gb.client.secret=test-gb-client-secret
uk.client.id=test-uk-client-id
uk.client.secret=test-uk-client-secret
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public RestController(OrdersV2Client ordersV2Client, PayPalTokenClient payPalTok
}

@PostMapping(path = "/uat")
UniversalAccessToken getUat(@RequestParam(value = "countryCode", required = false, defaultValue = "US") String countryCode) {
UniversalAccessToken getUat(@RequestParam(value = "countryCode") String countryCode) {
System.out.println("******************************");
System.out.println("REQUEST to /v1/oauth2/token:");
System.out.println("Country code: " + countryCode);
Expand All @@ -29,7 +29,7 @@ UniversalAccessToken getUat(@RequestParam(value = "countryCode", required = fals

@PostMapping(path = "/order")
Order createOrder(@RequestBody CreateOrderRequest createOrderRequest,
@RequestParam(value = "countryCode", required = false, defaultValue = "US") String countryCode) {
@RequestParam(value = "countryCode") String countryCode) {
System.out.println("******************************");
System.out.println("REQUEST to /v2/checkout/orders:");
System.out.println("Order Request body: " + createOrderRequest.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@ class TokenUtil {

private String clientIdUS;
private String clientSecretUS;
private String clientIdGB;
private String clientSecretGB;
private String clientIdUK;
private String clientSecretUK;

@Autowired
public TokenUtil(@Value("${us.client.id}") String clientIdUS,
@Value("${us.client.secret}") String clientSecretUS,
@Value("${gb.client.id}") String clientIdGB,
@Value("${gb.client.secret}") String clientSecretGB) {
@Value("${uk.client.id}") String clientIdUK,
@Value("${uk.client.secret}") String clientSecretUK) {
this.clientIdUS = clientIdUS;
this.clientSecretUS = clientSecretUS;
this.clientIdGB = clientIdGB;
this.clientSecretGB = clientSecretGB;
this.clientIdUK = clientIdUK;
this.clientSecretUK = clientSecretUK;
}

String getTokenAuthorizationHeaderForLowScope(String countryCode) {
String clientId = "GB".equalsIgnoreCase(countryCode) ? clientIdGB : clientIdUS;
String clientId = "UK".equalsIgnoreCase(countryCode) ? clientIdUK : clientIdUS;
return "Basic " + Base64.getEncoder().encodeToString(clientId.getBytes());
}

String getTokenAuthorizationHeaderForFullScope(String countryCode) {
String clientId = "GB".equalsIgnoreCase(countryCode) ? clientIdGB : clientIdUS;
String clientSecret = "GB".equalsIgnoreCase(countryCode) ? clientSecretGB : clientSecretUS;
String clientId = "UK".equalsIgnoreCase(countryCode) ? clientIdUK : clientIdUS;
String clientSecret = "UK".equalsIgnoreCase(countryCode) ? clientSecretUK : clientSecretUS;
return "Basic " + Base64.getEncoder().encodeToString((clientId + ":" + clientSecret).getBytes());
}
}
4 changes: 2 additions & 2 deletions src/main/resources/application-local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ url=https://api.ppcpn.stage.paypal.com

us.client.id=AQ8xYdJxzJwQ6k-35yu1SuZdZj_pUkGYW6eJfhUl91FXM-TVPAtL3EZPMI7XTd8tvuhKsojBETOl3lXn
us.client.secret=EOyYr4wFszBhbLpC4O-Y2m1Xud75udVbJxU0nwKf5w51i1IzWtx_2gf5VGqJyTIL4lvtZOVZDk-ezWqp
gb.client.id=EOyYr4wFszBhbLpC4O-Y2m1Xud75udVbJxU0nwKf5w51i1IzWtx_2gf5VGqJyTIL4lvtZOVZDk-ezWqp
gb.client.secret=EEHsLnZit_7AX2Qk5efOZtvz5bk75X2sZvKfT9_K3fmibFV1x3Zjki14iWPdMDwtV2Jvjrz-F17kzzvS
uk.client.id=AS0UDVPnOxJUZ2Yl4NcoxMee0EQR1h-EM2Paomzow4901huN3ZuTeT4x7Aqb7eBNxvLwHV8Ssh0beq5v
uk.client.secret=EEHsLnZit_7AX2Qk5efOZtvz5bk75X2sZvKfT9_K3fmibFV1x3Zjki14iWPdMDwtV2Jvjrz-F17kzzvS
4 changes: 2 additions & 2 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ url=https://api.ppcpn.stage.paypal.com

us.client.id=${US_CLIENT_ID}
us.client.secret=${US_CLIENT_SECRET}
gb.client.id=${GB_CLIENT_ID}
gb.client.secret=${GB_CLIENT_SECRET}
uk.client.id=${UK_CLIENT_ID}
uk.client.secret=${UK_CLIENT_SECRET}
4 changes: 2 additions & 2 deletions src/test/resources/application-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ spring.profiles.active=test

us.client.id=test-us-client-id
us.client.secret=test-us-client-secret
gb.client.id=test-gb-client-id
gb.client.secret=test-gb-client-secret
uk.client.id=test-uk-client-id
uk.client.secret=test-uk-client-secret

0 comments on commit ba317e3

Please sign in to comment.