Exemplo n.º 1
0
 def raise_ipn_error(message):
     response.payment_trail.append(
         PaymentTrailItem(
             value=paramDict,
             status="ERROR",
             date=datetime.datetime.now(),
             method="paypal_ipn",
             id=message,
         ))
     response.save()
def mark_successful_payment(form, response, full_value, method_name, amount, currency, id, date=None, send_email=True):
    if not date:
        date = datetime.datetime.now()
    response.payment_trail.append(PaymentTrailItem(value=full_value, status="SUCCESS", date=date, date_created=date, date_modified=date, method=method_name, id=id))
    response.payment_status_detail.append(PaymentStatusDetailItem(amount=str(amount), currency=currency, date=date, date_created=date, date_modified=date, method=method_name, id=id))
    response.amount_paid = str(float(response.amount_paid or 0) + float(amount))
    update_response_paid_status(response)
    if form.formOptions.confirmationEmailInfo and send_email:
        email_sent = send_confirmation_email(response, form.formOptions.confirmationEmailInfo)
    return response.paid
Exemplo n.º 3
0
def mark_error_payment(response, message, method_name, full_value):
    response.payment_trail.append(
        PaymentTrailItem(
            value=full_value,
            status="ERROR",
            date=datetime.datetime.now(),
            date_created=date,
            date_modified=date,
            method=method_name,
            id=message,
        ))
    response.save()
    raise Exception("IPN ERROR: " + message)
Exemplo n.º 4
0
def mark_successful_payment(
    form,
    response,
    full_value,
    method_name,
    amount,
    currency,
    id,
    date=None,
    send_email=True,
    notes=None,
    email_template_id=None,
):
    if not date:
        date = datetime.datetime.now()
    payment_trail_kwargs = dict(
        value=full_value,
        status="SUCCESS",
        date=date,
        date_created=date,
        date_modified=date,
        method=method_name,
        id=id,
    )
    payment_status_detail_kwargs = dict(
        amount=str(amount),
        currency=currency,
        date=date,
        date_created=date,
        date_modified=date,
        method=method_name,
        id=id,
    )
    if notes is not None:
        payment_trail_kwargs = dict(payment_trail_kwargs, notes=notes)
        payment_status_detail_kwargs = dict(payment_status_detail_kwargs,
                                            notes=notes)
    response.payment_trail.append(PaymentTrailItem(**payment_trail_kwargs))
    response.payment_status_detail.append(
        PaymentStatusDetailItem(**payment_status_detail_kwargs))

    amount_paid = float(response.amount_paid or 0) + float(amount)
    response.amount_paid_cents = int(100 * amount_paid)
    response.amount_paid = str(amount_paid)
    update_response_paid_status(response)
    if send_email:
        send_email_receipt(response, form.formOptions, email_template_id)
    return response.paid
Exemplo n.º 5
0
        if isinstance(o, Decimal):
            return float(o)
        return super(DecimalEncoder, self).default(o)


for response in query['Items']:
    response = json.loads(json.dumps(response, cls=DecimalEncoder))
    res = Response(
        date_created=dateutil.parser.parse(response["date_created"]),
        date_modified=dateutil.parser.parse(response["date_last_modified"]),
        form=ObjectId(formIdNew),
        paymentInfo=response["paymentInfo"],
        value=response["value"],
        paid=response["PAID"],
        payment_trail=[
            PaymentTrailItem(date=dateutil.parser.parse(i["date"]),
                             value=i["value"],
                             status=i["status"],
                             id=i["value"]["txn_id"],
                             method="paypal_ipn")
            for i in response.get("IPN_HISTORY", [])
        ] or [],
        payment_status_detail=[
            PaymentStatusDetailItem(date=dateutil.parser.parse(i["date"]),
                                    amount=i["amount"],
                                    currency=i["currency"],
                                    method="paypal_ipn" if i["method"]
                                    == "paypal" else i["method"])
            for i in response.get("PAYMENT_HISTORY", [])
        ] or [])
    res.save()
Exemplo n.º 6
0
         "method": "paypal",
     } for i in response["IPN_HISTORY"]]
 PAYMENT_HISTORY = response.get("PAYMENT_HISTORY", [])
 IPN_HISTORY = response.get("IPN_HISTORY", [])
 res = Response(
     date_created=dateutil.parser.parse(response["date_created"]),
     date_modified=dateutil.parser.parse(response["date_last_modified"]),
     form=ObjectId(formIdNew),
     paymentInfo=response["paymentInfo"],
     value=response["value"],
     paid=response["PAID"],
     payment_trail=[
         PaymentTrailItem(
             date=dateutil.parser.parse(i["date"]),
             value=i["value"],
             status=i["status"],
             id=i["value"]["txn_id"],
             method="paypal_ipn",
         ) if "txn_id" in i["value"] else PaymentTrailItem(
             date=dateutil.parser.parse(i["date"]),
             value=i["value"],
             status=i["status"],
             id=i["value"]["order_id"],
             method="ccavenue",
         )
         # todo: do we need to handle manual payments from v1?
         for i in response.get("IPN_HISTORY", [])
     ] or [],
     payment_status_detail=[
         PaymentStatusDetailItem(
             date=dateutil.parser.parse(i["date"]),