Add Bill To for auth.net

This commit is contained in:
David Bomba 2023-06-01 08:17:37 +10:00
parent 483a656b5f
commit 261da8afdd

View File

@ -91,6 +91,27 @@ class AuthorizeTransaction
$duplicateWindowSetting->setSettingName("duplicateWindow");
$duplicateWindowSetting->setSettingValue("60");
$contact = $this->authorize->client->primary_contact()->first() ?: $this->authorize->client->contacts()->first();
if($contact) {
$billto = new \net\authorize\api\contract\v1\CustomerAddressType();
$billto->setFirstName(substr($contact->present()->first_name(), 0, 50));
$billto->setLastName(substr($contact->present()->last_name(), 0, 50));
$billto->setCompany(substr($this->authorize->client->present()->name(), 0, 50));
$billto->setAddress(substr($this->authorize->client->address1, 0, 60));
$billto->setCity(substr($this->authorize->client->city, 0, 40));
$billto->setState(substr($this->authorize->client->state, 0, 40));
$billto->setZip(substr($this->authorize->client->postal_code, 0, 20));
if ($this->authorize->client->country_id) {
$billto->setCountry($this->authorize->client->country->name);
}
$billto->setPhoneNumber(substr($this->authorize->client->phone, 0, 20));
}
//Assign to the transactionRequest field
$transactionRequestType = new TransactionRequestType();
$transactionRequestType->setTransactionType('authCaptureTransaction');
$transactionRequestType->setAmount($amount);
@ -100,9 +121,11 @@ class AuthorizeTransaction
$transactionRequestType->addToTransactionSettings($duplicateWindowSetting);
$transactionRequestType->setPayment($paymentOne);
// $transactionRequestType->setProfile($profileToCharge);
$transactionRequestType->setCurrencyCode($this->authorize->client->currency()->code);
if($billto)
$transactionRequestType->setBillTo($billto);
$request = new CreateTransactionRequest();
$request->setMerchantAuthentication($this->authorize->merchant_authentication);
$request->setRefId($refId);