def _mass_pay(request, payment_paypal_dict): PAYPAL_CONFIG = PayPalConfig( API_USERNAME=settings.PAYPAL_API_USERNAME, API_PASSWORD=settings.PAYPAL_API_PASSWORD, API_SIGNATURE=settings.PAYPAL_API_SIGNATURE, API_ENVIRONMENT=settings.PAYPAL_API_ENVIRONMENT, DEBUG_LEVEL=0, ) paypal_interface = PayPalInterface(config=PAYPAL_CONFIG) payment_dict = {"RECEIVERTYPE": "EmailAddress"} for i, item in enumerate(payment_paypal_dict.items()): payment_account = (item[0])[0 : item[0].find("_")] participant = item[1] payment_credit = participant.award_credit - participant.donate_credit if payment_credit > 0: if payment_account: payment_dict["L_EMAIL%s" % i] = payment_account payment_dict["L_AMT%s" % i] = payment_credit payment_dict["L_NOTE%s" % i] = participant.research.name participant.superuser_award_dt = now() participant.payment_type = "paypal" participant.payment_account = payment_account try: resp = paypal_interface._call("MassPay", **payment_dict) if resp["ACK"] == "Success": for payment_account, participant in payment_paypal_dict.items(): participant.payment_status = True participant.payment_resp = "MassPay Success" participant.save() success(request, _(u"Payment of payment successful")) except PayPalAPIResponseError as e: error(request, _(u"%s") % e.message)