2020-05-20 05:33:58 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { addQueryArgs } from '@wordpress/url';
|
2022-01-06 12:53:30 +00:00
|
|
|
import { getSetting } from '@woocommerce/settings';
|
2020-05-20 05:33:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an in-app-purchase URL.
|
|
|
|
*
|
|
|
|
* @param {string} url
|
|
|
|
* @param {Object} queryArgs
|
|
|
|
* @return {string} url with in-app-purchase query parameters
|
|
|
|
*/
|
|
|
|
export const getInAppPurchaseUrl = ( url, queryArgs = {} ) => {
|
|
|
|
const { pathname, search } = window.location;
|
|
|
|
const connectNonce = getSetting( 'connectNonce', '' );
|
|
|
|
queryArgs = {
|
|
|
|
'wccom-site': getSetting( 'siteUrl' ),
|
|
|
|
// If the site is installed in a directory the directory must be included in the back param path.
|
|
|
|
'wccom-back': pathname + search,
|
|
|
|
'wccom-woo-version': getSetting( 'wcVersion' ),
|
|
|
|
'wccom-connect-nonce': connectNonce,
|
|
|
|
...queryArgs,
|
2020-07-28 02:32:58 +00:00
|
|
|
};
|
2020-05-20 05:33:58 +00:00
|
|
|
|
|
|
|
return addQueryArgs( url, queryArgs );
|
2020-07-28 02:32:58 +00:00
|
|
|
};
|