简体   繁体   中英

How can I setup taxes and make them included in the subscription price paypal sdk

So I live in europe and we are obligated to have taxes already included in the price displayed to the user and I was wondering how I could do this with Paypal sdk.

My billing_plan_attributes:

billing_plan_attributes = {
            "name": request.args['name'],
            "description": request.args['description'],
            "merchant_preferences": {
                "auto_bill_amount": "yes",
                "cancel_url": "https://ruby-eu.com/profile/settings/paypal/cancel/token",
                "initial_fail_amount_action": "continue",
                "max_fail_attempts": "1",
                "return_url": 'https://ruby-eu.com/profile/settings/paypal/subscribe/execute',
                "setup_fee": {
                    "currency": request.args['currency'],
                    "value": request.args['setup_fee']
                }
            },
            "payment_definitions": [
                {
                    "amount": {
                        "currency": request.args['currency'],
                        "value": request.args['amount']
                    },
                    "cycles": request.args['cycles'],
                    "frequency": request.args['frequency'],
                    "frequency_interval": request.args['frequency_interval'],
                    "name": request.args['payment_name'],
                    "type": request.args['payment_type'],
                }
            ],
            "type": request.args['type']
        }

I tried adding

"taxes": {
                    "percentage": "23",
                    "inclusive": True
                }

inside merchant_preferences , payment_defenitions and under type but when I run it they return

Problem while creating a new plan: Incoming JSON request does not map to API request

and I don't know how could I fix this issue. In case you're wondering if the problem is somewhere else I removed the taxes from the JSON and run and it worked.

First of all know that the depcrecated billing plan object in the Python SDK does NOT correspond to the new plans object in the new Subscriptions API. If you want to use the Subscriptions API (and you probably should), you need to integrate with direct HTTPS API calls, NOT any of the old SDKs. Basically, look at the CURL calls you see here: https://developer.paypal.com/docs/subscriptions/integrate/ ... and implement their equivalents from Python.

The billing plans objects of the Subscriptions API do support the syntax you were trying to add, so my guess is that is where you got it from: https://developer.paypal.com/docs/api/subscriptions/v1/#plans_create

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM