• Resolved shalintj

    (@shalintj)


    Hi Nicolas,
    While trying to process the subscription payment, I’m stuck at “Processing”:
    https://cl.ly/ebbe510b6565

    When I check Stripe’s logs, I see the “200” but nothing under “Payments” & no subscription is created:
    https://www.dropbox.com/s/zbj9ozh3ptndw36/stripe-log.txt?dl=0

    Also, inside the theme’s functions.php, I have added the following param too:

    
    add_action( 'direct_stripe_subscription_data', function($data, $user, $plan_id, $token, $button_id) {
     $data[] = array(
    		
    			"cross_border_classification" => "export"
    		
    	);
      return $data;
      
    }, 10, 4 );
    

    Please do help!

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Nicolas Figueira

    (@nahuelmahe)

    Hi @shalintj,

    Does the subscription go through without the hook ?

    Notes :
    – if you only use $data parameter you can remove other parameters and remove “, 4” at the end of the code function($data) ( this code will be applied to all Direct Stripe buttons )
    – I previously edited the gist example for charges too (even if that worked), this data needs to be in metadata instruction for the API, that means the code should look like :

    $data = array(
          'metadata' => array("cross_border_classification" => "export")
          )
    );

    Let me know if that helped,

    Thread Starter shalintj

    (@shalintj)

    Thanks for the super quick response.

    So, I’m making some progress – no longer stuck at “Processing” prompt. But the payment is still failing. Here’s what the log says:

    
      {
      "error": {
        "code": "parameter_missing",
        "doc_url": "https://stripe.com/docs/error-codes/parameter-missing",
        "message": "Missing required param: customer.",
        "param": "customer",
        "type": "invalid_request_error"
      }
    }
     

    Test Page: https://checkout.videodojo.co/stripe-test-2/

    Also, here’s a India specific documentation (do look at Page 7):
    https://www.dropbox.com/s/lkjr3w7ykdjwa2j/stripe-doc.pdf?dl=0

    • This reply was modified 7 years, 2 months ago by shalintj.
    • This reply was modified 7 years, 2 months ago by shalintj.
    • This reply was modified 7 years, 2 months ago by shalintj.
    • This reply was modified 7 years, 2 months ago by shalintj.
    Thread Starter shalintj

    (@shalintj)

    Hey Nicolas.. apologies for pushing this aggressively. Just wanted to check on my last reply. Would be great if you can help me figure what am I running in to this issue…

    Plugin Author Nicolas Figueira

    (@nahuelmahe)

    Hello,

    You didn’t confirm if the subscription worked without the hook ?

    But I see an error in the code above, sorry about that, it should be $data[] =

    Without the brackets it replaced the whole data, that means there is no plan id passed to Stripe(which matches the error returned in stripe), with the brackets as in the gist, it adds this data to previously set data.

    Let me know

    Thread Starter shalintj

    (@shalintj)

    Got it.

    TEST 1: SUBSCRIPTION TEST WITHOUT THE HOOK:
    It failed. Here’s the error as per Stripe logs.
    https://www.dropbox.com/s/pkm9edl9uyfuwrb/stripe-subscription-error-1.png?dl=0

    TEST 2: WITH THE HOOK
    This too failed.

    
    add_action( 'direct_stripe_subscription_data', function($data) {
    $data[] = array(
          'metadata' => array("cross_border_classification" => "export")	
    	);
      return $data;
      
    }, 10 );
    

    Error:
    https://www.dropbox.com/s/8hd3ycn7cxufxbm/stripe-subscription-error-2.png?dl=0

    Plugin Author Nicolas Figueira

    (@nahuelmahe)

    Hello,

    Did you set a param called “cross_border_classification” anywhere else in the code or stripe dashboard ?

    Thread Starter shalintj

    (@shalintj)

    Nope. Nowhere else. Have only added it to theme’s functions.php. The surprising part is, this same hook worked for one-off payments but not for subscriptions.

    https://cl.ly/2fee6fc25c50

    • This reply was modified 7 years, 2 months ago by shalintj.
    Thread Starter shalintj

    (@shalintj)

    Ok.. So, it worked.. Here’s what I changed and where I messed up earlier:

    1. Passed the cross_border like the one-off one. Screengrab: https://cl.ly/dd744df2711a

    2. I mistakenly added the product ID and not the plan ID. Fixed that.

    One last query (at least for now 🙂 ):
    For now, to test the subscription code, I removed the one-off hook and added the one for the subscription. If I want to let both these to work together, how do I do that? Here are the final versions of the codes that worked:

    https://cl.ly/dd744df2711a & https://cl.ly/c2c58d69eb6c

    Plugin Author Nicolas Figueira

    (@nahuelmahe)

    Hello @shalintj ,

    I’m glad you found what was wrong.

    Are you passing “cross_border_classification” on main array on purpose ? ( It’s best you can pass it to metadata as in the example above. )

    You can set both filters at the same time one will be triggered for payments and the other for subscriptions, you can then create conditions based on the $button_id parameter to add code for a specific button. Otherwise the code for subscriptions will be applied on all subscription type buttons … Also If you use the charge filter, be aware it will be applied on the payment for the “Setting fee” option.

    In the case you are using the same function in both filters it’s best to name the function and call it withi both actions, like :

    
    function data_for_direct_stripe($data){
        $data[] = array(
          'metadata' => array("cross_border_classification" => "export")	
         );
      return $data;
      
    }
    add_action( 'direct_stripe_charge_data', data_for_direct_stripe($data), 10 );
    add_action( 'direct_stripe_subscription_data', data_for_direct_stripe($data), 10 );
    

    Best wishes,

    Thread Starter shalintj

    (@shalintj)

    Thanks Nicolas. Will try it out and let you know how it goes.

    BTW, what is “Setting Fee” you referred to in your message?

    Plugin Author Nicolas Figueira

    (@nahuelmahe)

    Hello @shalintj ,

    Another user commented your other ticket and I realized I didn’t answer that one, sorry about that.

    The setting fee option in Direct Stripe was created to allow a fixed charge upon subscription ( a setting/creation fee ).

    I think that Stripe added an option to do that during the plan creation.

    Kind regards

    Thread Starter shalintj

    (@shalintj)

    Got it. Thanks for your response, Nicolas.

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Subscription – Stuck at “PROCESSING”’ is closed to new replies.