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

[Paypal express-checkout-nvp] Inconsistency in Transaction Status Key Naming #988

Open
ViniTou opened this issue Feb 19, 2024 · 3 comments
Assignees
Labels

Comments

@ViniTou
Copy link

ViniTou commented Feb 19, 2024

Greetings,

I've outlined the logic flow below and would appreciate corrections if any discrepancies are identified:

  1. Incoming Notify Action: Initiates the \Payum\Paypal\ExpressCheckout\Nvp\Action\PaymentDetailsSyncAction.

  2. Within the PaymentDetailsSyncAction, transactions are fetched for each transaction in a loop:

    foreach (range(0, 9) as $index) {
        if ($model['PAYMENTREQUEST_'.$index.'_TRANSACTIONID']) {
            $this->gateway->execute(new GetTransactionDetails($model, $index));
        }
  3. The response for these transactions is stored in the model through the GetTransactionDetailsAction:

    $result = $this->api->getTransactionDetails(array('TRANSACTIONID' => $model[$transactionIndex]));
    foreach ($result as $name => $value) {
        if (in_array($name, $this->getPaymentRequestNFields())) {
            $model['PAYMENTREQUEST_'.$request->getPaymentRequestN().'_'.$name] = $value;
        }
    }

    Note: Each value is stored under a key with the PAYMENTREQUEST_ prefix.

  4. The complete model is intended to be used with GetHumanStatus. However, there appears to be an issue with the checks for transaction status, as they reference values under the wrong key in PaymentDetailsStatusAction.php:

    src/Payum/Paypal/ExpressCheckout/Nvp/Action/PaymentDetailsStatusAction.php:95
    foreach (range(0, 9) as $index) {
        if (null === $paymentStatus = $model['PAYMENTINFO_'.$index.'_PAYMENTSTATUS']) {
            continue;
        }

    Question: Is there a reason why this setup might not be working, or is it a case of misnamed keys? If the latter, should the key in PaymentDetailsStatusAction be updated?

Your insights on this matter would be highly valuable. Thank you.

@ViniTou ViniTou changed the title [Paypal express-checkout-nvp] GetTransactionDetails response keys - Status check [Paypal express-checkout-nvp] Inconsistency in Transaction Status Key Naming Feb 19, 2024
@pierredup
Copy link
Member

@ViniTou The checks are correct.

When a payment is initiated, the PAYMENTREQUEST_ values are set and sent to PayPal. Once the payment on PayPal is done and the user is directed back to the site, then the payment is captured. When the payment is captured, before the Sync action is executed, the DoExpressCheckoutPayment action is executed which triggers the DoExpressCheckoutPaymentAction

if (
$details['PAYERID'] &&
Api::CHECKOUTSTATUS_PAYMENT_ACTION_NOT_INITIATED === $details['CHECKOUTSTATUS'] &&
$details['PAYMENTREQUEST_0_AMT'] > 0
) {
if (Api::USERACTION_COMMIT !== $details['AUTHORIZE_TOKEN_USERACTION']) {
$confirmOrder = new ConfirmOrder($request->getFirstModel());
$confirmOrder->setModel($request->getModel());
$this->gateway->execute($confirmOrder);
}
$this->gateway->execute(new DoExpressCheckoutPayment($details));
}
if (! $details['PAYERID']) {
$this->gateway->execute(new AuthorizeToken($details));
}
$this->gateway->execute(new Sync($details));

The DoExpressCheckoutPaymentAction then calls the PayPal API with the payment fields. The API then responds with all the PAYMENTINFO_ fields, which is then added back into the model.

$model->replace(
$this->api->doExpressCheckoutPayment((array) $model)
);

So when the PaymentDetailsStatusAction action is executed the values is checking against the correct keys that are set on the model.

If there is something specific not working for you, please let me know what issues you are facing.

@pierredup pierredup self-assigned this Apr 3, 2024
@pierredup
Copy link
Member

If there are any other issues, please feel free to re-open the issue and add additional detail

@ViniTou
Copy link
Author

ViniTou commented Apr 5, 2024

Thing is I was not talking about capturing payment, as that works fine, but Notify action flow.

@pierredup pierredup reopened this Apr 5, 2024
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

2 participants