gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 15:48:25 24 4
gpt4 key购买 nike

我正在使用 ActiveMerchant我正在尝试使用快速结账和自适应支付来集成 PayPal。在自适应支付中,我能够查看购物车内容,如下所示 Shopping cart content .我的代码是这样的,它按预期工作。

 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,我无法在交易明细中看到我的购物车内容

express_checkout

然而在交易过程中,元素详情出现, Item details对于快速结帐,我的代码是这样的

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

关于ruby-on-rails - 购物车内容缺失 Paypal Express Checkout 上未显示交易详情,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33409443/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com