Woocommerce-自定义支付网关?

时间:2019-02-19 16:07:58

标签: wordpress woocommerce payment-gateway

我想在我的网站上添加一个自定义的支付网关,例如PayPal,其中所有用户操作都在支付网关网站上进行。 我遵循了this tutorial,并且了解到我需要在process_payment($ order_id)函数中定义重定向

我没有得到的是这一行:

'redirect' => $this->get_return_url( $order )

我在哪里可以将用户重定向到的网址?

我该那样做吗?

$args = array(

            $url = 'https://www.my-redirection-link.com/'

        );

然后执行以下操作:

/*
         * Your API interaction could be built with wp_remote_post()
         */
         $response = wp_remote_post( '{payment processor endpoint}', $args );


         if( !is_wp_error( $response ) ) {

             $body = json_decode( $response['body'], true );

             // it could be different depending on your payment processor
             if ( $body['response']['responseCode'] == 'APPROVED' ) {

                // we received the payment
                $order->payment_complete();
                $order->reduce_order_stock();

                // some notes to customer (replace true with false to make it private)
                $order->add_order_note( 'Hey, your order is paid! Thank you!', true );

                // Empty cart
                $woocommerce->cart->empty_cart();

                // Redirect to the thank you page
                return array(
                    'result' => 'success',
                    'redirect' => $this->get_return_url( $order )
                );

那对我不起作用。结帐页面上显示连接错误。

0 个答案:

没有答案