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

#219 support rest jsv4 implementation #221

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Dec 12, 2018

Adds support for Rest jsv4 where the createCard object can create a reference to a billing agreement that can be rebilled when the card is not present. This is similar to the normal createCard in that a token represents the card but the card details have been validated in the Paypal popup rather than by them being passed through this code.

The process is that createCard is called and getTransactionReference then returns a token which is passed back to the paypal js script. The paypal script pops up a modal where the user authorizes the card and then the authorized token can be used like a normal cardReference from then on. Obviously the paypal js script is out of scope for Omnipay but it needs to be able to call some php function via ajax to work

I've been a bit back & forth on whether the token should be retrieved via getTransactionReference & getCardReference - also in #215 - it's the only reference that exists for the transaction prior to it being authorized & it kinda refers to the transaction about to be authorized but it also kinda makes sense as a cardReference. It's a fallback in the getTransactionReference function at the moment & could arguably be a fallback in both.

See #220

Includes #220

@eileenmcnaughton eileenmcnaughton force-pushed the master branch 7 times, most recently from e31317b to 3ed4d4d Compare December 14, 2018 00:05
@eileenmcnaughton eileenmcnaughton force-pushed the master branch 2 times, most recently from a72f643 to 2ded7ec Compare March 4, 2019 06:48
When setting up a paypal rest Authorize request there are a few possibilities

we have a payment token
we have a credit card number & cvv & expiry
we have neither of the above and should be redirected to paypal for us to log in and authorize the payment.
Currently the code understands the difference as

cardReference is present
'card' object is present
neither of the above.
However, the card object also holds other information - email, address, phone etc. Even if these are not used by Paypal Rest the calling code should not need to know that it can't set these under a specific combination of circumstances.

This fix looks more deeply into the passed card parameter for the presence of the actual card fields - ie.card number, expiry - and otherwise concludes this is not a card-present transations and allows the redirect to proceed
…ntegrations.

In a generic integration the card parameter might exist to hold billing address details even when
the card number is not provided. We don't expect the integration to hold knowledge that 'paypal rest won't work
if you pass a 'card' paramter when you are pre-authorizing a token' so we should
look more deeply into the passed card parameter for the presence of the actual card fields - ie.
card number, expiry ,cvv
…nReference.

When processing a request with no card present a token is retrieved from
paypal which is the used by a paypal browser script to open a paypal popup to approve the token.

It's a bit arguable whether this is best retrieved via getTransactionReference or
getCardReference. cardReference makes sense in that the token is used in place of a card
but it's also the only reference we have for the transaction at this point.

Related :
thephpleague#219

thephpleague#215
…sent

This scenario occurs when the pay with paypal button is clicked and authentication is done offsite
…ew paypal agreement

This submits the required paypal requests to complete the authorization of a stored token
representing a paypal authorization - ie. like creating a re-usable card
but when the card is not presented via the php layer
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

Successfully merging this pull request may close these issues.

2 participants