You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过cardReference在unoapp-dev/omnipay-moneris中获取卡详情?

在unoapp-dev/omnipay-moneris中通过卡引用获取卡详情的方法

首先,你之前的代码缺少关键的send()调用——Omnipay的所有请求对象都需要执行send()才会实际发起API请求。正确的获取卡片详情流程如下:

  1. 确保卡片创建成功并拿到有效引用
    你的创建卡片代码逻辑正确,需先确认卡片创建成功再提取卡引用:

    $card = $this->gateway->createCard(['card' => $card])->send();
    if ($card->isSuccessful()) {
        $ref = $card->getCardReference();
    } else {
        // 处理卡片创建失败逻辑
    }
    
  2. 使用fetchCard请求获取卡详情
    调用fetchCard并传入卡引用,执行send()后即可获取目标有效期信息:

    $cardDetails = $this->gateway->fetchCard([
        'cardReference' => $ref
    ])->send();
    
    if ($cardDetails->isSuccessful()) {
        // 获取有效期信息
        $expiryYear = $cardDetails->getExpiryYear();
        $expiryMonth = $cardDetails->getExpiryMonth();
        // 可额外获取其他卡信息示例
        $lastFourDigits = $cardDetails->getLastFour();
        $cardBrand = $cardDetails->getBrand();
    } else {
        $errorMsg = $cardDetails->getMessage();
        // 处理获取失败逻辑
    }
    

关于你尝试的方法说明

  • getCardDetails:该驱动未封装此标准方法,不建议使用。
  • fetchProfile:此方法用于获取客户的完整档案(可能包含多张卡片),仅需单张卡片详情时,fetchCard是更精准的选择。

内容的提问来源于stack exchange,提问作者Nazmus Sakib

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.20 16:42:06