rizwanaabbas
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Woocommerce Subscription auto payments issue@kartiks16 No that’s not the issue if we manually call the renewal function it works. Only WordPress Scheduled task is not calling payment function.
I am using this hook to schedule the payment
add_action( ‘woocommerce_scheduled_subscription_payment_’ . $this->id, array( $this, ‘scheduled_subscription_payment’ ), 10, 2 );
`function scheduled_subscription_payment( $amount_to_charge, $order ) {
//$result = $this->process_subscription_payment( $order, $amount_to_charge );
$order_id = $order->get_id();
$order->add_order_note( sprintf( __( ‘Payment Attempt through schedule – %s’, $this->id )));
error_log( ‘Request Args: ‘ . var_export( $order, true ) );
//die();
$result = $this->chargeCard($order_id,1);
// error_log( ‘Schedule Payment Log : ‘ . var_export( $result, true ) );
if ( is_wp_error( $result ) ) {
$order->add_order_note( sprintf( __( ‘Network International subscription renewal failed – %s’, $this->id )));
WC_Subscriptions_Manager::process_subscription_payment_failure_on_order( $order, $product_id );
} else {
WC_Subscriptions_Manager::process_subscription_payments_on_order( $order );
}}