-
Notifications
You must be signed in to change notification settings - Fork 308
Start recording ref in exchanges table #4361
Conversation
I do believe that this is ready for review. @mattbk @rohitpaulk @nobodxbodon et.al |
@@ -82,6 +83,7 @@ def create_card_hold(db, participant, amount): | |||
'options': { 'submit_for_settlement': False }, | |||
'custom_fields': {'participant_id': participant.id} | |||
}) | |||
ref = result.transaction.id |
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.
A general question: can ref here and below be null?
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.
yes it can be according to the current state of the db table. For recording and accounting purposes we don't want it not to be null but because of the current issue with the missing back data we need to allow nulls until we can back fill all the refs (if that is at all possible).
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.
To make sure, after this PR, all the newly inserted records afterwards will have ref field as non-null?
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.
Do they give us a URL and not just a transaction id? Eventually we're going to want to cross-link from Gratipay (admin) UI over to Braintree (etc.). Transaction id is a start but if we can know a URL at this point then let's just store that, ya?
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.
all the newly inserted records afterwards will have ref field as non-null?
I believe they will/should be null if the transaction fails. We still want to record our attempt at a transaction even if the API call fails.
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.
@whit537 I believe that it should be null if it fails in the try...except
block but it may still have a reference in Braintree if fails on there side after the card_hold
has been created.
Eventually we're going to want to cross-link from Gratipay (admin) UI over to Braintree (etc.).
Going to look into this now.
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.
it may still have a reference in Braintree if fails on there side after the
card_hold
has been created.
Hmmm ... we should probably differentiate "failure" state as reported by Braintree from an "error" state due to, e.g., network failure during the API call.
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.
we can always do that in the note field of the exchange record. (sorry for stating the obvious)
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.
Can we just build a URL to the transaction? E.g., Stripe builds URLs like https://dashboard.stripe.com/payments/ch_19tIgqD5FJNWkW8j1uWePP8O with the charge ID.
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.
After a ridiculous long time researching it...yes we can build a URL to the transaction using transaction.id
I believe it would look something like
https://dashboard.braintreegateway.com/merchants/gratipay/transactions/1vt8z5a3
where 1vt8z5a3
is the transaction.id
gratipay/billing/exchanges.py
Outdated
@@ -74,6 +74,7 @@ def create_card_hold(db, participant, amount): | |||
|
|||
hold = None | |||
error = "" | |||
ref = "" |
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.
Why do we need to set this here? For when the transaction fails and we don't have a ref? Shouldn't we just stick with null in that case?
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.
I needed to set this (but it could be Null) because it kept giving the error that the variable was being referenced before being assigned
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.
After some consideration...yes it should be Null
if the try..except
fails
This last commit just changes the ref from an empty string to It should be noted that all of the transaction history is attached to the one id on creation of the transaction in the Braintree system. Refund transactions is the only action that has a different id from the origin transaction for which it is made. There is a field in the refund transaction that links to the original transaction for which the refund is being made. IRL @whit537 suggested that eventually we may want to record the origin transaction ids for refunds that we do in its own field. Currently it is recorded in the |
ok ready for review/merge |
Merge conflict! |
Working on the conflict files no sure why it is saying that. |
I just can't figure out the conflict |
…y.com into record-ref-in-exchanges
I'm not sure what I just did. Was following the command line instructions mentioned in the box at the bottom of the PR. |
I was trying not to do that since the commands merge the branch into master (at least that is what I think it does) and I did not want to do that until the conflict was resolved. ... !m @mattbk Ready for review and merging if acceptable |
Yeah, I stopped once I had merged master into this branch, and then pushed from there. I think it was only the first block of commands.
and then I think you got the right change in 9445dda, but for some reason it wasn't working right. |
This should fix the problem of not recording the ref to the external system. In this PR only the braintree ref id is being recorded. @whit537 suggested that the Paypal MassPay reference be done in another PR.
Please note that this first commit should fail since I have not updated the
test_billing_exchanges.py
as yet.