Modifying PayPalRest plan parameters requires override whole method

Kirby

Well-known member
Affected version
2.3.7
For non-recurring payments the PayPalRest has method getPaymentParams which allows to easily modify the parmeters.

However, when creating a subscription plan the parameters are hardcoded somwhere in the middle of method getPlanByProductId:

PHP:
$params = [
    'product_id' => $productId,
    'name' => substr($purchase->purchasableTitle, 0, 127),
    'status' => 'ACTIVE',
    'billing_cycles' => [
        [
            'frequency' => [
                'interval_unit' => strtoupper($purchase->lengthUnit),
                'interval_count' => $purchase->lengthAmount,
            ],
            'tenure_type' => 'REGULAR',
            'sequence' => 1,
            'total_cycles' => 0,
            'pricing_scheme' => [
                'fixed_price' => [
                    'value' => $purchase->cost,
                    'currency_code' => $purchase->currency,
                ],
            ],
        ],
    ],
    'payment_preferences' => [
        'payment_failure_threshold' => 2,
    ],
];

$plan = $this->makePayPalRequest('post', 'v1/billing/plans', [
    'json' => $params,
], $accessToken, $errors);

Could the params be moved to their own method getPlanParams()?

This would allow to modify payment parameters as easy as for non-recurring payments.
 
Back
Top Bottom