购物车内容缺失 Paypal Express Checkout 上未显示交易详情

Shopping Cart Contents missing Transaction details not shown on Paypal Express Checkout

我正在使用 ActiveMerchantI'm trying to Integrate PayPal using express checkout and Adaptive Payment. In the Adaptive Payment I was able to view Shopping Cart Contents as below 。我的代码是这样的,它按预期工作。

 def adaptive_checkout

    listing = Listing.find(session[:listing_id].to_f)


    total_amount_in_cents = listing.price_cents

    service_charge_rate = 5 #in percentage 5%

    service_charge_in_cents = total_amount_in_cents * service_charge_rate / 100

    service_charge_in_dollor = service_charge_in_cents / 100.00 # this will be for secondary user (Admin of the system)

    total_amount_in_dollar = total_amount_in_cents / 100.00 # this will be for primary receiver

    seller_email = PaypalAccount.where(person_id: listing.author_id).last.email # This is the Primary receiver

    system_admin_email = PaypalAccount.where(active: true)
                             .where("paypal_accounts.community_id IS NOT NULL && paypal_accounts.person_id IS NULL")
                             .first.email # This is the Secondary receiver


    recipients = [
        {
            email: seller_email,
            amount: total_amount_in_dollar ,
            primary: true
        },

        {
            email: system_admin_email,
            amount: service_charge_in_dollor,
            primary: false
        }
    ]

    response = ADAPTIVE_GATEWAY.setup_purchase(
        action_type: "CREATE",
        return_url: "http://esignature.lvh.me:3000/en/transactions/status",
        cancel_url: "http://esignature.lvh.me:3000/",
        ipn_notification_url: "http://0dbf7871.ngrok.io/en/transactions/notification",
        receiver_list: recipients
    )


    ADAPTIVE_GATEWAY.set_payment_options(

        pay_key: response["payKey"],
        receiver_options: [
            {
                description: "Your purchase of #{listing.title}",
                invoice_data: {
                    item: [
                        {
                            name: listing.title,
                            item_count: 1,
                            item_price: total_amount_in_dollar,
                            price: total_amount_in_dollar
                        }
                    ]
                },
                receiver: {email: seller_email}
            },
            {
                description: "Service charge for purchase of #{listing.title} ",
                invoice_data: {
                    item: [
                        {
                            name: "Service charge for purchase of #{listing.title}",
                            item_count: 1,
                            item_price: service_charge_in_dollor,
                            price: service_charge_in_dollor
                        }
                    ]
                },
                receiver: {email: system_admin_email}
            }
        ]
    )



    # For redirecting the customer to the actual paypal site to finish the payment.
    redirect_to (ADAPTIVE_GATEWAY.redirect_url_for(response["payKey"]))
  end

但是使用express_checkout,我在交易详情中看不到我的购物车内容

但是在交易过程中,商品详情出现, 对于快速结账,我的代码是这样的

def express_checkout

    listing = Listing.find(session[:listing_id].to_f)

    response = EXPRESS_GATEWAY.setup_purchase(session[:amount].to_f,
                                              ip: request.remote_ip,
                                              return_url: "http://esignature.lvh.me:3000/en/transactions/status",
                                              cancel_return_url: "http://esignature.lvh.me:3000/",
                                              currency: "USD",
                                              allow_guest_checkout: true,
                                              items: [{name: listing.title, description: listing.description, quantity: session[:number_of_days], amount: listing.price_cents},
                                                      {name: "Service Charge", amount: session[:service_charge]}
                                              ]
    )

    redirect_to EXPRESS_GATEWAY.redirect_url_for(response.token)

  end

  def status
    if (params[:token].present? && params[:PayerID].present?)
      token = params[:token]
      @response = EXPRESS_GATEWAY.details_for(token).params
      express_purchase_options = {
          :ip => request.remote_ip,
          :token => params[:token],
          :payer_id => params[:PayerID]
      }

      response = EXPRESS_GATEWAY.purchase(session[:amount].to_f, express_purchase_options)


      if response.message == "Success"
        listing = Listing.find(session[:listing_id].to_f)
        BookingInfo.create!(listing_id: listing.id, start_on: session[:start_date].to_date, end_on: session[:end_date].to_date)
        render 'status'
      else
        render 'status_error'
      end
      reset_session_params
    else
      reset_session_params
      redirect_to homepage_without_locale_path
    end

  end

我尝试使用 set_payment_options 方法,但引发方法缺失错误。有没有其他方法可以在快速结帐时附加商品详细信息。

您是否也在 DoExpressCheckout 调用中包括订单项详细信息?如果您仅在 SetExpressCheckout 调用中发送它们,它们将显示在上面列出的结帐屏幕中,但如果未包含在 DoExpressCheckout 调用中,它们将不会显示在交易详细信息中。

https://github.com/activemerchant/active_merchant/issues/1912