/usr/lib/python3/dist-packages/braintree/dispute.py is in python3-braintree 3.38.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | from decimal import Decimal
from braintree.attribute_getter import AttributeGetter
from braintree.transaction_details import TransactionDetails
from braintree.dispute_details import DisputeEvidence, DisputeStatusHistory
from braintree.configuration import Configuration
class Dispute(AttributeGetter):
class Status(object):
"""
Constants representing dispute statuses. Available types are:
* braintree.Dispute.Status.Accepted
* braintree.Dispute.Status.Disputed
* braintree.Dispute.Status.Open
* braintree.Dispute.Status.Won
* braintree.Dispute.Status.Lost
"""
Accepted = "accepted"
Disputed = "disputed"
Expired = "expired"
Open = "open"
Won = "won"
Lost = "lost"
class Reason(object):
"""
Constants representing dispute reasons. Available types are:
* braintree.Dispute.Reason.CancelledRecurringTransaction
* braintree.Dispute.Reason.CreditNotProcessed
* braintree.Dispute.Reason.Duplicate
* braintree.Dispute.Reason.Fraud
* braintree.Dispute.Reason.General
* braintree.Dispute.Reason.InvalidAccount
* braintree.Dispute.Reason.NotRecognized
* braintree.Dispute.Reason.ProductNotReceived
* braintree.Dispute.Reason.ProductUnsatisfactory
* braintree.Dispute.Reason.Retrieval
* braintree.Dispute.Reason.TransactionAmountDiffers
"""
CancelledRecurringTransaction = "cancelled_recurring_transaction"
CreditNotProcessed = "credit_not_processed"
Duplicate = "duplicate"
Fraud = "fraud"
General = "general"
InvalidAccount = "invalid_account"
NotRecognized = "not_recognized"
ProductNotReceived = "product_not_received"
ProductUnsatisfactory = "product_unsatisfactory"
Retrieval = "retrieval"
TransactionAmountDiffers = "transaction_amount_differs"
class Kind(object):
"""
Constants representing dispute kinds. Available types are:
* braintree.Dispute.Kind.Chargeback
* braintree.Dispute.Kind.PreArbitration
* braintree.Dispute.Kind.Retrieval
"""
Chargeback = "chargeback"
PreArbitration = "pre_arbitration"
Retrieval = "retrieval"
@staticmethod
def accept(id):
"""
Accept a dispute, given a dispute_id.
This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>` if the provided dispute_id
is not found. ::
result = braintree.Dispute.accept("my_dispute_id")
"""
return Configuration.gateway().dispute.accept(id)
@staticmethod
def add_file_evidence(dispute_id, document_upload_id):
"""
Adds file evidence to a dispute, given a dispute_id and a document_upload_id.
This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>` if the provided dispute_id
is not found. ::
document = braintree.DocumentUpload.create({
"kind": braintree.DocumentUpload.Kind.EvidenceDocument,
"file": open("/path/to/evidence.pdf", "rb")
})
result = braintree.Dispute.add_file_evidence("my_dispute_id", document.id)
"""
return Configuration.gateway().dispute.add_file_evidence(dispute_id, document_upload_id)
@staticmethod
def add_text_evidence(id, content):
"""
Adds text evidence to a dispute, given a dispute_id.
This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>` if the provided dispute_id
is not found. ::
result = braintree.Dispute.add_text_evidence("my_dispute_id", "my_evidence")
"""
return Configuration.gateway().dispute.add_text_evidence(id, content)
@staticmethod
def finalize(id):
"""
Finalize a dispute, given a dispute_id.
This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>` if the provided dispute_id
is not found. ::
result = braintree.Dispute.finalize("my_dispute_id")
"""
return Configuration.gateway().dispute.finalize(id)
@staticmethod
def find(id):
"""
Find an dispute, given a dispute_id. This does not return a result
object. This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>` if the provided dispute_id
is not found. ::
dispute = braintree.Dispute.find("my_dispute_id")
"""
return Configuration.gateway().dispute.find(id)
@staticmethod
def remove_evidence(id, evidence_id):
"""
Remove evidence on a dispute.
This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>` if the provided dispute_id or evidence_id
is not found. ::
result = braintree.Dispute.remove_evidence("my_dispute_id", "my_evidence_id")
"""
return Configuration.gateway().dispute.remove_evidence(id, evidence_id)
@staticmethod
def search(*query):
"""
Searches for disputes, given a DisputeSearch query.
collection = braintree.Dispute.search(
braintree.DisputeSearch.id == "the_dispute_id"
)
for dispute in collection.items:
print dispute.id
"""
return Configuration.gateway().dispute.search(*query)
def __init__(self, attributes):
AttributeGetter.__init__(self, attributes)
if "amount" in attributes and self.amount is not None:
self.amount = Decimal(self.amount)
if "amount_disputed" in attributes and self.amount_disputed is not None:
self.amount_disputed = Decimal(self.amount_disputed)
if "amount_won" in attributes and self.amount_won is not None:
self.amount_won = Decimal(self.amount_won)
if "transaction" in attributes:
self.transaction_details = TransactionDetails(attributes.pop("transaction"))
self.transaction = self.transaction_details
if "evidence" in attributes and self.evidence is not None:
self.evidence = [DisputeEvidence(evidence) for evidence in self.evidence]
if "status_history" in attributes and self.status_history is not None:
self.status_history = [DisputeStatusHistory(status_history) for status_history in self.status_history]
|