-
Notifications
You must be signed in to change notification settings - Fork 59
Merge 3rd stream #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
OpesanyaAdebayo
wants to merge
1
commit into
main
Choose a base branch
from
3-recurring-debit-webhook-duplicate-transaction-initial
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,6 +60,7 @@ async function completeSuccessfulCharge({ accountId, reference, amount }) { | |
| message: 'Account successfully credited', | ||
| }; | ||
| } | ||
|
|
||
| async function chargeCard({ | ||
| accountId, pan, expiry_month, expiry_year, cvv, email, amount, | ||
| }) { | ||
|
|
@@ -78,7 +79,6 @@ async function chargeCard({ | |
| Authorization: `Bearer ${process.env.PAYSTACK_SECRET_KEY}`, | ||
| }, | ||
| }); | ||
|
|
||
| const nextAction = processInitialCardCharge(charge.data); | ||
| await models.card_transactions.create({ | ||
| external_reference: nextAction.data.reference, | ||
|
|
@@ -302,3 +302,30 @@ async function submitPhone({ | |
| return error.response ? error.response.data : error; | ||
| } | ||
| } | ||
|
|
||
| async function chargeCardWithAuthorization(authorization) { | ||
| const charge = await axios.post(PAYSTACK_BASE_URL, { | ||
| authorization_code: authorization, | ||
| amount: 10000, | ||
| email: '[email protected]', | ||
| }, { | ||
| headers: { | ||
| Authorization: `Bearer ${process.env.PAYSTACK_SECRET_KEY}`, | ||
| }, | ||
| }); | ||
| return { | ||
| success: true, | ||
| data: charge.data.data, | ||
| }; | ||
| } | ||
|
|
||
| chargeCardWithAuthorization('AUTH_zev61rikmn').then(console.log).catch(console.log); | ||
| // chargeCard({ | ||
| // accountId: 1, | ||
| // pan: '506066506066506067', | ||
| // amount: 1000000, | ||
| // cvv: '060', | ||
| // email: '[email protected]', | ||
| // expiry_month: '12', | ||
| // expiry_year: '25', | ||
| // }).then(console.log).catch(console.log); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| const crypto = require('crypto'); | ||
|
|
||
| const key = 'mysecret key'; | ||
|
|
||
| // create hahs | ||
| // const hash = crypto.createHmac('sha512', key); | ||
| // hash.update(text); | ||
| // const value = hash.digest('hex'); | ||
|
|
||
| // print result | ||
| // console.log(value); | ||
|
|
||
| function hashArguments(...parameters) { | ||
| const concatenatedRequest = parameters.join(''); | ||
| const hash = crypto.createHmac('sha512', key); | ||
| hash.update(concatenatedRequest); | ||
| return hash.digest('hex'); | ||
| } | ||
|
|
||
| module.exports = { hashArguments }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@uncoooloj this is where I used the implementation for #3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seen it, what if transactions are just a few milli seconds apart?
That's my fear. The system won't be done with this IO so both will pass.
What do you think?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, @uncoooloj Redis also has implementations for transactions and optimistic locking.
I'll update it in the final version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so quick question, what if there was a request throttling to one request per 10 ms for example? sounds like a lazy hack but that + a transaction has solves our problem no?