简体   繁体   English

贝宝数字商品的自适应支付

[英]Paypal adaptive payments for digital goods

I am struggling to figure out how to get Digital goods to work with my adaptive payments. 我正在努力弄清楚如何使数字商品与我的自适应付款一起使用。 I am using the Paypal ruby gem can someone please show me a code sample for a payments with 2 receivers and for Digital Goods ? 我正在使用Paypal ruby gem ,有人可以给我看一个代码示例,说明使用2个接收器付款和使用“ Digital Goods吗?

I already am approved for micro payments by paypal. 我已经被贝宝(Paypal)批准使用小额付款。

# Build request object
        @pay = @api.build_pay({
          :actionType => "PAY",
          :cancelUrl => "http://localhost:3000/account", #sandbox
          :currencyCode => "USD",
          #:feesPayer => "SENDER",
          :ipnNotificationUrl => "http://596w.localtunnel.com/pay/#{purchased.id}", #sandbox
          :memo => "Test payment",
          :receiverList => {
            :receiver => [{
              :amount => price.round(2),
              :email => "an email", #sandbox
              :paymentType => "DIGITALGOODS",
              :primary => true
              },
              unless account.user.email == "an email"
              {
                :amount => mycut.round(2),
                :email => "anemail", #sandbox
                :paymentType => "DIGITALGOODS" 
                }
              end
                ] },
          :returnUrl => "http://localhost:3000/pay/complete/" #sandbox 
          })

I get the error: 我得到错误:

This feature (Digital Goods) is not supported.

As far as i know on the the Express Payment option of Paypal supports digital good. 据我所知,贝宝的“快速付款”选项支持数字商品。 if you can replace your integration to use activemerchant and use the PaypalDigitalGoodsGateway you'd do yourself a favor. 如果你能取代您的集成使用activemerchant和使用PaypalDigitalGoodsGateway你会帮自己一个忙。

Log a ticket at https://www.paypal.com/mts and they'll enable it for you. https://www.paypal.com/mts上记录票证,他们会为您启用票证。 For what it's worth, the product you're trying to use is: Digital Goods for Express Checkout. 物有所值,您想要使用的产品是:用于快速结帐的数字商品。 Express Checkout itself is available by default on all accounts, but that team can enable Digital Goods on your Sandbox account. 默认情况下,所有帐户都可以使用Express Checkout本身,但是该团队可以在您的Sandbox帐户上启用Digital Goods。

This error may appear if you get the payKey successfully but redirect user to wrong url later. 如果您成功获取了payKey,但是稍后将用户重定向到错误的url,则可能会出现此错误。

Here is haml code for form for embedded payments, including Digital Goods. 这是用于嵌入式付款(包括数字商品)的表单的haml代码。

= javascript_include_tag "//www.paypalobjects.com/js/external/apdg.js"

%form.text-center{:action => ::PAYPAL_ADAPTIVE_GATEWAY.embedded_flow_url, :target => "PPDGFrame"}
  %input#type{:name => "expType", :type => "hidden", :value => "light"}
  %input#paykey{:name => "payKey", :type => "hidden", :value => @payKey}
  %input#submitBtn{:type => "submit", :value => 'Pay with PayPal' }

:javascript
  var returnFromPayPal = function(){
  //do something on PayPal popup closing here
  };
  var dgFlowMini = new PAYPAL.apps.DGFlowMini({ trigger: 'submitBtn', callbackFunction: returnFromPayPal});

  //works only for lightbox mode
  function MyEmbeddedFlow(embeddedFlow) {
      this.embeddedPPObj = embeddedFlow;
      this.paymentSuccess = function () {
           this.embeddedPPObj.closeFlow();
           // handle payment success here
           window.location.reload(true);
      };
      this.paymentCanceled = function () {
           this.embeddedPPObj.closeFlow();
           // handle payment cancellation here
           window.location.reload(true);
      };
   }
   var myEmbeddedPaymentFlow = new MyEmbeddedFlow(dgFlowMini);

::PAYPAL_ADAPTIVE_GATEWAY.embedded_flow_url is from activemerchant, you may use 'https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay' for sandbox or 'https://www.paypal.com/webapps/adaptivepayment/flow/pay' for production. ::PAYPAL_ADAPTIVE_GATEWAY.embedded_flow_url是activemerchant,你可以使用'https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay'的沙箱或'https://www.paypal.com/webapps/adaptivepayment/flow/pay'进行生产。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM