Skip to content

Support for Accept.js #77

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

Merged
merged 5 commits into from
Mar 3, 2017
Merged

Support for Accept.js #77

merged 5 commits into from
Mar 3, 2017

Conversation

felixmaier1989
Copy link
Contributor

Following the discussion on #41

@judgej
Copy link
Member

judgej commented Mar 2, 2017

Quick question: if the front-end form puts the tokenized card into POST data opaqueDataDescriptor and opaqueDataValue, does that mean the application does not need to handle it explicitly at the back end? Are those the field names the official SDK suggests?

I've not tried this, but if the payment fails for some other reason (e.g. invalid postcode or something) then can this tokenized card be used again (if so, how many times), or does the end user need to completely re-enter their credit card details again (a personal pain point in many stores)? I think this will effect whether the application needs to be capturing the tokenized card details or not, in the session, in case they need to be reused after a other-details validation failure.

Looks great. I'll aim to get it merged later today.

@felixmaier1989
Copy link
Contributor Author

I dont fully understand your first question. Here is the code I run in the back end:

/**
 * @var \Omnipay\AuthorizeNet\AIMGateway $gateway
 */
$gateway = Omnipay\Omnipay::create('\Omnipay\AuthorizeNet\AIMGateway');

$gateway->setApiLoginId(...);
$gateway->setTransactionKey(...);

$request = $gateway->purchase([
    'notifyUrl' => 'htts://www.perdu.com',
    'amount' => $amount,
]);

$request->setOpaqueDataDescriptor($_POST['data_descriptor']);
$request->setOpaqueDataValue($_POST['data_value']);

$response = $request->send();

if ($response->isSuccessful()) {
    // ...

}

As for the field names, I didnt check them against the SDK. Taking a look at it:

https://github.com/AuthorizeNet/sample-code-php/search?utf8=%E2%9C%93&q=opaque
https://github.com/AuthorizeNet/sdk-php/blob/9d24edc675362b6349983205b8288d178fa0c469/lib/net/authorize/api/contract/v1/OpaqueDataType.php

Seems like the relevant approach would be to handle an OpaqueDataType object made of two properties dataDescriptor and dataValue.

I dont have any strong opinion about it. Let me know what you decide, I'll change it.

@judgej
Copy link
Member

judgej commented Mar 2, 2017

The request class, used to POST data to the gateway, is looking at GET data in putting its data together. That makes an assumption about what is happening in the environment in which the request object is put together. I was just clarifying that was intentional and that I understood why it was working that way.

Actually, looking again, it should probably be removed since it uses GET and not even POST:

https://github.com/thephpleague/omnipay-authorizenet/pull/77/files#diff-3197c271405074529f9f6b7b308a0546R171

If I understand correctly, that could potentially be injected by an end user just by adding GET parameters to the merchant site credit card form POST URL, and without any input validation. Best leave full control in the merchant application like in your example.

@judgej
Copy link
Member

judgej commented Mar 2, 2017

In other words, when a payment request is created, what it contains will be affected by GET parameters in the URL of the page that constructs the payment request, and that cannot be prevented by the application without explicitly resetting those two values, which any site NOT wanting to use Accepy.JS would not be doing.

@felixmaier1989
Copy link
Contributor Author

Ok I get you. I just removed that. That originally was in Mark's snippet and I assumed this was right.

Regarding the variable naming, any thoughts?

@judgej
Copy link
Member

judgej commented Mar 2, 2017

Thanks, I think that is safer.

The variable name looks good to me. It is named very specifically for Authorize.Net, and we can provide a more generic wrapper or mapping later if and when we develop any common approach across the various gateways.

@Mark-H
Copy link
Contributor

Mark-H commented Mar 2, 2017

I was missing the setter in my code, which is why I needed to fetch it directly from the $_GET.

@Mark-H
Copy link
Contributor

Mark-H commented Mar 2, 2017

Looks like it works as expected here 👍 Just had to fix my javascript to use the right names.

:shipit:

@judgej judgej merged commit e090a13 into thephpleague:master Mar 3, 2017
@judgej
Copy link
Member

judgej commented Mar 3, 2017

All merged - thank you. If you could confirm the master branch works for you, I'll try to get a release done today. I've added a few notes to the README too - anything to add or correct, just shout PR :-)

@felixmaier1989
Copy link
Contributor Author

I tested it and it works fine for me! Let us know about the release. Thank you.

@judgej
Copy link
Member

judgej commented Mar 7, 2017

Thanks, I'll work on a release ASAP. It looks like there are a number of other PRs coming related to reporting and refunds (the transactionReference is a little messy) so it would be good to get a new baseline.

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.

3 participants