summaryrefslogtreecommitdiff
path: root/addons/payment_stripe
diff options
context:
space:
mode:
authorMartin Trigaux <mat@odoo.com>2017-01-18 17:01:38 +0100
committerMartin Trigaux <mat@odoo.com>2017-01-19 13:34:58 +0100
commitebda1abec40f40580a7da1e511164f0ec77d7a62 (patch)
tree94d76b5857576086a231037c47cd26ac9bb3c49a /addons/payment_stripe
parent6169018c33705d2c591c402761e5f9ac9b36ce55 (diff)
[IMP] stripe: add receipt_email to the order
The email of the recipient must be specified in the charge. The checkout.js prompt creates a token with the email specified as the name but to get an email confirmation that the charge succeeded, the receipt_email parameter must be set. Side note: the receipt_email is not enough to send email confirmation, it must also be enabled on Stripe dashboard that generated the access tokens. Reference: https://support.stripe.com/questions/email-receipts opw-697759
Diffstat (limited to 'addons/payment_stripe')
-rw-r--r--addons/payment_stripe/controllers/main.py2
-rw-r--r--addons/payment_stripe/models/payment_transaction.py4
2 files changed, 4 insertions, 2 deletions
diff --git a/addons/payment_stripe/controllers/main.py b/addons/payment_stripe/controllers/main.py
index ceebb17e500..b4627157a9e 100644
--- a/addons/payment_stripe/controllers/main.py
+++ b/addons/payment_stripe/controllers/main.py
@@ -32,7 +32,7 @@ class StripeController(http.Controller):
tx = request.env['payment.transaction'].sudo().browse(
int(request.session.get('sale_transaction_id') or request.session.get('website_payment_tx_id', False))
)
- response = tx._create_stripe_charge(tokenid=post['tokenid'])
+ response = tx._create_stripe_charge(tokenid=post['tokenid'], email=post['email'])
_logger.info('Stripe: entering form_feedback with post data %s', pprint.pformat(response))
if response:
request.env['payment.transaction'].sudo().form_feedback(response, 'stripe')
diff --git a/addons/payment_stripe/models/payment_transaction.py b/addons/payment_stripe/models/payment_transaction.py
index 66409f0b942..98b2d0b4551 100644
--- a/addons/payment_stripe/models/payment_transaction.py
+++ b/addons/payment_stripe/models/payment_transaction.py
@@ -17,7 +17,7 @@ _logger = logging.getLogger(__name__)
class PaymentTransactionStripe(models.Model):
_inherit = 'payment.transaction'
- def _create_stripe_charge(self, acquirer_ref=None, tokenid=None):
+ def _create_stripe_charge(self, acquirer_ref=None, tokenid=None, email=None):
api_url_charge = 'https://%s/charges' % (self.acquirer_id._get_stripe_api_url())
charge_params = {
'amount': int(self.amount*100), # Stripe takes amount in cents (https://support.stripe.com/questions/which-zero-decimal-currencies-does-stripe-support)
@@ -28,6 +28,8 @@ class PaymentTransactionStripe(models.Model):
charge_params['customer'] = acquirer_ref
if tokenid:
charge_params['card'] = str(tokenid)
+ if email:
+ charge_params['receipt_email'] = email
r = requests.post(api_url_charge,
auth=(self.acquirer_id.stripe_secret_key, ''),
params=charge_params,