def create(self, debited_funds, fees=None, secure_mode_return_url=None): pay_in = PayIn() pay_in.AuthorId = self.mangopay_user.mangopay_id pay_in.CreditedUserId = self.mangopay_wallet.mangopay_user.mangopay_id pay_in.CreditedWalletId = self.mangopay_wallet.mangopay_id pay_in.DebitedFunds = python_money_to_mangopay_money(debited_funds) if not fees: fees = PythonMoney(0, debited_funds.currency) pay_in.Fees = python_money_to_mangopay_money(fees) payment_details = PayInPaymentDetailsCard() payment_details.CardType = "CB_VISA_MASTERCARD" pay_in.PaymentDetails = payment_details execution_details = PayInExecutionDetailsDirect() execution_details.CardId = self.mangopay_card.mangopay_id execution_details.SecureModeReturnURL = secure_mode_return_url execution_details.SecureMode = "DEFAULT" pay_in.ExecutionDetails = execution_details client = get_mangopay_api_client() created_pay_in = client.payIns.Create(pay_in) self.mangopay_id = created_pay_in.Id self._update(created_pay_in)
def getJohnsPayInCardDirect(self, wallet=None): """Creates Pay-In Card Direct object return PayIn """ if wallet == None: wallet = self.getJohnsWallet() cardRegistration = CardRegistration() cardRegistration.UserId = wallet.Owners[0] cardRegistration.Currency = 'EUR' cardRegistration = self.sdk.cardRegistrations.Create(cardRegistration) cardRegistration.RegistrationData = self.getPaylineCorrectRegistartionData( cardRegistration) cardRegistration = self.sdk.cardRegistrations.Update(cardRegistration) card = self.sdk.cards.Get(cardRegistration.CardId) # create pay-in CARD DIRECT payIn = PayIn() payIn.CreditedWalletId = wallet.Id payIn.AuthorId = wallet.Owners[0] payIn.DebitedFunds = Money() payIn.DebitedFunds.Amount = 10000 payIn.DebitedFunds.Currency = 'EUR' payIn.Fees = Money() payIn.Fees.Amount = 0 payIn.Fees.Currency = 'EUR' # payment type as CARD payIn.PaymentDetails = PayInPaymentDetailsCard() payIn.PaymentDetails.CardType = card.CardType # execution type as DIRECT payIn.ExecutionDetails = PayInExecutionDetailsDirect() payIn.ExecutionDetails.CardId = card.Id payIn.ExecutionDetails.SecureModeReturnURL = 'http://test.com' return self.sdk.payIns.Create(payIn)
def create(self, secure_mode_return_url): pay_in = PayIn() pay_in.AuthorId = self.mangopay_user.mangopay_id pay_in.CreditedUserId = self.mangopay_user.mangopay_id pay_in.CreditedWalletId = self.mangopay_wallet.mangopay_id pay_in.DebitedFunds = python_money_to_mangopay_money( self.debited_funds) pay_in.Fees = python_money_to_mangopay_money(self.fees) payment_details = PayInPaymentDetailsCard() payment_details.CardType = "CB_VISA_MASTERCARD" pay_in.PaymentDetails = payment_details execution_details = PayInExecutionDetailsDirect() execution_details.CardId = self.mangopay_card.mangopay_id execution_details.SecureModeReturnURL = secure_mode_return_url execution_details.SecureMode = "DEFAULT" pay_in.ExecutionDetails = execution_details client = get_mangopay_api_client() created_pay_in = client.payIns.Create(pay_in) self.mangopay_id = created_pay_in.Id self._update(created_pay_in)
def getJohnsWalletWithMoney(self, amount=10000): """Creates static JohnsWallet (wallets belonging to John) if not created yet return Wallet """ if self._johnsWalletWithMoney == None: john = self.getJohn() wallet = Wallet() wallet.Owners = [john.Id] wallet.Currency = 'EUR' wallet.Description = 'WALLET IN EUR' wallet = self.sdk.wallets.Create(wallet) cardRegistration = CardRegistration() cardRegistration.UserId = wallet.Owners[0] cardRegistration.Currency = 'EUR' cardRegistration = self.sdk.cardRegistrations.Create( cardRegistration) cardRegistration.RegistrationData = self.getPaylineCorrectRegistartionData( cardRegistration) cardRegistration = self.sdk.cardRegistrations.Update( cardRegistration) card = self.sdk.cards.Get(cardRegistration.CardId) # create pay-in CARD DIRECT payIn = PayIn() payIn.CreditedWalletId = wallet.Id payIn.AuthorId = cardRegistration.UserId payIn.DebitedFunds = Money() payIn.DebitedFunds.Amount = amount payIn.DebitedFunds.Currency = 'EUR' payIn.Fees = Money() payIn.Fees.Amount = 0 payIn.Fees.Currency = 'EUR' # payment type as CARD payIn.PaymentDetails = PayInPaymentDetailsCard() if (card.CardType == 'CB' or card.CardType == 'VISA' or card.CardType == 'MASTERCARD' or card.CardType == CardType.CB_VISA_MASTERCARD): payIn.PaymentDetails.CardType = CardType.CB_VISA_MASTERCARD # elif (card.CardType == CardType.AMEX): # payIn.PaymentDetails.CardType = CardType.AMEX # execution type as DIRECT payIn.ExecutionDetails = PayInExecutionDetailsDirect() payIn.ExecutionDetails.CardId = card.Id payIn.ExecutionDetails.SecureModeReturnURL = 'http://test.com' # create Pay-In self.sdk.payIns.Create(payIn) self._johnsWalletWithMoney = self.sdk.wallets.Get(wallet.Id) return self._johnsWalletWithMoney
def getPayInPaymentDetailsCard(self): """return PayInPaymentDetailsCard""" if self._payInPaymentDetailsCard == None: self._payInPaymentDetailsCard = PayInPaymentDetailsCard() self._payInPaymentDetailsCard.CardType = CardType.CB_VISA_MASTERCARD return self._payInPaymentDetailsCard
def _get_payment_details(self): payment_details = PayInPaymentDetailsCard() payment_details.CardType = "CB_VISA_MASTERCARD" return payment_details