Rails Spree OffsitePayments Integrations work flow

152 views Asked by At

I'm a newbie in Spree, ActiveMerchant and payment flow...

That said, I am trying to integrate an OffsitePayment to spree, I created a custom gateway, added it to spree's payment methods on spree.rb config file and set it up on the admin interface, such that it is showing as an option to the buyer, and the purchase method is getting called. But what to actually do inside the purchase method? I suppose (and expect) that the integration helper has some properties I need to fill in (as I see in the docs for it), but once it is filled, how do I actually "submit" the payment? I don't even know if I should be looking for something spree related or OffsitePayments, or ActiveMerchant related... a bit lost.

class Spree::Gateway::PagSeguro < Spree::Gateway
    def provider_class
        OffsitePayments::Integrations::PagSeguro
    end

    def provider
        provider_class::Helper
    end

    def auto_capture?
        true
    end

    def purchase(amount, paym_source, gateway_options={})
        # What to do here?            
        ActiveMerchant::Billing::Response.new(true, 'success', {}, {})
    end

end
1

There are 1 answers

0
GeekOnCoffee On

Your purchase method needs to do whatever is required for the gateway to take the money, and then return the appropriate ActiveMerchant::Billing::Response based on the status so that Spree knows how to process it.