Question

I'm trying to config my paypal gateway and activemerchant with help of railscasts tutorial but I'm a bit confused because the gateway information has changed.

That's the old config from the tutorial:

gateway = ActiveMerchant::Billing::PaypalGateway.new(
  login: "...",
  password: "...",
  signature: "..."
)

In my PaypalSandbox-Account I just have this:

  1. Endpoint: "..."
  2. Client ID: "..."
  3. Secret: "..."

What's the right config?

Was it helpful?

Solution

What you need for your gateway are the classic credentials. In order to get your these you have to first create a Paypal sandbox account that will act as your seller. Make sure it is a Business/Merchant type account.

Once you do that then click on the "Profile" link for that account, look under the tab "API Credentials." That will have all the information you need listed.

  1. Paypal API Username
  2. Paypal API Signature
  3. Paypal API Password

OTHER TIPS

From scratch testing

First you have to go to Paypal developer's website and create and account

Then generate sandbox user type business then click on Profile option and then click on API Credentials tab you will finally the required data such login/username, password/password, signature/signature

enter image description here

require 'active_merchant'

    ActiveMerchant::Billing::Base.mode = :test
    paypal_options = {
        login: "activemerchant-test_api1.example.com",
        password: "HBC6A84QLRWC923A",
        signature: "AFcWxV21C7fd0v3bYYYRCpSSRl31AC-11AKBL8FFO9tjImL311y8a0hx"
    }
    @gateway = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options)


    response = @gateway.setup_purchase(50,
        ip: request.remote_ip,
        return_url: "http://local.mywebdomain.com:3000/mylocalhostpaymentsucceed",
        cancel_return_url: "http://local.mywebdomain.com:3000/seeyouagain",
        currency: "USD",
        allow_guest_checkout: true,
        items: [{name: "Order", description: "Order description", quantity: "1", amount: 50}]
    )
    redirect_to  @gateway.redirect_url_for(response.token)

Another tip is how to set the localhost to local.mywebdomain.com. Just edit the .host file inside system32 folder of your machine as

127.0.0.1 local.mywebdomain.com
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top