Paypal.Auth (Paypal v0.1.1)

View Source

Paypal requires to have an authenticated token to interact. This module helps to generate a token time to time (before it's expired) and ensure we have always the correct one.

To achieve this, we need a bit of configuration. We could provide this adding in our project the following block:

config :paypal,
  url: System.get_env("PAYPAL_URL", "https://api-m.sandbox.paypal.com"),
  client_id: System.get_env("PAYPAL_CLIENT_ID"),
  secret: System.get_env("PAYPAL_SECRET")

Because the content of the client_id and secret are sensitive, I prefer provide these values using the environment variables, but if you need to put them in your config file for your project, go ahead.

The configuration parameters are the following:

  • url is the URL where we have to perform the base requests. Paypal has two different URLs and you can see in the example above the one that's in use for the sandbox/testing environment. This is the one you should use for development.
  • client_id is one of the data Paypal provide us when we generate the API data to be connected to them.
  • secret this is the most sensitive one. If that's unveil, go to the Paypal website and regenerate a new one!

Summary

Functions

Get active token.

Get token and fails if there's no token.

Functions

get_token()

Get active token.

get_token!()

Get token and fails if there's no token.