예제 #1
0
 def create_simple(self):
     pay_in_id = self.mangopay_pay_in.mangopay_id
     refund = Refund()
     refund.InitialTransactionId = pay_in_id
     refund.AuthorId = self.mangopay_user.mangopay_id
     client = get_mangopay_api_client()
     created_refund = client.payIns.CreateRefund(pay_in_id, refund)
     self.status = created_refund.Status
     self.result_code = created_refund.ResultCode
     self.mangopay_id = created_refund.Id
     self.execution_date = get_execution_date_as_datetime(refund)
     self.save()
     return self.status == "SUCCEEDED"
예제 #2
0
 def create_simple(self):
     pay_in_id = self.mangopay_pay_in.mangopay_id
     refund = Refund()
     refund.InitialTransactionId = pay_in_id
     refund.AuthorId = self.mangopay_user.mangopay_id
     client = get_mangopay_api_client()
     created_refund = client.payIns.CreateRefund(pay_in_id, refund)
     self.status = created_refund.Status
     self.result_code = created_refund.ResultCode
     self.mangopay_id = created_refund.Id
     self.execution_date = get_execution_date_as_datetime(refund)
     self.save()
     return self.status == "SUCCEEDED"
예제 #3
0
 def create_advanced(self):
     pay_in_id = self.mangopay_pay_in.mangopay_id
     refund = Refund()
     refund.InitialTransactionId = pay_in_id
     refund.AuthorId = self.mangopay_user.mangopay_id
     refund.fees = python_money_to_mangopay_money(self.fees)
     client = get_mangopay_api_client()
     created_refund = client.payIns.CreateRefund(pay_in_id, refund)
     self.status = created_refund.Status
     self.result_code = created_refund.ResultCode
     self.mangopay_id = created_refund.Id
     self.execution_date = get_execution_date_as_datetime(refund)
     self.response = json.dumps(created_refund.__dict__)
     self.save()
     return self.status == "SUCCEEDED"
예제 #4
0
    def getJohnsRefundForPayIn(self, payIn=None):
        """ Creates refund object for PayIn
        return Refund
        """
        if payIn == None:
            payIn = self.getJohnsPayInCardDirect()

        refund = Refund()
        refund.CreditedWalletId = payIn.CreditedWalletId
        refund.AuthorId = payIn.AuthorId
        refund.DebitedFunds = Money()
        refund.DebitedFunds.Amount = payIn.DebitedFunds.Amount
        refund.DebitedFunds.Currency = payIn.DebitedFunds.Currency
        refund.Fees = Money()
        refund.Fees.Amount = payIn.Fees.Amount
        refund.Fees.Currency = payIn.Fees.Currency
        return self.sdk.payIns.CreateRefund(payIn.Id, refund)
예제 #5
0
 def getJohnsRefundForTransfer(self, transfer=None):
     """Creates refund object for transfer
     return Refund
     """
     if transfer == None:
         transfer = self.getJohnsTransfer()
     refund = Refund()
     refund.DebitedWalletId = transfer.DebitedWalletId
     refund.CreditedWalletId = transfer.CreditedWalletId
     refund.AuthorId = transfer.AuthorId
     refund.DebitedFunds = Money()
     refund.DebitedFunds.Amount = transfer.DebitedFunds.Amount
     refund.DebitedFunds.Currency = transfer.DebitedFunds.Currency
     refund.Fees = Money()
     refund.Fees.Amount = transfer.Fees.Amount
     refund.Fees.Currency = transfer.Fees.Currency
     return self.sdk.transfers.CreateRefund(transfer.Id, refund)
예제 #6
0
 def getJohnsRefundForPayIn(self, payIn = None):
     """ Creates refund object for PayIn
     return Refund
     """
     if payIn == None:
         payIn = self.getJohnsPayInCardDirect()
     
     refund = Refund()
     refund.CreditedWalletId = payIn.CreditedWalletId
     refund.AuthorId = payIn.AuthorId
     refund.DebitedFunds = Money()
     refund.DebitedFunds.Amount = payIn.DebitedFunds.Amount
     refund.DebitedFunds.Currency = payIn.DebitedFunds.Currency
     refund.Fees = Money()
     refund.Fees.Amount = payIn.Fees.Amount
     refund.Fees.Currency = payIn.Fees.Currency
     return self.sdk.payIns.CreateRefund(payIn.Id, refund)
예제 #7
0
 def getJohnsRefundForTransfer(self, transfer = None):
     """Creates refund object for transfer
     return Refund
     """
     if transfer == None:
         transfer = self.getJohnsTransfer()
     refund = Refund()
     refund.DebitedWalletId = transfer.DebitedWalletId
     refund.CreditedWalletId = transfer.CreditedWalletId
     refund.AuthorId = transfer.AuthorId
     refund.DebitedFunds = Money()
     refund.DebitedFunds.Amount = transfer.DebitedFunds.Amount
     refund.DebitedFunds.Currency = transfer.DebitedFunds.Currency
     refund.Fees = Money()
     refund.Fees.Amount = transfer.Fees.Amount
     refund.Fees.Currency = transfer.Fees.Currency
     return self.sdk.transfers.CreateRefund(transfer.Id, refund)
예제 #8
0
 def test_payout_refund_callback(self, R_Get, PO_Get):
     homer, ba = self.homer, self.homer_route
     for status in ('failed', 'succeeded'):
         # Create the payout
         self.make_exchange('mango-cc', 10, 0, homer)
         e_id = record_exchange(self.db, ba, -9, 1, 0, homer, 'pre')
         assert homer.balance == 0
         homer.close(None)
         assert homer.status == 'closed'
         payout = PayOut()
         payout.Status = 'SUCCEEDED'
         payout.ResultCode = '000000'
         payout.AuthorId = homer.mangopay_user_id
         payout.Tag = str(e_id)
         PO_Get.return_value = payout
         # Create the refund
         status_up = status.upper()
         error = 'FOO' if status == 'failed' else None
         refund = Refund()
         refund.DebitedFunds = Money(900, 'EUR')
         refund.Fees = Money(-100, 'EUR')
         refund.Status = status_up
         refund.ResultCode = '000001' if error else '000000'
         refund.ResultMessage = error
         reason = refund.RefundReason = RefundReason()
         reason.RefundReasonMessage = 'BECAUSE 42'
         refund.AuthorId = homer.mangopay_user_id
         R_Get.return_value = refund
         # Call back
         qs = "EventType=PAYOUT_REFUND_" + status_up + "&RessourceId=123456790"
         r = self.callback(qs)
         assert r.code == 200, r.text
         homer = homer.refetch()
         if status == 'failed':
             assert homer.balance == 0
             assert homer.status == 'closed'
         else:
             assert homer.balance == 10
             assert homer.status == 'active'
             emails = self.get_emails()
             assert len(emails) == 1
             assert emails[0]['to'][0] == 'homer <%s>' % homer.email
             assert 'fail' in emails[0]['subject']
             assert 'BECAUSE 42' in emails[0]['text']
         homer.update_status('active')  # reset for next loop run