mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 17:24:36 -04:00
Fixes for eWay
This commit is contained in:
parent
90198e6b7a
commit
8db20c1fca
@ -22,6 +22,7 @@ use App\Models\PaymentHash;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\EwayPaymentDriver;
|
||||
use App\PaymentDrivers\Eway\ErrorCode;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Str;
|
||||
@ -120,8 +121,8 @@ class CreditCard
|
||||
$transaction = [
|
||||
'Reference' => $this->eway_driver->client->number,
|
||||
'Title' => '',
|
||||
'FirstName' => $this->eway_driver->client->primary_contact()->present()->last_name(),
|
||||
'LastName' => $this->eway_driver->client->primary_contact()->present()->first_name(),
|
||||
'FirstName' => $this->eway_driver->client->contacts()->first()->present()->last_name(),
|
||||
'LastName' => $this->eway_driver->client->contacts()->first()->present()->first_name(),
|
||||
'CompanyName' => $this->eway_driver->client->name,
|
||||
'Street1' => $this->eway_driver->client->address1,
|
||||
'Street2' => $this->eway_driver->client->address2,
|
||||
@ -130,30 +131,33 @@ class CreditCard
|
||||
'PostalCode' => $this->eway_driver->client->postal_code,
|
||||
'Country' => $this->eway_driver->client->country->iso_3166_2,
|
||||
'Phone' => $this->eway_driver->client->phone,
|
||||
'Email' => $this->eway_driver->client->primary_contact()->email,
|
||||
'Email' => $this->eway_driver->client->contacts()->first()->email,
|
||||
"Url" => $this->eway_driver->client->website,
|
||||
'Payment' => [
|
||||
'TotalAmount' => 0,
|
||||
],
|
||||
'TransactionType' => \Eway\Rapid\Enum\TransactionType::PURCHASE,
|
||||
// 'Payment' => [
|
||||
// 'TotalAmount' => 0,
|
||||
// ],
|
||||
// 'TransactionType' => \Eway\Rapid\Enum\TransactionType::PURCHASE,
|
||||
'Method' => \Eway\Rapid\Enum\PaymentMethod::CREATE_TOKEN_CUSTOMER,
|
||||
'SecuredCardData' => $request->input('SecuredCardData'),
|
||||
];
|
||||
|
||||
$response = $this->eway_driver->init()->eway->createCustomer(\Eway\Rapid\Enum\ApiMethod::DIRECT, $transaction);
|
||||
|
||||
nlog($response);
|
||||
$response_status = ErrorCode::getStatus($response->ResponseMessage);
|
||||
|
||||
if(!$response_status['success'])
|
||||
throw new PaymentFailed($response_status['message'], 400);
|
||||
|
||||
//success
|
||||
$cgt = [];
|
||||
$cgt['token'] = $data['token'];
|
||||
$cgt['token'] = $response->Customer->TokenCustomerID;
|
||||
$cgt['payment_method_id'] = GatewayType::CREDIT_CARD;
|
||||
|
||||
$payment_meta = new \stdClass;
|
||||
$payment_meta->exp_month = 'xx';
|
||||
$payment_meta->exp_year = 'xx';
|
||||
$payment_meta->exp_month = $response->Customer->CardDetails->ExpiryMonth;
|
||||
$payment_meta->exp_year = $response->Customer->CardDetails->ExpiryYear;
|
||||
$payment_meta->brand = 'CC';
|
||||
$payment_meta->last4 = 'xxxx';
|
||||
$payment_meta->last4 = $response->Customer->CardDetails->Number;
|
||||
$payment_meta->type = GatewayType::CREDIT_CARD;
|
||||
|
||||
$cgt['payment_meta'] = $payment_meta;
|
||||
|
@ -15,80 +15,91 @@ namespace App\PaymentDrivers\Eway;
|
||||
class ErrorCode
|
||||
{
|
||||
|
||||
public $success = [
|
||||
["A2000" => "Transaction Approved"],
|
||||
["A2008" => "Honour With Identification"],
|
||||
["A2010" => "Approved For Partial Amount"],
|
||||
["A2011" => "Approved, VIP"],
|
||||
["A2016" => "Approved, Update Track 3"],
|
||||
],
|
||||
|
||||
public $failure = [
|
||||
["D4401" => "Refer to Issuer"],
|
||||
["D4402" => "Refer to Issuer, special"],
|
||||
["D4403" => "No Merchant"],
|
||||
["D4404" => "Pick Up Card"],
|
||||
["D4405" => "Do Not Honour"],
|
||||
["D4406" => "Error"],
|
||||
["D4407" => "Pick Up Card, Special"],
|
||||
["D4409" => "Request In Progress"],
|
||||
["D4412" => "Invalid Transaction"],
|
||||
["D4413" => "Invalid Amount"],
|
||||
["D4414" => "Invalid Card Number"],
|
||||
["D4415" => "No Issuer"],
|
||||
["D4417" => "3D Secure Error"],
|
||||
["D4419" => "Re-enter Last Transaction"],
|
||||
["D4421" => "No Action Taken"],
|
||||
["D4422" => "Suspected Malfunction"],
|
||||
["D4423" => "Unacceptable Transaction Fee"],
|
||||
["D4425" => "Unable to Locate Record On File"],
|
||||
["D4430" => "Format Error"],
|
||||
["D4431" => "Bank Not Supported By Switch"],
|
||||
["D4433" => "Expired Card, Capture"],
|
||||
["D4434" => "Suspected Fraud, Retain Card"],
|
||||
["D4435" => "Card Acceptor, Contact Acquirer, Retain Card"],
|
||||
["D4436" => "Restricted Card, Retain Card"],
|
||||
["D4437" => "Contact Acquirer Security Department, Retain Card"],
|
||||
["D4438" => "PIN Tries Exceeded, Capture"],
|
||||
["D4439" => "No Credit Account"],
|
||||
["D4440" => "Function Not Supported"],
|
||||
["D4441" => "Lost Card"],
|
||||
["D4442" => "No Universal Account"],
|
||||
["D4443" => "Stolen Card"],
|
||||
["D4444" => "No Investment Account"],
|
||||
["D4450" => "Click-to-Pay (Visa Checkout) Transaction"],
|
||||
["D4451" => "Insufficient Funds"],
|
||||
["D4452" => "No Cheque Account"],
|
||||
["D4453" => "No Savings Account"],
|
||||
["D4454" => "Expired Card"],
|
||||
["D4455" => "Incorrect PIN"],
|
||||
["D4456" => "No Card Record"],
|
||||
["D4457" => "Function Not Permitted to Cardholder"],
|
||||
["D4458" => "Function Not Permitted to Terminal"],
|
||||
["D4459" => "Suspected Fraud"],
|
||||
["D4460" => "Acceptor Contact Acquirer"],
|
||||
["D4461" => "Exceeds Withdrawal Limit"],
|
||||
["D4462" => "Restricted Card"],
|
||||
["D4463" => "Security Violation"],
|
||||
["D4464" => "Original Amount Incorrect"],
|
||||
["D4466" => "Acceptor Contact Acquirer, Security"],
|
||||
["D4467" => "Capture Card"],
|
||||
["D4475" => "PIN Tries Exceeded"],
|
||||
["D4476" => "Invalidate Txn Reference"],
|
||||
["D4481" => "Accumulated Transaction Counter (Amount) Exceeded"],
|
||||
["D4482" => "CVV Validation Error"],
|
||||
["D4483" => "Acquirer Is Not Accepting Transactions From You At This Time"],
|
||||
["D4484" => "Acquirer Is Not Accepting This Transaction"],
|
||||
["D4490" => "Cut off In Progress"],
|
||||
["D4491" => "Card Issuer Unavailable"],
|
||||
["D4492" => "Unable To Route Transaction"],
|
||||
["D4493" => "Cannot Complete, Violation Of The Law"],
|
||||
["D4494" => "Duplicate Transaction"],
|
||||
["D4495" => "Amex Declined"],
|
||||
["D4496" => "System Error"],
|
||||
["D4497" => "MasterPass Error"],
|
||||
["D4498" => "PayPal Create Transaction Error"],
|
||||
["D4499" => "Invalid Transaction for Auth/Void"],
|
||||
private static $success = [
|
||||
"A2000" => "Transaction Approved",
|
||||
"A2008" => "Honour With Identification",
|
||||
"A2010" => "Approved For Partial Amount",
|
||||
"A2011" => "Approved, VIP",
|
||||
"A2016" => "Approved, Update Track 3",
|
||||
];
|
||||
|
||||
private static $failure = [
|
||||
"D4401" => "Refer to Issuer",
|
||||
"D4402" => "Refer to Issuer, special",
|
||||
"D4403" => "No Merchant",
|
||||
"D4404" => "Pick Up Card",
|
||||
"D4405" => "Do Not Honour",
|
||||
"D4406" => "Error",
|
||||
"D4407" => "Pick Up Card, Special",
|
||||
"D4409" => "Request In Progress",
|
||||
"D4412" => "Invalid Transaction",
|
||||
"D4413" => "Invalid Amount",
|
||||
"D4414" => "Invalid Card Number",
|
||||
"D4415" => "No Issuer",
|
||||
"D4417" => "3D Secure Error",
|
||||
"D4419" => "Re-enter Last Transaction",
|
||||
"D4421" => "No Action Taken",
|
||||
"D4422" => "Suspected Malfunction",
|
||||
"D4423" => "Unacceptable Transaction Fee",
|
||||
"D4425" => "Unable to Locate Record On File",
|
||||
"D4430" => "Format Error",
|
||||
"D4431" => "Bank Not Supported By Switch",
|
||||
"D4433" => "Expired Card, Capture",
|
||||
"D4434" => "Suspected Fraud, Retain Card",
|
||||
"D4435" => "Card Acceptor, Contact Acquirer, Retain Card",
|
||||
"D4436" => "Restricted Card, Retain Card",
|
||||
"D4437" => "Contact Acquirer Security Department, Retain Card",
|
||||
"D4438" => "PIN Tries Exceeded, Capture",
|
||||
"D4439" => "No Credit Account",
|
||||
"D4440" => "Function Not Supported",
|
||||
"D4441" => "Lost Card",
|
||||
"D4442" => "No Universal Account",
|
||||
"D4443" => "Stolen Card",
|
||||
"D4444" => "No Investment Account",
|
||||
"D4450" => "Click-to-Pay (Visa Checkout) Transaction",
|
||||
"D4451" => "Insufficient Funds",
|
||||
"D4452" => "No Cheque Account",
|
||||
"D4453" => "No Savings Account",
|
||||
"D4454" => "Expired Card",
|
||||
"D4455" => "Incorrect PIN",
|
||||
"D4456" => "No Card Record",
|
||||
"D4457" => "Function Not Permitted to Cardholder",
|
||||
"D4458" => "Function Not Permitted to Terminal",
|
||||
"D4459" => "Suspected Fraud",
|
||||
"D4460" => "Acceptor Contact Acquirer",
|
||||
"D4461" => "Exceeds Withdrawal Limit",
|
||||
"D4462" => "Restricted Card",
|
||||
"D4463" => "Security Violation",
|
||||
"D4464" => "Original Amount Incorrect",
|
||||
"D4466" => "Acceptor Contact Acquirer, Security",
|
||||
"D4467" => "Capture Card",
|
||||
"D4475" => "PIN Tries Exceeded",
|
||||
"D4476" => "Invalidate Txn Reference",
|
||||
"D4481" => "Accumulated Transaction Counter (Amount) Exceeded",
|
||||
"D4482" => "CVV Validation Error",
|
||||
"D4483" => "Acquirer Is Not Accepting Transactions From You At This Time",
|
||||
"D4484" => "Acquirer Is Not Accepting This Transaction",
|
||||
"D4490" => "Cut off In Progress",
|
||||
"D4491" => "Card Issuer Unavailable",
|
||||
"D4492" => "Unable To Route Transaction",
|
||||
"D4493" => "Cannot Complete, Violation Of The Law",
|
||||
"D4494" => "Duplicate Transaction",
|
||||
"D4495" => "Amex Declined",
|
||||
"D4496" => "System Error",
|
||||
"D4497" => "MasterPass Error",
|
||||
"D4498" => "PayPal Create Transaction Error",
|
||||
"D4499" => "Invalid Transaction for Auth/Void",
|
||||
];
|
||||
|
||||
|
||||
public static function getStatus($code)
|
||||
{
|
||||
if(array_key_exists($code, self::$success))
|
||||
return ['success' => true, 'message' => self::$success[$code]];
|
||||
|
||||
if(array_key_exists($code, self::$failure))
|
||||
return ['success' => false, 'message' => self::$failure[$code]];
|
||||
|
||||
return ['success' => false, 'message' => "Unknown error message code - {$code}"];
|
||||
}
|
||||
}
|
@ -101,4 +101,47 @@ class EwayPaymentDriver extends BaseDriver
|
||||
public function processWebhookRequest(PaymentWebhookRequest $request, Payment $payment = null)
|
||||
{
|
||||
}
|
||||
|
||||
public function getClientRequiredFields(): array
|
||||
{
|
||||
$fields = [];
|
||||
$fields[] = ['name' => 'contact_first_name', 'label' => ctrans('texts.first_name'), 'type' => 'text', 'validation' => 'required'];
|
||||
$fields[] = ['name' => 'contact_last_name', 'label' => ctrans('texts.last_name'), 'type' => 'text', 'validation' => 'required'];
|
||||
$fields[] = ['name' => 'contact_email', 'label' => ctrans('texts.email'), 'type' => 'text', 'validation' => 'required,email:rfc'];
|
||||
$fields[] = ['name' => 'client_country_id', 'label' => ctrans('texts.country'), 'type' => 'text', 'validation' => 'required'];
|
||||
|
||||
if ($this->company_gateway->require_client_name) {
|
||||
$fields[] = ['name' => 'client_name', 'label' => ctrans('texts.client_name'), 'type' => 'text', 'validation' => 'required'];
|
||||
}
|
||||
|
||||
// if ($this->company_gateway->require_contact_name) {
|
||||
// }
|
||||
|
||||
// if ($this->company_gateway->require_contact_email) {
|
||||
// }
|
||||
|
||||
if ($this->company_gateway->require_client_phone) {
|
||||
$fields[] = ['name' => 'client_phone', 'label' => ctrans('texts.client_phone'), 'type' => 'tel', 'validation' => 'required'];
|
||||
}
|
||||
|
||||
if ($this->company_gateway->require_billing_address) {
|
||||
$fields[] = ['name' => 'client_address_line_1', 'label' => ctrans('texts.address1'), 'type' => 'text', 'validation' => 'required'];
|
||||
$fields[] = ['name' => 'client_city', 'label' => ctrans('texts.city'), 'type' => 'text', 'validation' => 'required'];
|
||||
$fields[] = ['name' => 'client_state', 'label' => ctrans('texts.state'), 'type' => 'text', 'validation' => 'required'];
|
||||
}
|
||||
|
||||
if($this->company_gateway->require_postal_code)
|
||||
$fields[] = ['name' => 'client_postal_code', 'label' => ctrans('texts.postal_code'), 'type' => 'text', 'validation' => 'required'];
|
||||
|
||||
if ($this->company_gateway->require_shipping_address) {
|
||||
$fields[] = ['name' => 'client_shipping_address_line_1', 'label' => ctrans('texts.shipping_address1'), 'type' => 'text', 'validation' => 'required'];
|
||||
$fields[] = ['name' => 'client_shipping_city', 'label' => ctrans('texts.shipping_city'), 'type' => 'text', 'validation' => 'required'];
|
||||
$fields[] = ['name' => 'client_shipping_state', 'label' => ctrans('texts.shipping_state'), 'type' => 'text', 'validation' => 'required'];
|
||||
$fields[] = ['name' => 'client_shipping_postal_code', 'label' => ctrans('texts.shipping_postal_code'), 'type' => 'text', 'validation' => 'required'];
|
||||
$fields[] = ['name' => 'client_shipping_country_id', 'label' => ctrans('texts.shipping_country'), 'type' => 'text', 'validation' => 'required'];
|
||||
}
|
||||
|
||||
|
||||
return $fields;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user