Skip to content

Issue #11 Set ClientIp via the parameters form. #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
$gateway->initialize((array) $app['session']->get($sessionVar));

$params = $app['session']->get($sessionVar.'.authorize', array());
$params['clientIp'] = $app['request']->getClientIp();
$params['returnUrl'] = str_replace('/authorize', '/completeAuthorize', $app['request']->getUri());
$params['cancelUrl'] = $app['request']->getUri();
$card = new CreditCard($app['session']->get($sessionVar.'.card'));
Expand Down Expand Up @@ -95,7 +96,6 @@
$app['session']->set($sessionVar.'.card', $card);

$params['card'] = $card;
$params['clientIp'] = $app['request']->getClientIp();
$response = $gateway->authorize($params)->send();

return $app['twig']->render('response.twig', array(
Expand Down Expand Up @@ -126,6 +126,7 @@
$gateway->initialize((array) $app['session']->get($sessionVar));

$params = $app['session']->get($sessionVar.'.capture', array());
$params['clientIp'] = $app['request']->getClientIp();

return $app['twig']->render('request.twig', array(
'gateway' => $gateway,
Expand All @@ -146,7 +147,6 @@
// save POST data into session
$app['session']->set($sessionVar.'.capture', $params);

$params['clientIp'] = $app['request']->getClientIp();
$response = $gateway->capture($params)->send();

return $app['twig']->render('response.twig', array(
Expand All @@ -162,6 +162,7 @@
$gateway->initialize((array) $app['session']->get($sessionVar));

$params = $app['session']->get($sessionVar.'.purchase', array());
$params['clientIp'] = $app['request']->getClientIp();
$params['returnUrl'] = str_replace('/purchase', '/completePurchase', $app['request']->getUri());
$params['cancelUrl'] = $app['request']->getUri();
$card = new CreditCard($app['session']->get($sessionVar.'.card'));
Expand Down Expand Up @@ -189,7 +190,6 @@
$app['session']->set($sessionVar.'.card', $card);

$params['card'] = $card;
$params['clientIp'] = $app['request']->getClientIp();
$response = $gateway->purchase($params)->send();

return $app['twig']->render('response.twig', array(
Expand All @@ -208,7 +208,6 @@
// load request data from session
$params = $app['session']->get($sessionVar.'.purchase', array());

$params['clientIp'] = $app['request']->getClientIp();
$response = $gateway->completePurchase($params)->send();

return $app['twig']->render('response.twig', array(
Expand All @@ -224,6 +223,7 @@
$gateway->initialize((array) $app['session']->get($sessionVar));

$params = $app['session']->get($sessionVar.'.create', array());
$params['clientIp'] = $app['request']->getClientIp();
$card = new CreditCard($app['session']->get($sessionVar.'.card'));

return $app['twig']->render('request.twig', array(
Expand All @@ -249,7 +249,6 @@
$app['session']->set($sessionVar.'.card', $card);

$params['card'] = $card;
$params['clientIp'] = $app['request']->getClientIp();
$response = $gateway->createCard($params)->send();

return $app['twig']->render('response.twig', array(
Expand All @@ -265,6 +264,7 @@
$gateway->initialize((array) $app['session']->get($sessionVar));

$params = $app['session']->get($sessionVar.'.update', array());
$params['clientIp'] = $app['request']->getClientIp();
$card = new CreditCard($app['session']->get($sessionVar.'.card'));

return $app['twig']->render('request.twig', array(
Expand All @@ -290,7 +290,6 @@
$app['session']->set($sessionVar.'.card', $card);

$params['card'] = $card;
$params['clientIp'] = $app['request']->getClientIp();
$response = $gateway->updateCard($params)->send();

return $app['twig']->render('response.twig', array(
Expand All @@ -306,6 +305,7 @@
$gateway->initialize((array) $app['session']->get($sessionVar));

$params = $app['session']->get($sessionVar.'.delete', array());
$params['clientIp'] = $app['request']->getClientIp();

return $app['twig']->render('request.twig', array(
'gateway' => $gateway,
Expand All @@ -326,7 +326,6 @@
// save POST data into session
$app['session']->set($sessionVar.'.delete', $params);

$params['clientIp'] = $app['request']->getClientIp();
$response = $gateway->deleteCard($params)->send();

return $app['twig']->render('response.twig', array(
Expand Down
2 changes: 1 addition & 1 deletion views/request.twig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $response = $gateway->{{ method }}($params);</pre>
<p>The following parameters are available. Not all options are required by all gateways.</p>
<p><span class="label label-info">Note</span> Normally these parameters would be generated by your application and not set via form input.</p>

{% for key in ["amount", "currency", "description", "transactionId", "transactionReference", "cardReference", "returnUrl", "cancelUrl", "notifyUrl", "issuer"] %}
{% for key in ["amount", "currency", "description", "transactionId", "transactionReference", "cardReference", "returnUrl", "cancelUrl", "notifyUrl", "issuer", "clientIp"] %}

<div class="control-group">
<label class="control-label" for="params_{{key}}">{{ key }}</label>
Expand Down