function paymentUrl(organisation, offerId, sourceId, sourceIdType) {
  const matchSourceId = _get(organisation, 'payment.source_id_type') == sourceIdType;
  const hasPaymentSourceId = _has(organisation, 'payment.source_id_type');
  const hasPaymentUrl = _has(organisation, 'payment.url');
  const includePayment = hasPaymentUrl && (matchSourceId || !hasPaymentSourceId);

  if (!includePayment) { return; }

  let paymentUrl = organisation.payment.url.replace(/{offer_id}/g, offerId);
  if (matchSourceId) {
    paymentUrl = paymentUrl.replace(/{source_id}/g, sourceId);
  }

  return paymentUrl;
}
/**
 * Get the payment URL and replace placeholders with the source & offer IDs
 */
Get the payment URL and replace placeholders with the source & offer IDs
Get the payment URL and replace placeholders with the source & offer IDs
function paymentUrl(organisation, offerId, sourceId, sourceIdType) {
  const matchSourceId = _get(organisation, 'payment.source_id_type') == sourceIdType;
  const hasPaymentSourceId = _has(organisation, 'payment.source_id_type');
  const hasPaymentUrl = _has(organisation, 'payment.url');
  const includePayment = hasPaymentUrl && (matchSourceId || !hasPaymentSourceId);
  if (!includePayment) { return; }
  let paymentUrl = organisation.payment.url.replace(/{offer_id}/g, offerId);
  if (matchSourceId) {
    paymentUrl = paymentUrl.replace(/{source_id}/g, sourceId);
  }
  return paymentUrl;
}
function paymentUrl ( organisation , offerId , sourceId , sourceIdType ) { const matchSourceId = _get ( organisation , 'payment.source_id_type' ) == sourceIdType ; const hasPaymentSourceId = _has ( organisation , 'payment.source_id_type' ) ; const hasPaymentUrl = _has ( organisation , 'payment.url' ) ; const includePayment = hasPaymentUrl && ( matchSourceId || ! hasPaymentSourceId ) ; if ( ! includePayment ) { return ; } let paymentUrl = organisation . payment . url . replace ( / {offer_id} / g , offerId ) ; if ( matchSourceId ) { paymentUrl = paymentUrl . replace ( / {source_id} / g , sourceId ) ; } return paymentUrl ; }
Get the payment URL and replace placeholders with the source & offer IDs
Get the payment URL and replace placeholders with the source & offer IDs