Skip to content

Commit

Permalink
chore: remove custom url from query param (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsimhadri authored and GitHub Enterprise committed Oct 24, 2022
1 parent d5ff33e commit 215a3ea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/applepay.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { logApplePayEvent } from './logging';

async function createOrder(payload : OrderPayload) : Promise<CreateOrderResponse> {
const basicAuth = btoa(`${ getClientID() }`);
const domain = getPayPalHost('customDomain');
const domain = getPayPalHost();
const accessToken = await fetch(
`https://api.${ domain }/v1/oauth2/token`,
{
Expand Down Expand Up @@ -53,7 +53,7 @@ async function createOrder(payload : OrderPayload) : Promise<CreateOrderResponse
}

function config() : Promise<ConfigResponse | PayPalApplePayErrorType> {
const domain = getPayPalHost('customDomain');
const domain = getPayPalHost();

return fetch(
`https://www.${ domain }/graphql?GetApplepayConfig`,
Expand Down Expand Up @@ -127,7 +127,7 @@ function config() : Promise<ConfigResponse | PayPalApplePayErrorType> {

function validateMerchant({ validationUrl } : ValidateMerchantParams) : Promise<ApplePaySession | PayPalApplePayErrorType> {
logApplePayEvent('validatemerchant', { validationUrl });
const domain = getPayPalHost('customDomain');
const domain = getPayPalHost();

return fetch(
`https://www.${ domain }/graphql?GetApplePayMerchantSession`,
Expand Down Expand Up @@ -208,7 +208,7 @@ function validateMerchant({ validationUrl } : ValidateMerchantParams) : Promise<

function confirmOrder({ orderID, token, billingContact, shippingContact } : ConfirmOrderParams) : Promise<void | PayPalApplePayErrorType> {
logApplePayEvent('paymentauthorized');
const domain = getPayPalHost('customDomain');
const domain = getPayPalHost();

return fetch(
`https://www.${ domain }/graphql?ApproveApplePayPayment`,
Expand Down
6 changes: 1 addition & 5 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ export function getCurrency() : string {
return getSDKQueryParam('currency', 'USD');
}

export function getPayPalHost(customDomain : string) : any {
const params = new URLSearchParams(document.location.search);
if (params.get(customDomain)) {
return params.get(customDomain);
}
export function getPayPalHost() : any {
return getPayPalAPIDomain().split('//')[1];
}

Expand Down

0 comments on commit 215a3ea

Please sign in to comment.