[django-oscar] Re: Add a new payment gateway to Oscar

2024-02-09 Thread Veronica Jones
I am currently trying to integrate Stripe into Django-Oscar but feel that 
this code might be a little outdated now. Would any of y'all suggest an 
updated version of this code?

I am trying to figure it out myself, but am confused on how to split up the 
Stripe Payment 'form' from the submit button, while keeping whatever data 
was entered into the Stripe Payment 'form'. I put quotes around form 
because I am not referring to a Django form, but the Stripe embedded form.

I appreciate any help.

On Wednesday, August 5, 2015 at 11:33:34 PM UTC-5 Joseph Gallagher wrote:

> Hi Loi,
>
> So I've used Stripe  for credit card integration. 
> It's not exactly obvious, and I owe everything to google but, once you've 
> gone to Stripe and set up an account & installed Stripe in your virtualenv, 
> what I've posted below should take care of the logic. You'll need to grab 
> the test keys and set them in settings.py like so:
>
> STRIPE_SECRET_KEY = "sk_test_."
> STRIPE_PUBLISHABLE_KEY = "pk_test_."
> STRIPE_CURRENCY = "USD"
>
>
> Set these in your local checkout apps' __init__.py:
>
> PAYMENT_EVENT_PURCHASE = 'Purchase'
> PAYMENT_METHOD_STRIPE = 'Stripe'
> STRIPE_EMAIL = 'stripeEmail'
> STRIPE_TOKEN = 'stripeToken'
>
>
> You will need to override the PaymentDetailsView to set the source and 
> handle payment, as per the oscar docs:
>
> from django.conf import settings
> from oscar.core.loading import get_model
> from django.utils.decorators import method_decorator
> from django.views.decorators.csrf import csrf_exempt
>
> from oscar.apps.checkout.views import PaymentDetailsView as 
> CorePaymentDetailsView
> from facade import Facade
>
> from . import PAYMENT_METHOD_STRIPE, PAYMENT_EVENT_PURCHASE, STRIPE_EMAIL, 
> STRIPE_TOKEN
>
> import forms
>
> SourceType = get_model('payment', 'SourceType')
> Source = get_model('payment', 'Source')
>
>
> class PaymentDetailsView(CorePaymentDetailsView):
>
> @method_decorator(csrf_exempt)
> def dispatch(self, request, *args, **kwargs):
> return super(PaymentDetailsView, self).dispatch(request, *args, 
> **kwargs)
>
> def get_context_data(self, **kwargs):
> ctx = super(PaymentDetailsView, self).get_context_data(**kwargs)
> if self.preview:
> ctx['stripe_token_form'] = 
> forms.StripeTokenForm(self.request.POST)
> ctx['order_total_incl_tax_cents'] = (
> ctx['order_total'].incl_tax * 100
> ).to_integral_value()
> else:
> ctx['stripe_publishable_key'] = settings.STRIPE_PUBLISHABLE_KEY
> return ctx
>
> def handle_payment(self, order_number, total, **kwargs):
> stripe_ref = Facade().charge(
> order_number,
> total,
> card=self.request.POST[STRIPE_TOKEN],
> description=self.payment_description(order_number, total, 
> **kwargs),
> metadata=self.payment_metadata(order_number, total, **kwargs))
>
> source_type, __ = 
> SourceType.objects.get_or_create(name=PAYMENT_METHOD_STRIPE)
> source = Source(
> source_type=source_type,
> currency=settings.STRIPE_CURRENCY,
> amount_allocated=total.incl_tax,
> amount_debited=total.incl_tax,
> reference=stripe_ref)
> self.add_payment_source(source)
>
> self.add_payment_event(PAYMENT_EVENT_PURCHASE, total.incl_tax)
>
> def payment_description(self, order_number, total, **kwargs):
> return self.request.POST[STRIPE_EMAIL]
>
> def payment_metadata(self, order_number, total, **kwargs):
> return {'order_number': order_number}
>
>
> You can then create a payment facade in your local /apps/checkout. You 
> won't be overriding an Oscar facade.py, since that doesn't exist in the 
> checkout app. Something like this:
>
> from django.conf import settings
> from oscar.apps.payment.exceptions import UnableToTakePayment, 
> InvalidGatewayRequestError
>
> import stripe
>
>
> class Facade(object):
> def __init__(self):
> stripe.api_key = settings.STRIPE_SECRET_KEY
>
> @staticmethod
> def get_friendly_decline_message(error):
> return 'The transaction was declined by your bank - please check your 
> bankcard details and try again'
>
> @staticmethod
> def get_friendly_error_message(error):
> return 'An error occurred when communicating with the payment 
> gateway.'
>
> def charge(self,
> order_number,
> total,
> card,
> currency=settings.STRIPE_CURRENCY,
> description=None,
> metadata=None,
> **kwargs):
> try:
> return stripe.Charge.create(
> amount=(total.incl_tax * 100).to_integral_value(),
> currency=currency,
> card=card,
> description=description,
> metadata=(metadata or {'order_number': order_number}),
> **kwargs).id
> 

Re: [django-oscar] Re: Add a new payment gateway to Oscar

2023-01-31 Thread Data Tips
anyone know how implement webpay ?

El viernes, 13 de enero de 2023 a la(s) 01:11:20 UTC-3, 
nicolas.cast...@gmail.com escribió:

> any one here can help me whit WEBPAY ?   its a chilean company,  i need to 
> implement it in django oscar please <3
>
> El domingo, 7 de junio de 2020 a las 14:34:34 UTC-4, dabut...@gmail.com 
> escribió:
>
>> Maybe check this out: 
>> https://github.com/django-oscar/django-oscar-stripe
>>
>> I’ve never used it but it might help. 
>>
>> On Sun, Jun 7, 2020 at 9:34 AM Pim Doodkorte  wrote:
>>
>>> Does anyone know if and how it is possible to add another payment way, 
>>> like Ideal? This should be possible with Stripe. Does anyone have any 
>>> experiecen with this and can help me out? 
>>> P.s. the above method works good for me, thanks!
>>>
>>> Op woensdag 5 augustus 2015 06:03:13 UTC+2 schreef Loi Nguyen:

 Hi, I want to create a new payment gateway ingrate to Oscar. It use 
 credit card to pay for order. 
 Can you give me some document or suggest me some payment gateway i 
 should follow to create a new payment gateway.
 Thanks a lot.

>>>
 -- 
>>> https://github.com/django-oscar/django-oscar
>>> http://django-oscar.readthedocs.org/en/latest/
>>> https://twitter.com/django_oscar
>>> --- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "django-oscar" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django-oscar...@googlegroups.com.
>>> To view this discussion on the web, visit 
>>> https://groups.google.com/d/msgid/django-oscar/c5c47623-e844-48a6-ab88-c067c7cb9cbfo%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>> -- 
>> Thank you!
>>
>> Daniel Butler
>>
>

-- 
https://github.com/django-oscar/django-oscar
http://django-oscar.readthedocs.org/en/latest/
--- 
You received this message because you are subscribed to the Google Groups 
"django-oscar" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-oscar+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/django-oscar/399c47d1-5a42-40fc-81d1-8dea6f0a480dn%40googlegroups.com.


Re: [django-oscar] Re: Add a new payment gateway to Oscar

2023-01-12 Thread Nico Silva
any one here can help me whit WEBPAY ?   its a chilean company,  i need to 
implement it in django oscar please <3

El domingo, 7 de junio de 2020 a las 14:34:34 UTC-4, dabut...@gmail.com 
escribió:

> Maybe check this out: 
> https://github.com/django-oscar/django-oscar-stripe
>
> I’ve never used it but it might help. 
>
> On Sun, Jun 7, 2020 at 9:34 AM Pim Doodkorte  wrote:
>
>> Does anyone know if and how it is possible to add another payment way, 
>> like Ideal? This should be possible with Stripe. Does anyone have any 
>> experiecen with this and can help me out? 
>> P.s. the above method works good for me, thanks!
>>
>> Op woensdag 5 augustus 2015 06:03:13 UTC+2 schreef Loi Nguyen:
>>>
>>> Hi, I want to create a new payment gateway ingrate to Oscar. It use 
>>> credit card to pay for order. 
>>> Can you give me some document or suggest me some payment gateway i 
>>> should follow to create a new payment gateway.
>>> Thanks a lot.
>>>
>>
>>> -- 
>> https://github.com/django-oscar/django-oscar
>> http://django-oscar.readthedocs.org/en/latest/
>> https://twitter.com/django_oscar
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "django-oscar" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-oscar...@googlegroups.com.
>> To view this discussion on the web, visit 
>> https://groups.google.com/d/msgid/django-oscar/c5c47623-e844-48a6-ab88-c067c7cb9cbfo%40googlegroups.com
>>  
>> 
>> .
>>
> -- 
> Thank you!
>
> Daniel Butler
>

-- 
https://github.com/django-oscar/django-oscar
http://django-oscar.readthedocs.org/en/latest/
--- 
You received this message because you are subscribed to the Google Groups 
"django-oscar" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-oscar+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/django-oscar/39faa01a-3d6c-4bbc-8d9d-ed0dc764a77fn%40googlegroups.com.


Re: [django-oscar] Re: Add a new payment gateway to Oscar

2020-06-07 Thread Daniel Butler
Maybe check this out:
https://github.com/django-oscar/django-oscar-stripe

I’ve never used it but it might help.

On Sun, Jun 7, 2020 at 9:34 AM Pim Doodkorte  wrote:

> Does anyone know if and how it is possible to add another payment way,
> like Ideal? This should be possible with Stripe. Does anyone have any
> experiecen with this and can help me out?
> P.s. the above method works good for me, thanks!
>
> Op woensdag 5 augustus 2015 06:03:13 UTC+2 schreef Loi Nguyen:
>>
>> Hi, I want to create a new payment gateway ingrate to Oscar. It use
>> credit card to pay for order.
>> Can you give me some document or suggest me some payment gateway i should
>> follow to create a new payment gateway.
>> Thanks a lot.
>>
>
>> --
> https://github.com/django-oscar/django-oscar
> http://django-oscar.readthedocs.org/en/latest/
> https://twitter.com/django_oscar
> ---
> You received this message because you are subscribed to the Google Groups
> "django-oscar" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-oscar+unsubscr...@googlegroups.com.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/django-oscar/c5c47623-e844-48a6-ab88-c067c7cb9cbfo%40googlegroups.com
> 
> .
>
-- 
Thank you!

Daniel Butler

-- 
https://github.com/django-oscar/django-oscar
http://django-oscar.readthedocs.org/en/latest/
https://twitter.com/django_oscar
--- 
You received this message because you are subscribed to the Google Groups 
"django-oscar" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-oscar+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/django-oscar/CADbhD6bWtehcB%3DRb0KiqbC-XP_X3sjZCPphQTc7HMhkZDyz8nQ%40mail.gmail.com.


[django-oscar] Re: Add a new payment gateway to Oscar

2020-06-07 Thread Pim Doodkorte
Does anyone know if and how it is possible to add another payment way, like 
Ideal? This should be possible with Stripe. Does anyone have any experiecen 
with this and can help me out? 
P.s. the above method works good for me, thanks!

Op woensdag 5 augustus 2015 06:03:13 UTC+2 schreef Loi Nguyen:
>
> Hi, I want to create a new payment gateway ingrate to Oscar. It use credit 
> card to pay for order. 
> Can you give me some document or suggest me some payment gateway i should 
> follow to create a new payment gateway.
> Thanks a lot.
>

-- 
https://github.com/django-oscar/django-oscar
http://django-oscar.readthedocs.org/en/latest/
https://twitter.com/django_oscar
--- 
You received this message because you are subscribed to the Google Groups 
"django-oscar" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-oscar+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/django-oscar/c5c47623-e844-48a6-ab88-c067c7cb9cbfo%40googlegroups.com.


[django-oscar] Re: Add a new payment gateway to Oscar

2018-12-17 Thread WELCH THE IFFY
First, I want to say a big thank you for this wonderful resource. i keep 
getting this error. perhaps i could get some help

[image: Screenshot (170).png]


On Wednesday, August 5, 2015 at 5:03:13 AM UTC+1, Loi Nguyen wrote:
>
> Hi, I want to create a new payment gateway ingrate to Oscar. It use credit 
> card to pay for order. 
> Can you give me some document or suggest me some payment gateway i should 
> follow to create a new payment gateway.
> Thanks a lot.
>

-- 
https://github.com/django-oscar/django-oscar
http://django-oscar.readthedocs.org/en/latest/
https://twitter.com/django_oscar
--- 
You received this message because you are subscribed to the Google Groups 
"django-oscar" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-oscar+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-oscar.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/django-oscar/ccc2071d-28f8-427e-a836-05ddf27263f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[django-oscar] Re: Add a new payment gateway to Oscar

2018-12-17 Thread Dyoser




Hi Joseph , thanks for the step by step instructionreally helpful

But i've a question about where to put what in what folder.
I've a shop called tpwshop do i need to create an apps folder inside my 
shop folder and also a checkout one?

Is that the way to extend Oscar's payment?

If you could clarify this it would be an enormous help.


Here is a pic of my actual folder structure

[image: oscar_folders.png]

Thanks!


El jueves, 6 de agosto de 2015, 5:33:34 (UTC+1), Joseph Gallagher escribió:
>
> Hi Loi,
>
> So I've used Stripe  for credit card integration. 
> It's not exactly obvious, and I owe everything to google but, once you've 
> gone to Stripe and set up an account & installed Stripe in your virtualenv, 
> what I've posted below should take care of the logic. You'll need to grab 
> the test keys and set them in settings.py like so:
>
> STRIPE_SECRET_KEY = "sk_test_."
> STRIPE_PUBLISHABLE_KEY = "pk_test_."
> STRIPE_CURRENCY = "USD"
>
>
> Set these in your local checkout apps' __init__.py:
>
> PAYMENT_EVENT_PURCHASE = 'Purchase'
> PAYMENT_METHOD_STRIPE = 'Stripe'
> STRIPE_EMAIL = 'stripeEmail'
> STRIPE_TOKEN = 'stripeToken'
>
>
> You will need to override the PaymentDetailsView to set the source and 
> handle payment, as per the oscar docs:
>
> from django.conf import settings
> from oscar.core.loading import get_model
> from django.utils.decorators import method_decorator
> from django.views.decorators.csrf import csrf_exempt
>
> from oscar.apps.checkout.views import PaymentDetailsView as 
> CorePaymentDetailsView
> from facade import Facade
>
> from . import PAYMENT_METHOD_STRIPE, PAYMENT_EVENT_PURCHASE, STRIPE_EMAIL, 
> STRIPE_TOKEN
>
> import forms
>
> SourceType = get_model('payment', 'SourceType')
> Source = get_model('payment', 'Source')
>
>
> class PaymentDetailsView(CorePaymentDetailsView):
>
> @method_decorator(csrf_exempt)
> def dispatch(self, request, *args, **kwargs):
> return super(PaymentDetailsView, self).dispatch(request, *args, 
> **kwargs)
>
> def get_context_data(self, **kwargs):
> ctx = super(PaymentDetailsView, self).get_context_data(**kwargs)
> if self.preview:
> ctx['stripe_token_form'] = 
> forms.StripeTokenForm(self.request.POST)
> ctx['order_total_incl_tax_cents'] = (
> ctx['order_total'].incl_tax * 100
> ).to_integral_value()
> else:
> ctx['stripe_publishable_key'] = settings.STRIPE_PUBLISHABLE_KEY
> return ctx
>
> def handle_payment(self, order_number, total, **kwargs):
> stripe_ref = Facade().charge(
> order_number,
> total,
> card=self.request.POST[STRIPE_TOKEN],
> description=self.payment_description(order_number, total, 
> **kwargs),
> metadata=self.payment_metadata(order_number, total, **kwargs))
>
> source_type, __ = 
> SourceType.objects.get_or_create(name=PAYMENT_METHOD_STRIPE)
> source = Source(
> source_type=source_type,
> currency=settings.STRIPE_CURRENCY,
> amount_allocated=total.incl_tax,
> amount_debited=total.incl_tax,
> reference=stripe_ref)
> self.add_payment_source(source)
>
> self.add_payment_event(PAYMENT_EVENT_PURCHASE, total.incl_tax)
>
> def payment_description(self, order_number, total, **kwargs):
> return self.request.POST[STRIPE_EMAIL]
>
> def payment_metadata(self, order_number, total, **kwargs):
> return {'order_number': order_number}
>
>
> You can then create a payment facade in your local /apps/checkout. You 
> won't be overriding an Oscar facade.py, since that doesn't exist in the 
> checkout app. Something like this:
>
> from django.conf import settings
> from oscar.apps.payment.exceptions import UnableToTakePayment, 
> InvalidGatewayRequestError
>
> import stripe
>
>
> class Facade(object):
> def __init__(self):
> stripe.api_key = settings.STRIPE_SECRET_KEY
>
> @staticmethod
> def get_friendly_decline_message(error):
> return 'The transaction was declined by your bank - please check your 
> bankcard details and try again'
>
> @staticmethod
> def get_friendly_error_message(error):
> return 'An error occurred when communicating with the payment 
> gateway.'
>
> def charge(self,
> order_number,
> total,
> card,
> currency=settings.STRIPE_CURRENCY,
> description=None,
> metadata=None,
> **kwargs):
> try:
> return stripe.Charge.create(
> amount=(total.incl_tax * 100).to_integral_value(),
> currency=currency,
> card=card,
> description=description,
> metadata=(metadata or {'order_number': order_number}),
> **kwargs).id
> except stripe.CardError, e:
> raise UnableToTakePayment

[django-oscar] Re: Add a new payment gateway to Oscar

2018-11-09 Thread SammyJ
Hi, this error occurs when your payment form is invalid.Have you set up 
stripe in the checkout app?

Maybe you could check out this Solution 

 on 
stackoverflow, look at the first answer. I guess it might help you solve 
your issue.

On Sunday, November 4, 2018 at 9:29:57 AM UTC+5:30, A G wrote:
>
> Hello! I am new in Django. Thank you for your solution. But i have a 
> problem - After payement on the preview page, when order must be confirmed, 
> i got error message
> A problem occurred while processing payment for this order - no payment 
> has been taken. Please contact customer services if this problem persists
>
> Or its becouse payemtns runs in test mode? But how to test it then?
> Can anybody help?
>
> Thanks in advance!
>
> четверг, 5 января 2017 г., 6:00:22 UTC+1 пользователь Andrew Edwards 
> написал:
>>
>> Awesome post Joseph!
>>
>> I just wanted to update this for as of this post's creation time. I had 
>> to modify the end of the Facade class with:
>>
>> except stripe.error.CardError as e:
>> raise UnableToTakePayment(self.get_friendly_decline_message(e))
>> except stripe.error.StripeError as e:
>> raise InvalidGatewayRequestError(self.get_friendly_error_message(e))
>>
>>
>> instead of:
>>
>> except stripe.CardError, e:
>> raise UnableToTakePayment(self.get_friendly_decline_message(e))
>> except stripe.StripeError, e:
>> raise InvalidGatewayRequestError(self.get_friendly_error_message(e))
>>
>>
>> ***If you don't follow this next step, the transaction will never 
>> complete.***
>> I also had to add to my preview template in the block 'hiddenforms':
>>
>> 
>> {% block hiddenforms %}
>> {{ stripe_token_form }}
>> {% endblock %}
>> 
>>
>> This allowed the stripe payment details to persist to the preview page 
>> and so when the user clicks the place order button the payment is actually 
>> taken from the card.
>>
>> One other thing I had to do was modify the else statement of the 
>> get_context_data method in your local PaymentDetailsView class such that 
>> the total price appears in the 'Pay' button of the Stripe form when you are 
>> entering payment details on the payment details page:
>>
>> def get_context_data(self, **kwargs):
>> ctx = super(PaymentDetailsView, self).get_context_data(**kwargs)
>> if self.preview:
>> ctx['stripe_token_form'] = forms.StripeTokenForm(self.request.POST)
>> ctx['order_total_incl_tax_cents'] = (
>> ctx['order_total'].incl_tax * 100
>> ).to_integral_value()
>> else:
>> ctx['order_total_incl_tax_cents'] = (
>> ctx['order_total'].incl_tax * 100
>> ).to_integral_value()
>> ctx['stripe_publishable_key'] = settings.STRIPE_PUBLISHABLE_KEY
>> return ctx
>>
>>
>> Hope this helps someone!
>>
>>

-- 
https://github.com/django-oscar/django-oscar
http://django-oscar.readthedocs.org/en/latest/
https://twitter.com/django_oscar
--- 
You received this message because you are subscribed to the Google Groups 
"django-oscar" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-oscar+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-oscar.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/django-oscar/57d2a48a-d91c-4f8b-bc95-4896e948d9e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[django-oscar] Re: Add a new payment gateway to Oscar

2018-11-03 Thread A G
Hello! I am new in Django. Thank you for your solution. But i have a 
problem - After payement on the preview page, when order must be confirmed, 
i got error message
A problem occurred while processing payment for this order - no payment has 
been taken. Please contact customer services if this problem persists

Or its becouse payemtns runs in test mode? But how to test it then?
Can anybody help?

Thanks in advance!

четверг, 5 января 2017 г., 6:00:22 UTC+1 пользователь Andrew Edwards 
написал:
>
> Awesome post Joseph!
>
> I just wanted to update this for as of this post's creation time. I had to 
> modify the end of the Facade class with:
>
> except stripe.error.CardError as e:
> raise UnableToTakePayment(self.get_friendly_decline_message(e))
> except stripe.error.StripeError as e:
> raise InvalidGatewayRequestError(self.get_friendly_error_message(e))
>
>
> instead of:
>
> except stripe.CardError, e:
> raise UnableToTakePayment(self.get_friendly_decline_message(e))
> except stripe.StripeError, e:
> raise InvalidGatewayRequestError(self.get_friendly_error_message(e))
>
>
> ***If you don't follow this next step, the transaction will never 
> complete.***
> I also had to add to my preview template in the block 'hiddenforms':
>
> 
> {% block hiddenforms %}
> {{ stripe_token_form }}
> {% endblock %}
> 
>
> This allowed the stripe payment details to persist to the preview page and 
> so when the user clicks the place order button the payment is actually 
> taken from the card.
>
> One other thing I had to do was modify the else statement of the 
> get_context_data method in your local PaymentDetailsView class such that 
> the total price appears in the 'Pay' button of the Stripe form when you are 
> entering payment details on the payment details page:
>
> def get_context_data(self, **kwargs):
> ctx = super(PaymentDetailsView, self).get_context_data(**kwargs)
> if self.preview:
> ctx['stripe_token_form'] = forms.StripeTokenForm(self.request.POST)
> ctx['order_total_incl_tax_cents'] = (
> ctx['order_total'].incl_tax * 100
> ).to_integral_value()
> else:
> ctx['order_total_incl_tax_cents'] = (
> ctx['order_total'].incl_tax * 100
> ).to_integral_value()
> ctx['stripe_publishable_key'] = settings.STRIPE_PUBLISHABLE_KEY
> return ctx
>
>
> Hope this helps someone!
>
>

-- 
https://github.com/django-oscar/django-oscar
http://django-oscar.readthedocs.org/en/latest/
https://twitter.com/django_oscar
--- 
You received this message because you are subscribed to the Google Groups 
"django-oscar" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-oscar+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-oscar.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/django-oscar/ba98befe-a279-4f21-9067-37d2dcc84754%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[django-oscar] Re: Add a new payment gateway to Oscar

2018-10-09 Thread Calvin Kcc
I have forked the checkout app and created all these files. But for some 
reason it keep saying there is no module named "facade" when I have 
facade.py in my checkout directory.

On Wednesday, August 5, 2015 at 12:03:13 AM UTC-4, Loi Nguyen wrote:
>
> Hi, I want to create a new payment gateway ingrate to Oscar. It use credit 
> card to pay for order. 
> Can you give me some document or suggest me some payment gateway i should 
> follow to create a new payment gateway.
> Thanks a lot.
>

-- 
https://github.com/django-oscar/django-oscar
http://django-oscar.readthedocs.org/en/latest/
https://twitter.com/django_oscar
--- 
You received this message because you are subscribed to the Google Groups 
"django-oscar" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-oscar+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-oscar.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/django-oscar/cc21ff5e-54a0-41ce-aaba-9b721478f39b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[django-oscar] Re: Add a new payment gateway to Oscar

2018-04-23 Thread Ajibola L' Don jibson
It did help me a lot .. thanks 

On Thursday, January 5, 2017 at 5:00:22 AM UTC, Andrew Edwards wrote:
>
> Awesome post Joseph!
>
> I just wanted to update this for as of this post's creation time. I had to 
> modify the end of the Facade class with:
> -
> Hope this helps someone!
>
>

-- 
https://github.com/tangentlabs/django-oscar
http://django-oscar.readthedocs.org/en/latest/
https://twitter.com/django_oscar
--- 
You received this message because you are subscribed to the Google Groups 
"django-oscar" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-oscar+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-oscar.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/django-oscar/73399047-d82f-4bf0-b0f1-e52995a89ead%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[django-oscar] Re: Add a new payment gateway to Oscar

2018-04-23 Thread Ajibola L' Don jibson
Thanks a lot for this a life saver .. i really appreciate this ... saved me 
a lot of troubles

-- 
https://github.com/tangentlabs/django-oscar
http://django-oscar.readthedocs.org/en/latest/
https://twitter.com/django_oscar
--- 
You received this message because you are subscribed to the Google Groups 
"django-oscar" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-oscar+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-oscar.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/django-oscar/5a8c723c-5df3-47aa-9222-aafa5ed867b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[django-oscar] Re: Add a new payment gateway to Oscar

2018-04-12 Thread Ryota Abe
Thank you, Joseph and Andrew!
I'm Japanese university student and try django oscar with stripe.

I refer to your advise but i can't send the data to stripe dashboard...

2017年1月5日木曜日 14時00分22秒 UTC+9 Andrew Edwards:
>
> Awesome post Joseph!
>
> I just wanted to update this for as of this post's creation time. I had to 
> modify the end of the Facade class with:
>
> except stripe.error.CardError as e:
> raise UnableToTakePayment(self.get_friendly_decline_message(e))
> except stripe.error.StripeError as e:
> raise InvalidGatewayRequestError(self.get_friendly_error_message(e))
>
>
> instead of:
>
> except stripe.CardError, e:
> raise UnableToTakePayment(self.get_friendly_decline_message(e))
> except stripe.StripeError, e:
> raise InvalidGatewayRequestError(self.get_friendly_error_message(e))
>
>
> ***If you don't follow this next step, the transaction will never 
> complete.***
> I also had to add to my preview template in the block 'hiddenforms':
>
> 
> {% block hiddenforms %}
> {{ stripe_token_form }}
> {% endblock %}
> 
>
> This allowed the stripe payment details to persist to the preview page and 
> so when the user clicks the place order button the payment is actually 
> taken from the card.
>
> One other thing I had to do was modify the else statement of the 
> get_context_data method in your local PaymentDetailsView class such that 
> the total price appears in the 'Pay' button of the Stripe form when you are 
> entering payment details on the payment details page:
>
> def get_context_data(self, **kwargs):
> ctx = super(PaymentDetailsView, self).get_context_data(**kwargs)
> if self.preview:
> ctx['stripe_token_form'] = forms.StripeTokenForm(self.request.POST)
> ctx['order_total_incl_tax_cents'] = (
> ctx['order_total'].incl_tax * 100
> ).to_integral_value()
> else:
> ctx['order_total_incl_tax_cents'] = (
> ctx['order_total'].incl_tax * 100
> ).to_integral_value()
> ctx['stripe_publishable_key'] = settings.STRIPE_PUBLISHABLE_KEY
> return ctx
>
>
> Hope this helps someone!
>
>

-- 
https://github.com/tangentlabs/django-oscar
http://django-oscar.readthedocs.org/en/latest/
https://twitter.com/django_oscar
--- 
You received this message because you are subscribed to the Google Groups 
"django-oscar" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-oscar+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-oscar.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/django-oscar/b2deb68b-181d-4e61-a71d-5f1ccb03481f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[django-oscar] Re: Add a new payment gateway to Oscar

2017-01-04 Thread Andrew Edwards
Awesome post Joseph!

I just wanted to update this for as of this post's creation time. I had to 
modify the end of the Facade class with:

except stripe.error.CardError as e:
raise UnableToTakePayment(self.get_friendly_decline_message(e))
except stripe.error.StripeError as e:
raise InvalidGatewayRequestError(self.get_friendly_error_message(e))


instead of:

except stripe.CardError, e:
raise UnableToTakePayment(self.get_friendly_decline_message(e))
except stripe.StripeError, e:
raise InvalidGatewayRequestError(self.get_friendly_error_message(e))


***If you don't follow this next step, the transaction will never 
complete.***
I also had to add to my preview template in the block 'hiddenforms':


{% block hiddenforms %}
{{ stripe_token_form }}
{% endblock %}


This allowed the stripe payment details to persist to the preview page and 
so when the user clicks the place order button the payment is actually 
taken from the card.

One other thing I had to do was modify the else statement of the 
get_context_data method in your local PaymentDetailsView class such that 
the total price appears in the 'Pay' button of the Stripe form when you are 
entering payment details on the payment details page:

def get_context_data(self, **kwargs):
ctx = super(PaymentDetailsView, self).get_context_data(**kwargs)
if self.preview:
ctx['stripe_token_form'] = forms.StripeTokenForm(self.request.POST)
ctx['order_total_incl_tax_cents'] = (
ctx['order_total'].incl_tax * 100
).to_integral_value()
else:
ctx['order_total_incl_tax_cents'] = (
ctx['order_total'].incl_tax * 100
).to_integral_value()
ctx['stripe_publishable_key'] = settings.STRIPE_PUBLISHABLE_KEY
return ctx


Hope this helps someone!

-- 
https://github.com/tangentlabs/django-oscar
http://django-oscar.readthedocs.org/en/latest/
https://twitter.com/django_oscar
--- 
You received this message because you are subscribed to the Google Groups 
"django-oscar" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-oscar+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-oscar.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/django-oscar/6b2bb02e-4abd-4fbb-ba7f-34a279db18a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[django-oscar] Re: Add a new payment gateway to Oscar

2017-01-03 Thread 비아구라길라임
Thank you, Joseph. You are my hero!!

On Thursday, August 6, 2015 at 12:33:34 PM UTC+8, Joseph Gallagher wrote:
>
> Hi Loi,
>
> So I've used Stripe  for credit card integration. 
> It's not exactly obvious, and I owe everything to google but, once you've 
> gone to Stripe and set up an account & installed Stripe in your virtualenv, 
> what I've posted below should take care of the logic. You'll need to grab 
> the test keys and set them in settings.py like so:
>
> STRIPE_SECRET_KEY = "sk_test_."
> STRIPE_PUBLISHABLE_KEY = "pk_test_."
> STRIPE_CURRENCY = "USD"
>
>
> Set these in your local checkout apps' __init__.py:
>
> PAYMENT_EVENT_PURCHASE = 'Purchase'
> PAYMENT_METHOD_STRIPE = 'Stripe'
> STRIPE_EMAIL = 'stripeEmail'
> STRIPE_TOKEN = 'stripeToken'
>
>
> You will need to override the PaymentDetailsView to set the source and 
> handle payment, as per the oscar docs:
>
> from django.conf import settings
> from oscar.core.loading import get_model
> from django.utils.decorators import method_decorator
> from django.views.decorators.csrf import csrf_exempt
>
> from oscar.apps.checkout.views import PaymentDetailsView as 
> CorePaymentDetailsView
> from facade import Facade
>
> from . import PAYMENT_METHOD_STRIPE, PAYMENT_EVENT_PURCHASE, STRIPE_EMAIL, 
> STRIPE_TOKEN
>
> import forms
>
> SourceType = get_model('payment', 'SourceType')
> Source = get_model('payment', 'Source')
>
>
> class PaymentDetailsView(CorePaymentDetailsView):
>
> @method_decorator(csrf_exempt)
> def dispatch(self, request, *args, **kwargs):
> return super(PaymentDetailsView, self).dispatch(request, *args, 
> **kwargs)
>
> def get_context_data(self, **kwargs):
> ctx = super(PaymentDetailsView, self).get_context_data(**kwargs)
> if self.preview:
> ctx['stripe_token_form'] = 
> forms.StripeTokenForm(self.request.POST)
> ctx['order_total_incl_tax_cents'] = (
> ctx['order_total'].incl_tax * 100
> ).to_integral_value()
> else:
> ctx['stripe_publishable_key'] = settings.STRIPE_PUBLISHABLE_KEY
> return ctx
>
> def handle_payment(self, order_number, total, **kwargs):
> stripe_ref = Facade().charge(
> order_number,
> total,
> card=self.request.POST[STRIPE_TOKEN],
> description=self.payment_description(order_number, total, 
> **kwargs),
> metadata=self.payment_metadata(order_number, total, **kwargs))
>
> source_type, __ = 
> SourceType.objects.get_or_create(name=PAYMENT_METHOD_STRIPE)
> source = Source(
> source_type=source_type,
> currency=settings.STRIPE_CURRENCY,
> amount_allocated=total.incl_tax,
> amount_debited=total.incl_tax,
> reference=stripe_ref)
> self.add_payment_source(source)
>
> self.add_payment_event(PAYMENT_EVENT_PURCHASE, total.incl_tax)
>
> def payment_description(self, order_number, total, **kwargs):
> return self.request.POST[STRIPE_EMAIL]
>
> def payment_metadata(self, order_number, total, **kwargs):
> return {'order_number': order_number}
>
>
> You can then create a payment facade in your local /apps/checkout. You 
> won't be overriding an Oscar facade.py, since that doesn't exist in the 
> checkout app. Something like this:
>
> from django.conf import settings
> from oscar.apps.payment.exceptions import UnableToTakePayment, 
> InvalidGatewayRequestError
>
> import stripe
>
>
> class Facade(object):
> def __init__(self):
> stripe.api_key = settings.STRIPE_SECRET_KEY
>
> @staticmethod
> def get_friendly_decline_message(error):
> return 'The transaction was declined by your bank - please check your 
> bankcard details and try again'
>
> @staticmethod
> def get_friendly_error_message(error):
> return 'An error occurred when communicating with the payment 
> gateway.'
>
> def charge(self,
> order_number,
> total,
> card,
> currency=settings.STRIPE_CURRENCY,
> description=None,
> metadata=None,
> **kwargs):
> try:
> return stripe.Charge.create(
> amount=(total.incl_tax * 100).to_integral_value(),
> currency=currency,
> card=card,
> description=description,
> metadata=(metadata or {'order_number': order_number}),
> **kwargs).id
> except stripe.CardError, e:
> raise UnableToTakePayment(self.get_friendly_decline_message(e))
> except stripe.StripeError, e:
> raise 
> InvalidGatewayRequestError(self.get_friendly_error_message(e))
>
>
> Now register your forms in your local /apps/checkout/forms.py like so:
>
> from django import forms
>
>
> class StripeTokenForm(forms.Form):
> stripeEmail = forms.EmailField(widget=forms.HiddenInput())
> stripeToken