marlon-be / marlon-ogone Goto Github PK
View Code? Open in Web Editor NEWOgone PHP library
Home Page: http://marlon.be
License: MIT License
Ogone PHP library
Home Page: http://marlon.be
License: MIT License
I'm using this in Laravel 5.6 - is there a way to automatically submit the form and redirect to Ogone?
My code:
// Create ogone payment request
$ecommercePaymentRequest = $this->generatePaymentRequest($order);
// Return html form for Ogone
$formGenerator = new SimpleFormGenerator;
$html = $formGenerator->render($ecommercePaymentRequest);
return new Response('<h1>Pay for order</h1><p></p>' . $html);
Ive added your package to packagist.org (http://packagist.org/packages/marlon-be/marlon-ogone). If you
d like to be added as a maintainer then let me know and i`ll add you.
I needed this to get composer to work :-).
For a while I've had the trouble of EcommercePaymentResponse objects not being valid using:
if($ecommercePaymentResponse->isValid($shaComposer) && $ecommercePaymentResponse->isSuccessful())
The problem here was that the redirect url (that I get from Ogone was double encoded).
Ex.
dot was '%252E' instead of '%2E'
This resulted in the $shaString being incorrect so it wouldnt be the same as the shaSign I got with the request (and thus isValid resulting in false).
It might have been a misconfiguration of Ogone on my part but for now I fixed it by urldecoding all the values from the request before creating the EcommercePaymentResponse.
A quick fix might be to do the following:
AllParametersShaComposer.php
public function compose(array $parameters)
{
foreach($this->parameterFilters as $parameterFilter) {
$parameters = $parameterFilter->filter($parameters);
}
ksort($parameters);
// compose SHA string
$shaString = '';
foreach($parameters as $key => $value) {
$shaString .= $key . '=' . urldecode($value) . $this->passphrase;
}
return strtoupper(hash($this->hashAlgorithm, $shaString));
}
instead of
public function compose(array $parameters)
{
foreach($this->parameterFilters as $parameterFilter) {
$parameters = $parameterFilter->filter($parameters);
}
ksort($parameters);
// compose SHA string
$shaString = '';
foreach($parameters as $key => $value) {
$shaString .= $key . '=' . $value . $this->passphrase;
}
return strtoupper(hash($this->hashAlgorithm, $shaString));
}
I don't know what the implication of this "fix" are, just wanted to give you guys an update on this particular problem.
According to https://payment-services.ingenico.com/int/en/ogone/support/guides/integration%20guides/directlink, the max length authorized for OwnerAddress parameter should be 50 characters, and not 35, as set in the AbstractPaymentRequest.php line 192.
public function setOwnerAddress($owneraddress)
{
if (strlen($owneraddress) > 35) {
throw new InvalidArgumentException("Owner address is too long");
}
$this->parameters['owneraddress'] = $owneraddress;
}
Not ?
Hi,
I'm new to php, wordpress, ogone (I'm a Java guy), and I'd like to know if I can generate an e-commerce form with an alias.
I haven't found it. I guess I'll try to override ECommercePaymentRequest. I'll try not to modify the library files.
Thx in advance,
Olivier Allouch
add custom, namespaced exceptions, to allow for more granularized catching
Hi,
although PAYIDSUB has been added in #65, it's missing in ShaOutParameterFilter
which then cannot be used when checking the SHA-OUT.
I think the classloader submodule in vendor/ can be deleted. The classloader component can be required in the composer.json file.
If you want I can send a PR for this change, easy peasy :) But I'd like to hear your opinion first.
Is this extra array_walk doing anything to the values? https://github.com/marlon-be/marlon-ogone/blob/master/lib/Ogone/ParameterFilter/GeneralParameterFilter.php#L19
As far as I can tell it's not changing any of the values as the trimmed values are not saved in the original values by trim().
Note: If you decide to fix this with a proper callback so that original values get changed, be careful to only trim values which are of type "string". Trimming int/float results in string and Ogone will fail when, for example, "AMOUNT" is a string.
Something like:
public function filter(array $parameters)
{
$parameters = array_change_key_case($parameters, CASE_UPPER);
array_walk($parameters, function (&$value) {
$value = is_string($value) ? trim($value) : $value;
});
$parameters = array_filter($parameters, function ($value) {
return (bool) strlen($value);
});
return $parameters;
}
I'm trying to access the fields from the response. Is it correct I have to make sure to add this line?
$shaComposer->addParameterFilter(new ShaOutParameterFilter); //optional
If so, when I do, Im getting Class 'ShaOutParameterFilter' not found.
use PostFinance\Ecommerce\EcommercePaymentResponse;
use PostFinance\ShaComposer\AllParametersShaComposer;
are present and the rest of the payment flow works like a breeze.
Any guidance on accessing the response fields would be much appreciated or maybe an extra paragraph in the readme?
It could be cool to add support for orderdirect
Allow extra parameters "alias" and "aliasusage" to be used in the ECommercePaymentRequest to enable the Alias checkbox in the Ecommerce flow.
For now, the Alias functionality is implemented via the Ogone\DirectLink\CreateAliasRequest using the separate alias gateway endpoint at Ingenico side.
It will probably suffice to add these two fields to the $ogoneFields
array in "Ogone\AbstractRequest".
According to this documentation https://www2.payment-services.ingenico.com/fr/fr/ogone/support/guides/integration%20guides/e-commerce/transaction-feedback#SC_7_4 Ogone\PaymentResponse
is missing some statuses.
At least the 4 and 41
this field is not compulsory
The Ogone parameters are not up to date anymore. I would be happy to update them, but I wondered if there is a better place to put them. The out params for instance, are now in two different places. The ShaOutParameterFilter and AbstractResponse class.
As I understand when user pay by credit card code must be looks like:
Problem is that from documentation CARDNO, CVC and so on must be calculated in SHA: List of Parameters to be included in SHA IN Calculation
Does it just not realized functionality now or there is another way to create direct link request with CARDNO, CVC and other params?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.