~akostajti/openstudio/openstudio

« back to all changes in this revision

Viewing changes to controllers/mollie.py

  • Committer: Edwin van de Ven
  • Date: 2017-01-31 10:18:53 UTC
  • Revision ID: edwinvandeven@home.nl-20170131101853-nssg8x7gozgn4t5c
Don't let customers initiate recurring payments from profile - invoices -- always manual
Added subscriptions to shop menu
Added default value of 0 for price in invoice.item_add_subscription

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
from general_helpers import datestr_to_python
5
5
from general_helpers import get_last_day_month
6
6
 
7
 
from openstudio import Invoice, Order, Customer, OSMail
 
7
from openstudio import Invoice, Order, Customer, CustomerSubscription, OSMail
8
8
 
9
9
from decimal import Decimal, ROUND_HALF_UP
10
10
 
203
203
                    break
204
204
 
205
205
            if valid_mandate:
206
 
                # Do a recurring payment
207
 
                recurring_type = 'recurring'
208
 
                try:
209
 
                    payment = mollie.payments.create({
210
 
                        'amount': invoice_amounts.TotalPriceVAT,
211
 
                        'customerId': mollie_customer_id,
212
 
                        'recurringType': recurring_type,  # important
213
 
                        'description': description,
214
 
                        'metadata': {
215
 
                            'invoice_id': invoice.invoice.id,
216
 
                            'customers_orders_id': 'invoice' # This lets the webhook function know it's dealing with an invoice
217
 
                        }
218
 
                    })
219
 
 
220
 
                    redirect(URL('shop', 'complete', vars={'iID':iID}))
221
 
                except Mollie.API.Error as e:
222
 
                    return 'API call failed: ' + e.message
 
206
                # Do a normal payment, probably an automatic payment failed somewhere in the process
 
207
                # and customer should pay manually now
 
208
                recurring_type = None
 
209
                # try:
 
210
                #     payment = mollie.payments.create({
 
211
                #         'amount': invoice_amounts.TotalPriceVAT,
 
212
                #         'customerId': mollie_customer_id,
 
213
                #         'recurringType': recurring_type,  # important
 
214
                #         'description': description,
 
215
                #         'metadata': {
 
216
                #             'invoice_id': invoice.invoice.id,
 
217
                #             'customers_orders_id': 'invoice' # This lets the webhook function know it's dealing with an invoice
 
218
                #         }
 
219
                #     })
 
220
                #
 
221
                #     redirect(URL('shop', 'complete', vars={'iID':iID}))
 
222
                # except Mollie.API.Error as e:
 
223
                #     return 'API call failed: ' + e.message
223
224
 
224
225
        print recurring_type
225
226
 
345
346
        payment_methods_id = 100,
346
347
    )
347
348
 
 
349
    cs = CustomerSubscription(csID)
 
350
    iID = cs.create_invoice_for_month(TODAY_LOCAL.year, TODAY_LOCAL.month)
 
351
 
348
352
    # # create invoice linked to subscription for first subscription term to know the right amount.
349
353
    # SubscriptionYear = TODAY_LOCAL.year
350
354
    # SubscriptionMonth = TODAY_LOCAL.month