I need to take information entered into a quote object, and authorize it on DirectPost programmatically.
The code, just like the REST API, will create an order, but with no payment data and no transaction. Nothing gets sent to Authorize.net.
This is what I have that creates an order from a quote with the correct payment method, but no transaction and no authorization:
$cartId = $post['cart_id'];
$quote = $this->_objectManager->create('\Magento\Quote\Model\Quote')->loadActive($cartId);
$info = $quote->getPayment()->importData(
[
PaymentInterface::KEY_METHOD => 'authorizenet_directpost',
'cc_type' => $post['cc_type'],
'cc_owner' => $post['cc_owner'],
'cc_last_4' => substr($post['cc_number'], -4),
'cc_number' => $post['cc_number'],
'cc_cid' => $post['cc_cid'],
'cc_exp_month' => $post['cc_exp_month'],
'cc_exp_year' => $post['cc_exp_year']
]
);
$quote->setCustomerId(null);
$quote->setCustomerEmail($quote->getBillingAddress()->getEmail());
$quote->setCustomerIsGuest(true);
$quote->setCustomerGroupId(\Magento\Customer\Api\Data\GroupInterface::NOT_LOGGED_IN_ID);
$billingaddress=$quote->getBillingAddress();
$quote->getShippingAddress()->setSameAsBilling(true);
$quote->save();
$payment = $quote->getPayment();
$order = $this->_objectManager->create('\Magento\Quote\Model\QuoteManagement')->submit($quote);
How do I get it to authorize and add transaction data to the order it created?