कभी भी बेहतर देर से नहीं, हुह?
ActiveMerchant की वास्तविक मास्टर शाखा में एक आवर्ती वर्ग PaypalGateway
और PaypalExpressGateway
दोनों में एकीकृत है।
यहां एक डेमो स्निपेट है जो काम करता है।
- बस बिलिंग अनुबंध
:initial_amount
की स्थापना की परवाह किए बिना किसी भी कीमत प्रदर्शित नहीं करता है की स्थापना: मैं बस कुछ ही अंक (के रूप में मैं उन्हें पता लगा मैं जितनी जल्दी जवाब अपडेट करेगा) है, जो कर रहे हैं के बारे में यकीन नहीं है। एक आइटम सहित आइटम की कीमत billing_agreement[:description]
से ऊपर दिखाएगी। तो मुझे यकीन नहीं है कि यह कैप्चरिंग को कैसे प्रभावित करता है, जो मैं इन दिनों परीक्षण कर रहा हूं।
आईपीएन नोटिफिकेशन। वे निम्नलिखित स्निपेट में गायब हैं। निम्नलिखित अद्यतन ...
class PaymentsController < ApplicationController
include ActiveMerchant::Billing
# GET /subscriptions/:id/checkout
def checkout
payment_request = PAYPAL_EXPRESS_GATEWAY.setup_purchase(@subscription.price_in_cents,
:billing_agreement => {
:type => 'RecurringPayments',
:description => 'Subscription agreement',
},
:currency => 'CHF',
:no_shipping => true,
:allow_guest_checkout => true,
:allow_note => false,
:initial_amount => @subscription.price_in_cents,
:locale => 'de',
:ip => request.remote_ip,
:return_url => url_for(:action => :confirm, :only_path => false),
:cancel_return_url => url_for(:action => :cancel, :only_path => false),
# Looks like :notify_url is not used here, but in the next section
)
if payment_request.success?
redirect_to PAYPAL_EXPRESS_GATEWAY.redirect_url_for(payment_request.token)
else
# Render something informal
render :text => payment_request.inspect.to_s and return
end
end
# POST /subscriptions/:id/confirm
# params having token and PayerID
def confirm
profile = PAYPAL_EXPRESS_GATEWAY.recurring(@subscription.price_in_cents, nil,
:description => 'Subscription agreement',
:start_date => Date.tomorrow, # PayPal throws an error if the date is not in the future
:period => 'Year',
:frequency => 1,
:amount => @subscription.price_in_cents,
:currency => 'CHF',
:initial_amount => @subscription.price_in_cents,
:auto_bill_outstanding => true,
:token => params[:token]
)
# profile has profile_id and profile_status. remember status because this gets updated via IPN.
@debug = {:params => params.inspect.to_s, :profile => profile.inspect.to_s }
# Render something informal
render :text => @debug.to_s and return
end
# implement instead of just log
def notification
log = Logger.new 'log/ipn.log'
log.debug params.inspect
render :text => params.inspect.to_s and return
end
# Private methods omitted
end
आप को देखने के लिए जो विकल्प संसाधित व एक्सएमएल अनुरोध की जो जगह में कर रहे हैं PaypalRecurringAPI और PaypalExpressGateway/PayPalGateway में एक देखो करना चाहते हैं।
संपादित करें पेपैल और पुनरावर्ती बिलिंग के बारे में नया, संशोधित स्क्रीनकास्ट अलग paypal-recurring मणि के साथ किया जाता है। शायद यह मदद करता है अगर आप इसे ActiveMerchant के साथ काम नहीं कर पा रहे हैं।
यह संबंधित पोस्ट आपके लिए भी उपयोगी हो सकती है। http://stackoverflow.com/questions/1683929/paypal-recurring- बिलिंग-and-activemerchant –