thephpleague / omnipay-authorizenet

Authorize.Net driver for the Omnipay payment processing library
MIT License
57 stars 92 forks source link

Add customer info to transaction. #115

Closed jsgv closed 5 years ago

jsgv commented 6 years ago

How can I add customer info while using the Accept.js gateway?

I am currently using the Accept.dispatchData method on the Accept.js library to create the opaque data values.

And in the backend I use the values.

$response = $gateway->purchase([
    'amount' => $amount,
    'opaqueDataDescriptor' => $request->input('dataDescriptor'),
    'opaqueDataValue' => $request->input('dataValue')
])->send();

How can I add customer info to the transaction?

I see the addBillingData method on the AIMAbstractRequest class, but I am not passing any customer info via Accept.js.

I am using version 2.6.

jsgv commented 5 years ago

I realized that you can add customer name via Accept.js.

var secureData = {
    cardData: {
        // ...
        fullName: fullName
    }
};
Accept.dispatchData(secureData, function(){});

But I am still unable to set customer email address. How can I set the customer email address?

judgej commented 5 years ago

You would normally set the email of the customer through the CreditCard object:

$creditCard = new \Omnipay\Common\CreditCard([
    'email' => 'foo@example.com',
]);

$response = $gateway->purchase([
    'amount' => $amount,
    'opaqueDataDescriptor' => $request->input('dataDescriptor'),
    'opaqueDataValue' => $request->input('dataValue'),
    'card' => $creditCard,
])->send();

Some more details here:

https://omnipay.thephpleague.com/api/cards/

jsgv commented 5 years ago

Thanks @judgej ! Yes, I do understand how to do it with a regular card purchase.

But for my case I am using Accept.js in the front end to create a token and then using the token to finalize the purchase. Not sure in which step the email address can be added. Authorize.net's documentation on their website isn't very helpful.

judgej commented 5 years ago

It's exactly as shown: when you submit the purchase details to the gateway. You can collect those details however you like - in the original form with the Accept form, from the back-end user account, from an additional form in the process. But it's for you to do, not the Accept.JS front end. That only concerns itself with what it needs to tokenise a card.

judgej commented 5 years ago

@jsgv Did this thread answer your question? Do we need further examples in the main README so this issue can be closed?

jsgv commented 5 years ago

@judgej Yes, example above was more than enough. Thank you.