Stripe Payment gateway throws an exception on live server working fine on local server

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-11 14:57:10

问题


I am facing an issue on stripe payment gateways. I have integrated stripe payment using their library given at Github and following Stripe Documentation

On first step i setup API key using secret key, then i created customer finally i charged that particular customer.

Full Code

\Stripe\Stripe::setApiKey( $stripe_secret_key );

    try {
            $customer = \Stripe\Customer::create(array(
                    "source" => $stripeToken,
                    "email" => $user_email
                )
            );
            $stripe_user_id = $customer->id;


        // charge customer by customer ID //
        $charge_amount = $stripe_payable_amount * 100;
        $charge = \Stripe\Charge::create(array(
            'amount' => $charge_amount,
            'currency' => $CurrentCurrency,
            'customer' => $stripe_user_id

        ));

    } catch ( Exception $e ) {


        echo  $e->getMessage();

    }

Above code sent an exception message as shown below:

Could not connect to Stripe (https://api.stripe.com/v1/customers/cus_********). Please check your internet connection and try again. If this problem persists, you should check Stripe's service status at https://twitter.com/stripestatus, or let us know at support@stripe.com. (Network error [errno 7]: Failed connect to api.stripe.com:443; Operation now in progress)

I contacted strip on twitter they said your DNS is miss configured on sever. I checked with our network admin. There is no change made from our side. Stripe API was working fine on same day.

Same code is working on localhost.I used same Test API keys on local server as my staging environment.

Please give me any hint to troubleshoot it.


回答1:


I have managed to solve the above error, it has nothing to do with code as same code is working on local server. I deployed it on an another server it worked as well.

Then i checked with our AWS support they mentioned they blocked our port 443. It was being used to send lot of traffic to another website due to malicious code on our server. After they unblock this port Stripe started working again.



来源:https://stackoverflow.com/questions/56399250/stripe-payment-gateway-throws-an-exception-on-live-server-working-fine-on-local

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!