Skip to content

viktorRock/payment-services

Repository files navigation

Payment Services

Payment services (PagSeguro) in the Google Cloud with NodeJS

Pre requisites

  1. A PagSeguro Account
  2. A Google Cloud Account

How to use it on the Cloud ?

  1. Enter Google cloud shell

  2. Clone repository on your google cloud App Engine (flex environemnt for NodeJS)

    • git clone https://github.com/viktorRock/OrdersPlat.git
  3. Set Environemnt Vars into app.yaml file, after enter Google cloud shell

    1. GOOGLE_SPREADSHEET_SCOPE - Usually 'https://www.googleapis.com/auth/spreadsheets' but it can be one of these ones here
    2. Pagseguro keys and auth info
      1. PAGSEG_URL -
        • Production - "https://ws.pagseguro.uol.com.br/v2/checkout"
        • test enviroment - "https://ws.sandbox.pagseguro.uol.com.br/v2/checkout"
      2. PAGSEG_CLIENT_TOKEN - API token you received from PagSeguro
      3. PAGSEG_CLIENT_EMAIL - Your e-mail from the PagSegure Sign Up
      4. name and config_id: - You get it during Google tutorial after running gcloud service-management deploy openapi.yaml
      • Example
          runtime: nodejs
          env: flex
          endpoints_api_service:
            # The following values are to be replaced by information from the output of
            # 'gcloud service-management deploy openapi.yaml' command.
            name: echo-api.endpoints.XXXXXXX-YYYYYYY.cloud.goog
            config_id: 2017-MM-DDzz
      
          env_variables:
              PAGSEG_CLIENT_EMAIL: 'pvmathiassilva@gmail.com'
              PAGSEG_CLIENT_TOKEN: 'EX1DAE21468965315HDFAF589GS3689008'
              PAGSEG_URL: 'https://ws.pagseguro.uol.com.br/v2/checkout'
      
  4. Deploying on Google Cloud Endpoints - Tutorial

How to test it ?

  1. Install curl
  2. Set environment variables
    • ENDPOINTS_HOST - Where your Endpoint were deployed on Tutorial
    • ENDPOINTS_KEY - The Endpoint key created during Tutorial
  3. Run the following command
    1. Windows
      • curl -vv -H "Content-Type: application/json" -d "@data.json" "%ENDPOINTS_HOST%/uolcheckout?key=%ENDPOINTS_KEY%"
    2. Linux
      • curl -vv -L -d '@data.json' -H 'Content-Type: application/json' "${ENDPOINTS_HOST}/uolcheckout?key=${ENDPOINTS_KEY}"