Skip to content

Commit

Permalink
chore: add pagarme partner id to new transactions (#107)
Browse files Browse the repository at this point in the history
* chore(secrets): set partner private id on request #100

* chore(secret): replace variable name

fixes #100
  • Loading branch information
matheusgnreis committed Jun 28, 2023
1 parent 1f7f00a commit 742ee2d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }}
SERVER_OPERATOR_TOKEN: ${{ secrets.SERVER_OPERATOR_TOKEN }}
PARTNER_ID: ${{ secrets.PARTNER_ID }}
run: npm run deploy

update-app-json:
Expand Down
5 changes: 3 additions & 2 deletions functions/__env.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// setup server and app options from Functions config (and mocks)
const { pkg, server } = require('firebase-functions').config()
const { pkg, server, pagarme } = require('firebase-functions').config()
const functionName = server.functionName || 'app'

module.exports = {
Expand All @@ -9,5 +9,6 @@ module.exports = {
`https://us-central1-${process.env.GCLOUD_PROJECT}.cloudfunctions.net/${functionName}`,
pkg: {
...pkg
}
},
pagarmePartnerId: pagarme && pagarme.partner_id
}
8 changes: 6 additions & 2 deletions functions/routes/ecom/modules/create-transaction.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { baseUri } = require('./../../../__env')
const { baseUri, pagarmePartnerId } = require('./../../../__env')
const axios = require('axios')
const addInstallments = require('../../../lib/payments/add-installments')
const parseStatus = require('../../../lib/payments/parse-status')
Expand Down Expand Up @@ -102,6 +102,10 @@ exports.post = ({ appSdk }, req, res) => {
platform_integration: 'ecomplus'
}

if (pagarmePartnerId) {
pagarmeTransaction.service_referer_name = pagarmePartnerId
}

pagarmeTransaction.customer = {
email: buyer.email,
name: buyer.fullname,
Expand Down Expand Up @@ -149,7 +153,7 @@ exports.post = ({ appSdk }, req, res) => {
address: parseAddress(params.billing_address)
}
}

pagarmeTransaction.items = []
items.forEach(item => {
if (item.quantity > 0) {
Expand Down
6 changes: 4 additions & 2 deletions scripts/firebase-deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ require('dotenv').config()
const {
FIREBASE_TOKEN,
SERVER_OPERATOR_TOKEN,
SERVER_BASE_URI
SERVER_BASE_URI,
PARTNER_ID
} = process.env

require('./scripts-minification')
Expand All @@ -15,7 +16,8 @@ const client = require('firebase-tools')
const config = [
`pkg.version=${version}`,
`pkg.name=${name}`,
`server.operator_token=${SERVER_OPERATOR_TOKEN}`
`server.operator_token=${SERVER_OPERATOR_TOKEN}`,
`pagarme.partner_id=${PARTNER_ID}`
]
if (SERVER_BASE_URI) {
config.push(`server.base_uri=${SERVER_BASE_URI}`)
Expand Down

0 comments on commit 742ee2d

Please sign in to comment.