Comments (6)
I was wondering why I never saw this problem, and it is because I save the transaction before sending the registration to SagePay. Doing this will have the same effect, as saving will generate a venderTxCode, since that becomes the primary key of the stored transaction:
$server->save();
from sagepay.
I'm inclined to put $this->save() right at the start of sendRegistration()
The registration result is saved after the event anyway. I don't think it is a big overhead to save it before sending to SagePay, which will also serve as a record of what was about to happen, in case the process fails before getting a response.
That should do the trick. What do you think?
from sagepay.
I'd agree with saving it at the start of sendRegistration(), I quite like that the library handles all the saving/loading and it's not something you need to worry about. So to keep it inside would keep it that way.
from sagepay.
I agree. It gets saved anyway, so an extra save will do no harm.
If you have other places or methods you want to save the transactions to, then just extend the TransactionAbstract and add your own saving/loading method in there. That should make it easier to integrate with other systems. You could, for example, save the transaction as a document in a NoSQL database - it does not have to be relartional - or as a post type in WordPress with all the fields serialised into the body, or split up into separate metadata. The flexibility is hopefully there.
from sagepay.
Okay, done.
I remember why the save was originally left out of there: the ability to not save a failed registration was an option that could be set. This would help cut down on the number of failed registrations in storage. Note that these are failures related to invalid data (e.g. a "&" in a postcode or an address line too long, or a name too short) and not failed authorisations (those come later, after the callback). So long as the application validates the data to be submitted before attempting to submit it, then this should not be an issue.
Note that most SagePay gateways do not involve decent validation. I can break most shops using SagePay with a few choice characters in an address field. My intention is to build a validation layer into this library so that data can be checked before it is posted to SagePay. The metadata defining the validation rules is already there, but it is not used yet.
I'm rambling! Shut up Jason :-)
from sagepay.
Actually, I've just realised you are working on validation already. It looks great. Check out the rules in https://github.com/academe/SagePay/blob/master/src/Academe/SagePay/Metadata/Transaction.php as all the fields have very strict validation rules, especially wrt what characters are allowed in them. The rules are defined in "SagePay speak" so will need some simple transaction to regexes and other more standard rules. It is annoying having fields like postcode being mandatory for some countries that don't have postcodes, for example Northern Ireland, for SagePay v2.x at least. And then when the user enters "N/A" the transaction gets rejected with "bad data" because of the "/" in the postcode.
The fact that SagePay will stop dead at the first error it finds, makes so much more important to validate at the application. We may also be able to do some simple transforms to avoid bugging the user (especially if there are multiple payment gateways, all with different validation needs). For example, silently strip out invalid characters in postcodes, truncate address lines that are too long.
Note also that most of the fields are sent to SagePay as single-byte ISO characters, so lengths are in characters or bytes after conversion from UTF-8, which is the assumed application characterset. However, some of the newer XML-based fields may be able to accept UTF-8, but I have not played with them much.
from sagepay.
Related Issues (20)
- Create Omnipay Wrapper
- Make sure typehints are interfaces, not abstracts
- Token field may not be send in server-notification HOT 4
- Helper::formatAmount silently sets Amount to Zero HOT 9
- Fields for Refund not picked out HOT 6
- Switch to PSR-4 autoloading HOT 1
- Surcharge XML is too long HOT 9
- Start using constructor injection
- Use Data Mapper model rather than up-side-down Active Record HOT 1
- possible misleading information on comment section HOT 10
- Support discounts in basket HOT 17
- Sagepay callback function is not taking sagepay tx_model HOT 2
- Passing correct customer data to Sage Pay HOT 9
- Create Omnipay connector
- Is VPSSignature utilised? HOT 4
- VendorTxCode not guaranteed to be unique or unpredictable HOT 3
- MD5 signature - change from Pending to OK for PPRO payments HOT 3
- Handle duplicate notification callbacks HOT 2
- Second CardType does not contain tamper: true HOT 1
- Support 3d Secure v2 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sagepay.