Search code examples
paypalpaypal-sandboxpaypal-rest-sdkpaypal-subscriptions

initial_fail_amount_action not working as expected


I'm trying to create a recurring payment plan which allow me to get the user first payment immediately, for doing this I've used the option setup_fee setted as 14.99 but for some reason I can't get this working. Infact, the sandbox user that I used for this doesn't have any funds, and the subscription shouldn't be approved just as it happens. These are the payment details:

{
    "name": "Monthly Plan",
    "description": "Monthly plan based subscription",
    "status": "ACTIVE",
    "usage_type": "LICENSED",
    "product_id": "PROD-32M79039A8219464Y",
    "billing_cycles": [
        {
            "frequency": {
                "interval_unit": "MONTH",
                "interval_count": 1
            },
            "tenure_type": "TRIAL",
            "sequence": 1,
            "total_cycles": 1,
            "pricing_scheme": {
                "fixed_price": {
                    "value": "0",
                    "currency_code": "EUR"
                }
            }
        },
        {
            "frequency": {
                "interval_unit": "MONTH",
                "interval_count": 1
            },
            "tenure_type": "REGULAR",
            "sequence": 2,
            "total_cycles": 0,
            "pricing_scheme": {
                "fixed_price": {
                    "value": "14.99",
                    "currency_code": "EUR"
                }
            }
        }
    ],
    "payment_preferences": {
        "auto_bill_outstanding": true,
        "setup_fee": {
            "value": "14.99",
            "currency_code": "EUR"
        },
        "setup_fee_failure_action": "CANCEL",
        "payment_failure_threshold": 0
    },
    "taxes": {
        "percentage": "0",
        "inclusive": false
    },
    "merchant_preferences": {
        "initial_fail_amount_action": "CANCEL",
        "max_fail_attempts": 0
    }
}

I've specified merchant_preferences, that must cancel the subscription process in the PayPal smart buttons process. But this doesn't do anything. The expected behavior:

  1. User approve a subscription using the PayPal smart buttons
  2. The user has no funds so PayPal should stop the process as merchant_preference configuration
  3. If the user has found, then the subscription must be created and the funds must be sent to merchant account in order to activate the subscription in my server

Solution

  • What country is the sandbox user, and what funding sources are on the account? Most sandbox users have infinite funds from a default bank account funding source, or a credit card. It does not matter that their PayPal balance is zero.

    In general it is not possible to create a PayPal subscription with only a PayPal balance -- a backup funding source is required.