Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/55.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 是否可以使用sdk gem将账单应用到paypal?_Ruby On Rails_Paypal_Ruby On Rails 5_Paypal Rest Sdk_Paypal Subscriptions - Fatal编程技术网

Ruby on rails 是否可以使用sdk gem将账单应用到paypal?

Ruby on rails 是否可以使用sdk gem将账单应用到paypal?,ruby-on-rails,paypal,ruby-on-rails-5,paypal-rest-sdk,paypal-subscriptions,Ruby On Rails,Paypal,Ruby On Rails 5,Paypal Rest Sdk,Paypal Subscriptions,我正在将paypal支付应用到我在rails 5中开发的网站,我正在使用gem“paypal sdk rest”,它对单位支付非常有效,但我需要自动实现月费和年费的会员资格。是否可以使用gem'paypal-sdk-rest'创建会员资格?发送到paypal api的必要参数是什么?这就是我到目前为止所做的: class Paypal::CheckoutsController < ApplicationController include PayPal::SDK::REST de

我正在将paypal支付应用到我在rails 5中开发的网站,我正在使用gem“paypal sdk rest”,它对单位支付非常有效,但我需要自动实现月费和年费的会员资格。是否可以使用gem'paypal-sdk-rest'创建会员资格?发送到paypal api的必要参数是什么?这就是我到目前为止所做的:

class Paypal::CheckoutsController < ApplicationController
  include PayPal::SDK::REST

  def create
    payment = Payment.new({
      intent: 'sale',
      payer: {
        payment_method: 'paypal'
      },
      redirect_urls: {
        return_url: complete_paypal_checkouts_url,
        cancel_url: line_items_url
      },
      transactions:  [
        {
          amount: {
            total: current_cart.total,
            currency: 'USD',
          },
          description: 'Pago de productos',
          item_list: {
            items: current_cart.line_items.map(&:to_paypal)
          }
        },
      ]
    })

    if payment.create
      redirect_url = payment.links.find{|v| v.rel == "approval_url" }.href

      redirect_to redirect_url
    else
      redirect_to line_items_path, alert: 'Something went wrong, please try later'
    end
  end

  def complete
    payment = Payment.find(params[:paymentId])

    if payment.execute(payer_id: params[:PayerID])  #return true or false
      session[:cart_id] = nil
      redirect_to root_path, notice: 'Thanks for purchasing!'
    else
      redirect_to line_items_path, alert: 'There was a problem processing your payment'
    end
  end
end
class Paypal::CheckoutsController