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

如何通过PayPal API修改收据上显示的店铺名称?

解决PayPal收据显示"Test Store"的问题

可行解决方法

1. 配置沙箱商家账户信息

登录PayPal开发者平台,进入沙箱账户列表,找到当前API调用对应的商家测试账户,点击「查看/编辑账户详情」,修改「商家名称」字段后保存。沙箱配置更新存在几分钟延迟,修改后需重新发起支付测试。

2. 在API请求中显式指定商家名称

若后台配置未生效,可在创建Payment对象时通过代码直接设置商家信息。在你的getPayment方法中添加MerchantInfo配置:

修改后的getPayment方法示例:

private Payment getPayment(PaypalPaymentRequest paymentRequest) throws PaypalPaymentException {
    Amount amount = new Amount();
    amount.setCurrency(paymentRequest.getCurrency().toString());
    amount.setTotal(paymentRequest.getTotalCost().toString());

    Transaction transaction = new Transaction();
    transaction.setAmount(amount);
    transaction.setDescription(getCreditBundleName(paymentRequest.getCreditBundleId()));

    List<Transaction> transactionList = new ArrayList<>();
    transactionList.add(transaction);

    Payer payer = new Payer();
    payer.setPaymentMethod("paypal");

    Payment payment = new Payment();
    payment.setIntent("sale");
    payment.setPayer(payer);
    payment.setTransactions(transactionList);

    // 新增:设置商家名称
    MerchantInfo merchantInfo = new MerchantInfo();
    merchantInfo.setBusinessName("你的实际店铺名称");
    payment.setMerchantInfo(merchantInfo);

    RedirectUrls redirectUrls = new RedirectUrls();
    redirectUrls.setCancelUrl("http://localhost:4200/buy-credits");
    redirectUrls.setReturnUrl("http://localhost:4200/complete-payment");

    payment.setRedirectUrls(redirectUrls);
    return payment;
}

3. 确认API账户匹配性

确保paypalClientId和paypalClientSecret对应的是你修改过商家名称的沙箱账户,避免因误用默认测试账户导致名称未更新。


内容的提问来源于stack exchange,提问作者ReVulV agina

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.27 21:24:55