У меня есть следующий код, но я не могу получить информацию о кредитной карте. Я повторяю это, и это просто показывает пустым. Не уверен почему. Любая помощь приветствуется
namespace Cytruslogic\Subscriptions\Model;
use \Stripe\Stripe;
/**
* Pay In Store payment method model
*/
class StripeSubscriptions extends \Magento\Payment\Model\Method\AbstractMethod
{
/**
* Payment code
*
* @var string
*/
CONST CODE = 'stripesubscriptions';
protected $_code = self::CODE;
/**
* Availability option
*
* @var bool
*/
protected $_isOffline = false;
protected $_isGateway = true;
protected $_canCapture = true;
protected $_canAuthorize = true;
public function capture(\Magento\Payment\Model\InfoInterface $Payment, $Amount)
{
echo $Payment->getCcType();
throw new \Magento\Framework\Exception\LocalizedException(__('Testing'));
// echo $payment->getCcNumber();
/** @var \Magento\Sales\Model\Order\Address $billing */
/*
$billing = $order->getBillingAddress();
try {
$requestData = [
'amount' => $amount * 100,
'currency' => strtolower($order->getBaseCurrencyCode()),
'description' => sprintf('#%s, %s', $order->getIncrementId(), $order->getCustomerEmail()),
'card' => [
'number' => $payment->getCcNumber(),
'exp_month' => sprintf('%02d',$payment->getCcExpMonth()),
'exp_year' => $payment->getCcExpYear(),
'cvc' => $payment->getCcCid(),
'name' => $billing->getName(),
'address_line1' => $billing->getStreetLine(1),
'address_line2' => $billing->getStreetLine(2),
'address_city' => $billing->getCity(),
'address_zip' => $billing->getPostcode(),
'address_state' => $billing->getRegion(),
'address_country' => $billing->getCountryId(),
// To get full localized country name, use this instead:
// 'address_country' => $this->_countryFactory->create()->loadByCode($billing->getCountryId())->getName(),
]
];
$charge = \Stripe\Charge::create($requestData);
$payment
->setTransactionId($charge->id)
->setIsTransactionClosed(0);
} catch (\Exception $e) {
$this->debugData(['request' => $requestData, 'exception' => $e->getMessage()]);
$this->_logger->error(__('Payment capturing error.'));
throw new \Magento\Framework\Validator\Exception(__('Payment capturing error.'));
}
*/
return $this;
}
public function authorize(\Magento\Payment\Model\InfoInterface $Payment, $Amount)
{
echo 'authorize';
$Order = $Payment->getOrder();
print_r($Payment->getCcNumber());
}
public function getConfigPaymentAction()
{
return self::ACTION_AUTHORIZE_CAPTURE;
}
/**
* Test method to handle an API call for authorization request.
*
* @param $request
* @return array
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function makeAuthRequest($request)
{
$response = ['transactionId' => 123]; //todo implement API call for auth request.
if(!$response) {
throw new \Magento\Framework\Exception\LocalizedException(__('Failed auth request.'));
}
return $response;
}
/**
* Test method to handle an API call for capture request.
*
* @param $request
* @return array
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function makeCaptureRequest($request)
{
$response = ['success']; //todo implement API call for capture request.
if(!$response) {
throw new \Magento\Framework\Exception\LocalizedException(__('Failed capture request.'));
}
return $response;
}
}