You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would enhance the administrative experience tremendously to create a better paper trail between payments and associated documents if the payment details were linked to the activity log on the reference document.
For example, on the stripe integration (stripe_settings.py), the following would do the trick:
defcreate_charge_on_stripe(self):
importstripetry:
charge=stripe.Charge.create(
amount=cint(flt(self.data.amount) *100),
currency=self.data.currency,
source=self.data.stripe_token_id,
description=self.data.description,
receipt_email=self.data.payer_email,
)
ifcharge.captured==True:
self.integration_request.db_set(
"status", "Completed", update_modified=False
)
self.flags.status_changed_to="Completed"# log the payment URL and receipt URL to the documentpayment_amount=frappe.utils.fmt_money(
charge.amount/100, currency=charge.currency
)
payment_url="https://dashboard.stripe.com/payments/"+charge.idreceipt_url=charge.receipt_urlcomment= (
f"<strong>Payment of {payment_amount} received via Stripe</strong><br>"f"<a target='_blank' rel='noopener noreferrer' href='{payment_url}'>View the Payment</a><br>"f"<a target='_blank' rel='noopener noreferrer' href='{receipt_url}'>View the Receipt</a>"
)
doc=frappe.get_doc(
self.data.reference_doctype, self.data.reference_docname
)
doc.add_comment("Info", comment)
else:
frappe.log_error(charge.failure_message, "Stripe Payment not completed")
exceptException:
frappe.log_error(frappe.get_traceback())
returnself.finalize_request()
As you can see, this change:
Extends the if charge.captured == True: conditional action in the create_charge_on_stripe function.
Evaluates the gateway-specific payment url and receipt url.
Combines the payment_amount and links into a comment text.
Saves the comment as type "Info" on the reference document.
The result is that a comment is logged in the activity feed on the document, as follows:
I suggest that this approach should be extended to all gateways so it could be incorporated into the app.
The text was updated successfully, but these errors were encountered:
It would enhance the administrative experience tremendously to create a better paper trail between payments and associated documents if the payment details were linked to the activity log on the reference document.
For example, on the stripe integration (
stripe_settings.py
), the following would do the trick:As you can see, this change:
if charge.captured == True:
conditional action in thecreate_charge_on_stripe
function.I suggest that this approach should be extended to all gateways so it could be incorporated into the app.
The text was updated successfully, but these errors were encountered: