0

My issue: I am working on a subscription or installment based application so the user gets whatever amount they had to for 3 or 6 months. I used stripe plan and schedule method to accomplish this:

When creating plan if the price is provided manually it works. Subscription is created But for me sometimes there is calculation and amount varies like dynamic subscription and I want price to be dynamic.

But when I make amount" => $price, dynamic I get error "This payment requires additional user action before it can be completed successfully. Payment can be completed using the PaymentIntent associated with the invoice. For more details see: https://stripe.com/docs/billing/subscriptions/overview#requires-action"

     //Fetching intent 
     $intent = \Stripe\PaymentIntent::retrieve($paymentMethodParams->paymentIntent['id']);
    
    //Create stripe user
    $customer = \Stripe\Customer::create(([
          'email' => 'evansd@ed.com',
          'description' => 'Valued Customer',
          'name' => 'Ed Ward', 
          'payment_method' => $paymentMethodParams->paymentMethod['id'],
          'invoice_settings' => 
              [
                'default_payment_method' => $paymentMethodParams->paymentMethod['id']
              ]
      ]));

      //Attaching paymentIntent with Customer
     \Stripe\PaymentIntent::update($paymentMethodParams->paymentIntent['id'],
        [
          'customer' => $customer->id,
        ]
      );
     $intent = \Stripe\PaymentIntent::retrieve($paymentMethodParams->paymentIntent['id']);

    $product = \Stripe\Product::create([
      'name' => 'Payment plan for user',
      'type' => 'service'
    ]);

    //Creating plan for the customer
    $plan = \Stripe\Plan::create(
      array(
        "product" => [
            "name" => '#1 monthly Subscription'
        ], 
        "amount" => 200,
        'nickname' => 'Payment Plan for order - ',
        "currency" => 'GBP',
        "interval" => 'month', 
        "interval_count" => 1,
        'metadata' => [                  
        ]
      )
    );

     $schedule = \Stripe\SubscriptionSchedule::create([
      'customer' => $customer->id,
      'start_date' => 'now',
      'end_behavior' => 'cancel',
      'metadata' => [
         'local_id' => 'ABC 12345',                    
      ],
      'phases' => [
          [
              'items' => [
                  [
                      'plan' => $plan->id,
                  ],
              ],
              'iterations'=>2
          ],
      ],
      ]);

 $subscription_id = $schedule->subscription;
 $result = \Stripe\Subscription::update($subscription_id,
    [
        'expand' => ['latest_invoice.payment_intent'],                
    ]
  );
$invoice = \Stripe\Invoice::retrieve($result->latest_invoice->id);
$invoice->pay();

What I did so far:

1: I even tried to set the $price = 1 and in phases 'quantity' => $price * $qty so it charges my price. But then its same again.

This issue is only for certain test cards like : 4000 0027 6000 3184.(issue started when SCA was implemented). The other cards without sca rules works perfectly. (These card that requires authentication on all transactions, regardless of how the card is set up.)

2:Created plan first and then created customer with the plan just like in mentioned in Stripe Subscription Plans of Varying Amounts

I think its not user action, but its dynamic plan price issue. If the price is static, it works and with sca card.

Thanks in advance.

jones
  • 749
  • 7
  • 34
  • The behavior you're describing is expected; trying to pay an Invoice off-session with a card that requires authentication will fail. Are you paying the non-dynamic ones on-session with Stripe.js? – Justin Michael Jan 16 '21 at 22:38
  • Yes, its stripe js. First I check with stripecreatePaymentMethod and create intent. If it requires action I will call stripe.handleCardAction then connect with API to create subscription. "The behavior you're describing is expected". what does that means, do I need to tell customer payment cannot be processed? – jones Jan 17 '21 at 10:57
  • Are you using Subscription Schedules in both the working and non-working scenarios? Can you update your question with the static price code that works so I can compare it to the dynamic price code that does not work? – Justin Michael Jan 20 '21 at 21:34

0 Answers0