Jump to content

Building urls help


Go to solution Solved by jazzman1,

Recommended Posts

I'm trying to make a payment gateway for my script but i`m having a problem with the output
 
The code

// redirect to the payment gateway
$desc = urlencode($days.' days extension for '.$username);
$sign = calculateWidgetSignature($params, $secret_key);

$gatewayUrl = 'http://paymentprocessor.com/gateway?';
$gatewayUrl .= 'key='.$app_key.'&';
$gatewayUrl .= 'uid='.$userId.'&';
$gatewayUrl .= 'widget='.$widget.'&';
$gatewayUrl .= 'amount='.$amount.'&';
$gatewayUrl .= 'currencyCode='.$ccode.'&';
$gatewayUrl .= 'ag_name='.$desc.'&';
$gatewayUrl .= 'ag_external_id='.$days.'&';
$gatewayUrl .= 'ag_type=fixed&';
$gatewayUrl .= 'ag_period_length='.$days.'&';
$gatewayUrl .= 'ag_period_type=day&';
$gatewayUrl .= 'ag_recurring=0&';
$gatewayUrl .= 'sign_version=2&';
$gatewayUrl .= 'sign='.$sign;

The problem is when I echo/print the $gatewayUrl I get the following
 

http ://paymentprocessor.com/gateway?key=random_string&uid=1&widget=p4_1&amount=10¤cyCode=USD&ag_name=30+days+extension+for+username&ag_external_id=30&ag_type=fixed&ag_period_length=30&ag_period_type=day&ag_recurring=0&sign_version=2&sign=random_string

 
The highlighted part in red is stopping the code from working as its meant to say "&currencyCode" not ¤cyCode

Edited by sford999
Link to comment
https://forums.phpfreaks.com/topic/276242-building-urls-help/
Share on other sites

  • Solution

Replace all "&" symbols with its a html entity name "&"

 

$gatewayUrl .= 'key='.$app_key.'&';

http://www.utexas.edu/learn/html/spchar.html

 

Are you planning to use this url in javascript?

Edited by jazzman1
Link to comment
https://forums.phpfreaks.com/topic/276242-building-urls-help/#findComment-1421532
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.