Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic Tax #153

Open
RobotDog37 opened this issue Sep 25, 2024 · 3 comments
Open

Automatic Tax #153

RobotDog37 opened this issue Sep 25, 2024 · 3 comments

Comments

@RobotDog37
Copy link

I've turned on automatic tax in my Stripe, and have tried to set the param for $params['automatic_tax'] = ['enabled' => true]; in the Invoice.php, but nothing I do seems to turn tax on. I'm in Australia and it should be 10% (as configured in my Stripe). Perhaps I'm doing something wrong? I don't see any toggles for tax in the plugin configuration. Otherwise, plugin works a charm, and is much appreciated! Cheers

@moumitahalder
Copy link
Contributor

Hi @RobotDog37,

Thank you for your message and for your kind words about the plugin!

At this time, we don't have built-in support for tax integration with Stripe's automatic tax feature. However, we're planning to include this functionality in our future releases.

Our development team will review and make decisions regarding this feature, and we'll keep you updated on its progress.

@RobotDog37
Copy link
Author

Hi @moumitahalder ,

I appreciate the quick response. I've been asked by my client to implement the tax in their checkout flow, as it is required for them to remain compliant. I've continued to study the codebase, and have attempted to implement it myself, but I've been unsuccessful so far. It seems that enabling the automatic_tax via the checkout session constructor breaks the pay now button. And despite there being some error handling there, there isn't any relevant information in the response, so I've hit quite a brick wall here.

Do you have any suggestions as to how I may be able to achieve this myself while waiting for an official modification to the plugin?

Thanks again,

RobotDog

@RobotDog37
Copy link
Author

Well, I dug a bit deeper and I believe I was able to solve my problem, although I'm not sure it was the proper way, and probably isn't complete. If anyone else needs to solve the issue temporarily while it's being developed by the authors, here's how I managed to do it - I modified enrol/stripepayment/externallib.php around line 280 to include the necessary parameters to enable tax calculations. I've added comments for the three lines that I added. Please forgive the lack of formatting, as I couldn't get GitHub to put this in a code block.

$session = Session::create([
'customer' => $receiverid,
'customer_email' => $receiveremail,
//set customer_update['address'] to auto
'customer_update' => ['address' => 'auto'],
'payment_intent_data' => ['description' => $description ],
'payment_method_types' => ['card'],
'line_items' => [[
'price_data' => [
'product_data' => [
'name' => $description,
'metadata' => [
'pro_id' => $courseid
],
'description' => $description,

                        ],
                        'unit_amount' => $amount , 
                        'currency' => $currency,
                        
                    ],
                    'quantity' => 1,
                    
                ]],
                'discounts' => [[
                    'coupon' => $couponid,
                ]],
                'metadata' => [
                    'course_shortname' => $shortname,
                    'course_id' => $course->id,
                ],
                'mode' => 'payment',
                //added billing_address_collection requirement
                'billing_address_collection' => 'required',
                //enabled automatic_tax 
                'automatic_tax' => ['enabled' => true],
                'success_url' => $CFG->wwwroot.'/webservice/rest/server.php?wstoken=' .$usertoken. '&wsfunction=moodle_stripepayment_success_stripe_url&moodlewsrestformat=json&sessionid={CHECKOUT_SESSION_ID}&user_id=' .$userid. '&couponid=' .$couponid. '&instance_id=' .$instanceid. '',
                'cancel_url' => $CFG->wwwroot.'/course/view.php?id='.$courseid,
            ]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants