我有以下代码,但无法获取信用卡信息。我回应它,它只是显示空白。不知道为什么。任何帮助表示赞赏
命名空间 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(__('捕获请求失败。')); } 返回$响应; } }