【问题标题】:PayPal REST API Order Summary Custom DescriptionPayPal REST API 订单摘要 自定义描述
【发布时间】:2016-01-20 04:13:40
【问题描述】:

是否可以在 PayPal 订单摘要页面中添加自定义消息? 仅当我不使用 setItemList 功能时,我才能放置我的自定义描述。

这里是支付功能:

    $payer = new Payer();
    $payer->setPaymentMethod($type);

    $item = new Item();
    $item->setName($this->record['title']);
    $item->setCurrency('GBP');
    $item->setQuantity(1);
    $item->setSku($order['id']);
    $item->setPrice($price);
    $item->setDescription($price);

    $itemList = new ItemList();
    $itemList->setItems(array($item));

    $amount = new Amount();
    $amount->setCurrency('GBP');
    $amount->setTotal($order['price']);

    $transaction = new Transaction();
    $transaction->setAmount($amount);
    $transaction->setItemList($itemList);
    $transaction->setDescription("My custom description");

    $baseUrl = SITE_URL.FrontendNavigation::getURLForBlock($this->module, 'Callback');
    $redirectUrls = new RedirectUrls();
    $redirectUrls->setReturnUrl($baseUrl.'?success=true');
    $redirectUrls->setCancelUrl($baseUrl.'?success=false');

    $payment = new Payment();
    $payment->setIntent("sale");
    $payment->setPayer($payer);
    $payment->setRedirectUrls($redirectUrls);
    $payment->setTransactions(array($transaction));

这是带有 setItemList 方法的摘要窗口: Image

问题是我需要摆脱所有这些信息(项目描述、项目编号等)并且只有我的自定义描述(一些字符串或其他变量)。

如果我不使用 setItemList 我会得到这个窗口。 Image 现在我可以看到我的自定义消息,但是包含此次购买总价格的项目总计行消失了。是否可以仅包含我的自定义消息而没有任何其他信息的总价格行?

【问题讨论】:

    标签: php api rest paypal paypal-rest-sdk


    【解决方案1】:

    不可能有一个只有项目名称和描述的单行。 项目始终显示为行项目及其相应的总计。

    $item1 = new Item();
    $item1->setName('My Custom Description')
        ->setCurrency('USD')
        ->setQuantity(1)
         ->setPrice(7.5);
    $itemList = new ItemList();
    $itemList->setItems(array($item1));
    $amount = new Amount();
    $amount->setCurrency("USD")
        ->setTotal(7.5);
    $transaction = new Transaction();
    
    $transaction->setAmount($amount)
        ->setItemList($itemList)
        ->setDescription("Payment description");
    

    【讨论】:

      猜你喜欢
      • 2015-12-09
      • 2013-03-05
      • 2015-03-21
      • 2013-08-08
      • 2012-07-09
      • 2013-12-05
      • 1970-01-01
      • 1970-01-01
      • 2016-09-17
      相关资源
      最近更新 更多