Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
lmscunha committed Nov 29, 2024
1 parent c90fc48 commit adbd17a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
7 changes: 4 additions & 3 deletions dist/tillo-provider.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/tillo-provider.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions src/tillo-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ function generateAuthSign(signData: Map<string, string>) {
sd.delete("apiSecret")
const sdList: any = []


sd.forEach((v: any) => {
sdList.push(v)
})
Expand Down Expand Up @@ -111,7 +110,9 @@ function TilloProvider(this: any, options: TilloProviderOptions) {

const { clientRequestId, brand, currency, value, sector } = msg.q

const clientRId = clientRequestId || `${msg.q.user_id}-digitalissue-${timestamp}`
const clientRId = clientRequestId ||
`${msg.q.user_id}-${brand}-digitalissue-${value}-${timestamp}`

const curr = currency || "GBP"

const signData: Map<string, string> = new Map([
Expand Down Expand Up @@ -165,7 +166,7 @@ function TilloProvider(this: any, options: TilloProviderOptions) {
}

this.shared.headers = {
'API-Key': res.keymap.key.value,
'API-Key': res.keymap.apikey.value,
}

this.shared.secret = res.keymap.secret.value
Expand All @@ -183,7 +184,7 @@ function TilloProvider(this: any, options: TilloProviderOptions) {
const defaults: TilloProviderOptions = {

// NOTE: include trailing /
url: 'https://sandbox.tillo.dev/api/v2/',
url: 'https://app.tillo.io/',

// Use global fetch by default - if exists
fetch: ('undefined' === typeof fetch ? undefined : fetch),
Expand Down
2 changes: 2 additions & 0 deletions test/local-config-template.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
module.exports = {
TILLO_API_KEY: '<API_KEY>',
TILLO_SECRET: '<SECRET>',
}
6 changes: 3 additions & 3 deletions test/tillo-provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,22 @@ async function makeSeneca() {
// debug: true,
file: [__dirname + '/local-config.js;?'],
var: {
$TILLO_KEY: String,
$TILLO_API_KEY: String,
$TILLO_SECRET: String,
}
})
.use('provider', {
provider: {
tillo: {
keys: {
key: { value: '$TILLO_KEY' },
apikey: { value: '$TILLO_API_KEY' },
secret: { value: '$TILLO_SECRET' },
}
}
}
})
.use(TilloProvider, {
// fetch: Fetch,
url: 'https://sandbox.tillo.dev/api/v2/',
})

return seneca.ready()
Expand Down

0 comments on commit adbd17a

Please sign in to comment.