magento-2.3 - Magneto 2 支付模块 - 无法获取信用卡号
问题描述
我有以下代码,但无法获取信用卡信息。我回应它,它只是显示空白。不知道为什么。任何帮助表示赞赏
命名空间 Cytruslogic\订阅\模型; 使用\条纹\条纹; /** * Pay In Store 付款方式模型 */ 类 StripeSubscriptions 扩展 \Magento\Payment\Model\Method\AbstractMethod { /** * 付款代码 * * @var 字符串 */ 常量代码 = 'stripesubscriptions'; 受保护的 $_code = self::CODE; /** * 可用性选项 * * @var 布尔值 */ 受保护的 $_isOffline = false; 受保护的 $_isGateway = true; 受保护的 $_canCapture = true; 受保护的 $_canAuthorize = true; 公共函数捕获(\Magento\Payment\Model\InfoInterface $Payment, $Amount) { 回声 $Payment->getCcType(); 抛出新的 \Magento\Framework\Exception\LocalizedException(__('Testing')); // echo $payment->getCcNumber(); /** @var \Magento\Sales\Model\Order\Address $billing */ /* $billing = $order->getBillingAddress(); 尝试 { $请求数据 = [ '金额' => $金额* 100, '货币' => strtolower($order->getBaseCurrencyCode()), 'description' => sprintf('#%s, %s', $order->getIncrementId(), $order->getCustomerEmail()), '卡' => [ '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(), // 要获取完整的本地化国家/地区名称,请改用: // 'address_country' => $this->_countryFactory->create()->loadByCode($billing->getCountryId())->getName(), ] ]; $charge = \Stripe\Charge::create($requestData); $支付 ->setTransactionId($charge->id) ->setIsTransactionClosed(0); } 捕捉 (\Exception $e) { $this->debugData(['request' => $requestData, 'exception' => $e->getMessage()]); $this->_logger->error(__('付款捕获错误。')); 抛出新的 \Magento\Framework\Validator\Exception(__('支付捕获错误。')); } */ 返回$这个; } 公共函数授权(\Magento\Payment\Model\InfoInterface $Payment, $Amount) { 回声“授权”; $Order = $Payment->getOrder(); print_r($Payment->getCcNumber()); } 公共函数 getConfigPaymentAction() { 返回自我::ACTION_AUTHORIZE_CAPTURE; } /** * 处理授权请求的 API 调用的测试方法。 * * @param $请求 * @return 数组 * @throws \Magento\Framework\Exception\LocalizedException */ 公共函数 makeAuthRequest($request) { $response = ['transactionId' => 123]; //todo 为认证请求实现 API 调用。 如果(!$响应){ 抛出新的 \Magento\Framework\Exception\LocalizedException(__('Failed auth request.')); } 返回$响应; } /** * 处理捕获请求的 API 调用的测试方法。 * * @param $请求 * @return 数组 * @throws \Magento\Framework\Exception\LocalizedException */ 公共函数 makeCaptureRequest($request) { $response = ['成功']; //todo 实现捕获请求的 API 调用。 如果(!$响应){ 抛出新的\Magento\Framework\Exception\LocalizedException(__('捕获请求失败。')); } 返回$响应; } }
解决方案
推荐阅读
- swift - 从 Firebase 集合和子集合循环中快速加载数据
- google-apps-script - Google 表格:更新现有行中的数据
- angular - 单击数据表行中的按钮时弹出模式
- extjs - 需要将表单显示为网格
- python - Jupyter Notebook 安装错误 - argon2-cffi (PEP 517) 的构建轮...错误
- php - PHP Cron计划作业未执行
- python-3.x - 太多的值无法解压(预期为 3)pygame 点击问题
- google-app-engine - Cloud Build 无法部署到 Google App Engine - 您无权充当 @appspot.gserviceaccount.com
- gnuplot - grep 文件中的值,然后将其用作文件夹名称来定位文件并绘图
- c++ - 打印 gcc 支持的最新 C++ 标准