Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to check transaction status (526) #453

Open
ifnull opened this issue Jan 27, 2022 · 1 comment
Open

Unable to check transaction status (526) #453

ifnull opened this issue Jan 27, 2022 · 1 comment
Labels

Comments

@ifnull
Copy link

ifnull commented Jan 27, 2022

Description

We are migrating from woocommerce-gateway-paypal-express-checkout. At checkout, we authorize then capture after an order has been fulfilled. Before sending an order to the fulfillment system we check the status of the authorization of a transaction. The way we do this in the Paypal Express Checkout plugin is by checking the order meta key _paypal_status and getting the transaction details using the plugin's internal gateway client. If the transaction is pending for any reason other than "authorization" we cancel the order.

Excerpt of how we do this today:

$paypal_status = get_post_meta ( $orderId, '_paypal_status', TRUE );
$trans_id      = get_post_meta ( $orderId, '_transaction_id', TRUE );
$trans_details = wc_gateway_ppec()->client->get_transaction_details( array( 'TRANSACTIONID' => $trans_id ) );
$reason = $trans_details['PENDINGREASON'];

if( $paypal_status !== 'pending' && $reason !== 'authorization' ){
    $order->add_order_note( 'Cancelled because Paypal payment status was ' . $paypal_status . 'Paypal PENDINGREASON was ' . $reason, 0, TRUE );
    $order->update_status( 'cancelled' );
}

With the woocommerce-paypal-payments plugin, I do not see a _paypal_status meta key on the order. However, it looks like the function order_is_approved() will provide what I need but since it is a private function, I'm unable to call it.

To Reproduce

$payment_gateways = new WC_Payment_Gateways();
$ppcp_gateway = $payment_gateways->get_available_payment_gateways()['ppcp-gateway'];
$ppcp_gateway->order_processor;

Expected Behavior

Order approval status is returned.

Actual Behavior

Uncaught Error: Cannot access protected property WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway::$order_processor 

Environment

  • WordPress 5.8.3
  • WooCommerce 6.1.0
  • Plugin 1.6.4
  • Chrome 97.0.4692.71
@Dinamiko Dinamiko changed the title Unable to check transaction status Unable to check transaction status (526) Feb 2, 2022
@AlexP11223
Copy link
Contributor

will provide what I need but since it is a private function, I'm unable to call it.

I think it would not help much even if it was public? You still need an order object retrieved from PayPal API.

If you want to do that, you can get api.endpoint.order from the container like discussed here and call its order method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants