Skip to content
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

Post Input Name Value #17

Open
OllyAlpha opened this issue Apr 26, 2016 · 6 comments
Open

Post Input Name Value #17

OllyAlpha opened this issue Apr 26, 2016 · 6 comments

Comments

@OllyAlpha
Copy link

Hi Timur,
Hoping you can help. I'm using your simple Sage Pay form which is awesome but unfortunaltely i'm having an issue posting the input/name value to Sage Pay.

If i set the value as you have done in your example:
$sagePay->setCurrency('EUR');
$sagePay->setAmount('100');
$sagePay->setDescription('Lorem ipsum');
$sagePay->setBillingSurname('Mustermann');
etc
all works well and it goes to sage pay with no errors.

but

Is there a way of having the value of the input field post to Sage Pay so it's dynamic?
For example: $sagePay->setAmount($_POST['Amount']); $sagePay->setDescription($_POST['Description']);
$sagePay->setBillingFirstnames($_POST['BillingFirstnames']); $sagePay->setBillingSurname($_POST['BillingSurname']);

Would really appreciate any help on this...?

@tolzhabayev
Copy link
Owner

Hey,

of course you can, dont see why not? Maybe show me more code so i can see whats the problem you are having?

@OllyAlpha
Copy link
Author

OllyAlpha commented Apr 27, 2016

Hey Timur,

I thought it might be but haven't managed to get it working yet. I've added an example of the form that i'm using but you can see the idea that i'm going for.


<form method="post" action="https://test.sagepay.com/gateway/service/vspform-register.vsp" id="sagepay" data-abide novalidate>
 <label for="fname">First Name
<input type="text" id="fname" onfocusout="updater();" name="BillingFirstnames" placeholder="First Name" required>
 </label>
<label for="lname">Surname
<input type="text" id="lname" onfocusout="updater();" name="BillingSurname" placeholder="Surname" required>
</label>
<label for="email">Email
<input type="email" id="email" pattern="email" onfocusout="updater();" name="CustomerEMail" placeholder="Email" required>
</label>
etc etc
</form>
<?php                                                                                                                                                
require_once('slib/SagePay.php');                                                   
$sagePay = new SagePay();
$sagePay->setCurrency('GBP');
$sagePay->setAmount($_POST['Amount']);
$sagePay->setDescription($_POST['Description']);
$sagePay->setBillingFirstnames($_POST['BillingFirstnames']);
$sagePay->setBillingSurname($_POST['BillingSurname']);
$sagePay->setCustomerEMail($_POST['CustomerEMail']);
$sagePay->setBillingPhone($_POST['BillingPhone']);
$sagePay->setDeliveryPhone($_POST['DeliveryPhone']);
$sagePay->setBillingAddress1($_POST['BillingAddress1']);
$sagePay->setBillingAddress2($_POST['BillingAddress2']);
$sagePay->setBillingCity($_POST['BillingCity']);
$sagePay->setBillingCountry('GB');
$sagePay->setBillingPostCode($_POST['BillingPostCode']);
$sagePay->setDeliveryFirstnames($_POST['DeliveryFirstnames']);
$sagePay->setDeliverySurname($_POST['DeliverySurname']);
$sagePay->setDeliveryAddress1($_POST['DeliveryAddress1']);
$sagePay->setDeliveryAddress2($_POST['DeliveryAddress2']);
$sagePay->setDeliveryCity($_POST['DeliveryCity']);
$sagePay->setDeliveryCountry('GB');
$sagePay->setDeliveryPostCode($_POST['DeliveryPostCode']);
$sagePay->setSuccessURL('http://www.vendorname.co.uk/success.php');
$sagePay->setFailureURL('http://www.vendorname.co.uk/fail.php');
?>

<input type="hidden" name="VPSProtocol" value="3.00">
<input type="hidden" name="TxType" value="AUTHENTICATE">
<input type="hidden" name="Vendor" value="vendorname">
<input type="hidden" name="Crypt" value= "<?php echo $sagePay->getCrypt(); ?>">

@tolzhabayev
Copy link
Owner

Looks fine to me, and below this code you should do:


<form method="POST" id="SagePayForm" action="*https://test.sagepay.com/gateway/service/vspform-register.vsp*">
    <input type="hidden" name="VPSProtocol" value= "3.00">
    <input type="hidden" name="TxType" value= "PAYMENT">
    <input type="hidden" name="Vendor" value= "*YOURVERNODID*">
    <input type="hidden" name="Crypt" value= "<?php echo $sagePay->getCrypt(); ?>">
    <input type="submit" value="continue to SagePay">
</form>

@OllyAlpha
Copy link
Author

Thats what I thought. Let me give it another whirl and see if I can get it going. Will keep you posted.

Thanks for taking a look.

@brianrevie
Copy link

Hey OllyAlpha, did you get this working?
I have been trying for 2 days to get it working like this but it just wont pull the values from the $_POST inputs and add them?

I can only get it working if I hard code the values into the following like this:
$sagePay->setAmount('100');
instead of this:
$sagePay->setAmount($_POST['Amount']);

@tolzhabayev
Copy link
Owner

tolzhabayev commented Aug 26, 2021

I can only get it working if I hard code the values into the following like this:
$sagePay->setAmount('100');
instead of this:
$sagePay->setAmount($_POST['Amount']);

try debugging / printing the value of $_POST['Amount'] before you use it. It might be emtpy. Check case sensitivity, etc.

I would also recommend considering this library which is more up to date: https://github.com/thephpleague/omnipay-sagepay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants