-
Notifications
You must be signed in to change notification settings - Fork 78
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
"Token billing" should use cardReference to supply the tokenised card #89
Comments
Thinking about this a little more, Sage Pay has a So it could be argued that Sage Pay supports both single-use and permanent tokens. Our use of I will check whether it is possible to tokenise a credit card using AJAX, as that could open up many possibilities. I have not seen that done in this gateway API, since both Direct and Server APIs use the site's IP address as a security check (the ONLY real security check TBH, which is a little crazy, especially on shared hosting), so it is probably not possible. However, using Sage Pay Server to just capture the credit card details in an iframe as a one-off token, then creating the actual transaction server-to-server (Sage Pay Direct) is very possible, and could make a lot of sense in some use-cases. So I think I would propose using |
…they are saved or not. Documentation updated to show more clearly how this is used. Needs a bit of a tidy-up, but I'm pushing to get some eyes on it.
Trying to get some consistency between the methods available in the notify handler and the direct Response class, since there is a lot of similarities between the two.
Some additional tests will be needed for this. Sage Pay Direct can take the CC details or a token/reference, and all always be able to take the CVV. Sage Pay Server will optional take atoken/reference. This will need some further refactering when PayPal support is implemented, since that overrides both tokens and CC details.
Realised through testing that the card details are never returned in the response from Sage Pay Direct createToken or transaction requests, since the merchant site will already have these details. They are only ever returned to the Sage Pay Server notification handler.
During testing, some inconsistencies were found in the way Sage Pay generates its signatures. These changes code around those bizarre inconsistencies.
Hello, great work on this. Looking promising. I'm still getting a little confused: In order to get the request I need to do some action, eg:
but at this point I need to provide the I can provide sample code if it helps! |
Yes, that can be a little confusing, but it's due to the origins of Omnipay. The The second thing to know is that options can be set in two main ways. These are equivalent, they set the card reference the same in both cases. Just use whichever is most useful to you in the context, or mix the two. You may have all the options up front, so pass in the array. You may build them up bit-by-bit, so use the setter methods. That's a feature across all Omnipay drivers for all options: $request = $gateway->purchase();
$request->setCardReference('{abc123}'); and $request = $gateway->purchase(['cardReference => '{abc123}']); So in your particular case, you can set the $request = $gateway->purchase(['cardReference => '{abc123}', 'card' => $card, ...]); A slight variation to that, is that for Sage Pay Direct you may have to get the Does that clear things up? |
I'll update this page to explain the different ways the options can be added: |
I see,
This worked fine, so that is fantastic. I think I am going to have to clean up my code to handle whether the request is a "new card" or a "saved card" and using Is this token persistent (until deleted?) using this method:
There is mention of a cardReference/token being deleted after the purchase completed. |
This helps clarify some issues that have been raised in this discussion: thephpleague/omnipay-sagepay#89 (comment)
You don't need to do the set null stuff on the card, as all those parameters start out as null if you don't set them at all. If you pass in a Either way, you cannot get a list of tokens from the gateway, so you are 100% responsible for making sure you delete them when no longer needed (explicitly or by using as a You can explicitly tell the gateway whether to keep the card or not using the |
I would like to get this PR release ASAP, so any feedback and details of how well it runs in your application would be appreciated to help get that moving. Note that this full cardReference support is only in PR #90, from this branch: https://github.com/academe/omnipay-sagepay/tree/issue89 |
I tested your example and it is working fine, I just need to clean up my code a bit. I'm going to read over the documentation readme now and let you know if anything is confusing to me (someone who isn't literate in all the Payment Processing terminology and process flow so not sure how much it will help). At first glance under "Generating a Token or CardReference"
I couldn't find this method, should it be I will feedback with anything else. |
A typo. Thanks. One thing I am very much aware of, is that it must really be read with the Sage Pay documentation to hand. To pull in all the details that are specific to that gateway (e.g. the values that some parameters accept) would make the README extremely long. But maybe that's what it needs...? All good stuff - your feedback is valulable. Bad or unclear documentation is bad or unclear, whether you know the lingo or not. It can't tell you everything, but I hope to get it to the level where it makes sense to newbies and experienced equally, and references to external documentation where necessary. |
In the example code it shows creating a gateway in this style:
However you can also do:
Does this matter? Or is it handled by Omnipay repo and not the adapter. |
Both underscore and backslash are supported: https://github.com/thephpleague/omnipay-common/blob/master/src/Common/Helper.php#L135 I think the |
Super minor typo: |
I can confirm everything is working as expected for me. In my setup, Omnipay sits on a REST API, details are passed with the param
And then save the I have a small question regarding this, does My thought is, when in my control flow would I save the token on my end to allow reference later on, before |
I don't believe Yes, you would save the token for later use. It will remain available for later use until it is either used (without saving) or you explicitly delete it, or its expiry date is reached. It is not not a temporary token that may last for only a couple of minutes, as used on AJAX-based gateways. So you could capture the card details on Monday, and use it to take a payment on Tuesday. One thing about your REST API, if you are using Sage Pay Direct, then the CC details will be passing through your application, so be aware you need to be PCI checked. That is very important to be aware of. If using Sage Pay Server, then the PCI checks are not as rigorous, since the CC details do not do near your application. Almost nobody should be using Sage Pay Direct for transactions and creating cards. |
When you say "It will remain available for later use until it is either used (without saving) or you explicitly delete it", do I need to save the token each time I request do a request? or can the same token be used, for example:
or would this not work? The "Used - Without Saving" seems a bit confusing. |
So long as you use it as a If your second purchase used a |
Thanks for all the hard work, I will talk with my manager to make sure all PCI stuff is dealt with, I'm just integrating the interface since in the past we've always used an SDK (paypal sdk, stripe sdk, sagepay sdk...) and it becomes frustrating when trying to maintain a core ecommerce platform. Everything for my needs is working great and you have cleared up a lot of knowledge for me, I am super grateful. Right now Ive got the PR checked out on testing. Will switch back to master once you merge. |
Cool. Thanks for your help too. Much of what we have here will apply to most other Omnipay drivers. There are at least a hundred of them once you start looking. PCI be very careful about. It may be really easy to bypass it and just use a gateway that appears to work. But if caught, especially after a data breach, it can bring a company down, especially with new laws coming up. |
Minor refactoring only done with tests written first.
This got merged a while ago. |
The Token Billing page describes the ability for a gateway to store a permanent or long-term credit card in the gateway account, and reference that card using a token. The token is called
cardReference
here.This driver supports this token billing, but refers to the card token as
token
instead ofcardReference
. It needs to be switched around for consistency.Some additional discussions here:
#25
The text was updated successfully, but these errors were encountered: