I\'m getting an Authorization Failed response from 2Checkout when using OmniPay API.
I had successfully hooked up Stripe with OmniPay, so then I went about hooking up 2C
The only way that I could get a transaction to go through was to set the Demo mode to "Off" manually in the sandbox settings under Account > Site Management, and then to pass in at least a billing address. I'd love to find out how to not have the billing address requirement (such as for digital download goods), but have not found a way to do so just yet, or if that's even possible.
Please note that if you set Demo Mode to "On", plus don't send a billing address, the transaction will go through okay but then it won't appear as a sale under the Sales tab. That's not very useful, because when you go live you want an actual sale that you can refund, and Demo Mode doesn't simulate an actual charge, merely an authorization of that card. (At least that's what I've figured out.)
On the transactionId
parameter, I took a shortcut for purposes here. Please make it a unique number in your system (like some number generated with UNIX time) or you could end up with a potential collision.
I also tried commenting out just the email, or just the phone, or both, and that didn't work -- you'll get "Parameter Error". Then, I tried sending in only these fields under card
: billingName
, email
, billingPostcode
, and billingCountry
-- and that failed with "Parameter Error" too. So then I added billingState
-- "Parameter Error". Then, added billingCity
-- "Parameter Error". So, in order for the transaction to go through, unless someone can show me some setting override or technique, the Billing Address is required, and must also include email and phone, to my wild surprise. That's a showstopper for some people, I'm sure, such as those trying to sell non-tangibles like digital downloads. Note also that I tried the official 2Checkout-created PHP API and tried all these tests again with that, and again, received "Parameter Error" unless the full billing address (including email and phone too) was utilized. This full billing address requirement with also email and billing phone is going to be a bummer for some businesses, I'm sure.
EDIT: This answer, if I'm guessing right, is an official answer from someone working at 2Checkout, itself? It sure does look that way. Anyway, he says that the billing address is definitely required because, as he states, "This is a requirement of our banking partners for address verification."
EDIT2: You'll need to experiment with a real live transaction, but I discovered in at least sandbox mode that, if I pass an empty string for the phoneNumber
field on the official 2Checkout PHP library, or the billingPhone
in the OmniPay API, then the transaction goes through okay. They just want to see that parameter, although it can be empty. But don't take my word for it -- test it on a live transaction (and refund yourself) to reconfirm, as I was only doing this in the sandbox. This answer seems to officially confirm from 2Checkout itself that they allow this.
Fixed code:
use Omnipay\Omnipay;
$sMerchantTransID = rand(11111111,99999999);
$oGateway = Omnipay::create('TwoCheckoutPlus_Token');
$oGateway->setPrivateKey($config->TWOCHECKOUT_PRIVATE_KEY);
$oGateway->setAccountNumber($config->TWOCHECKOUT_SELLERID);
$oGateway->setTestMode(true); // turns on Sandbox access
$oResponse = $oGateway->purchase(array(
'amount' => $sPrice,
'currency' => 'USD',
'token' => $sToken,
'transactionId' => $sMerchantTransID,
'card' => array(
'billingName' => $sName,
'billingAddress1' => $sStreet1,
'billingAddress2' => $sStreet2,
'billingCity' => $sCity,
'billingState' => $sState,
'billingPostcode' => $sZip,
'billingCountry' => $sCountry,
'email' => $sEmail,
'billingPhone' => $sPhone
)
))->send();
if (!$oResponse->isSuccessful()) {
die('ERROR: ' . $oResponse->getMessage());
}