Unexpected response when simulating negative response with Orders API v2

cawecoy
Contributor
Contributor

Hello. I am trying to simulate negative response with Orders API v2 through PHP.

 

<?php

use PayPalCheckoutSdk\Orders\OrdersCreateRequest;
use PayPalCheckoutSdk\Orders\OrdersCaptureRequest;

try {
    $orderId = $_GET['order_id'];
    $paypalRequest = new OrdersCaptureRequest($orderId);
    $paypalRequest->headers['PayPal-Mock-Response'] = '{"mock_application_codes": "DUPLICATE_INVOICE_ID"}';
    $client = PayPalClient::client();
    $response = $client->execute($paypalRequest);
} catch(\PayPalHttp\HttpException $e){
    var_dump($e);
}

 

When I try to simulate the DUPLICATE_INVOICE_ID reponse, I catch this cool excepetion response:

 

{
  "name": "UNPROCESSABLE_ENTITY",
  "details": [
    {
      "issue": "DUPLICATE_INVOICE_ID",
      "description": "Duplicate Invoice ID detected. To avoid a potential duplicate transaction your account setting requires that Invoice Id be unique for each transaction."
    }
  ],
  "message": "The requested action could not be completed, was semantically incorrect, or failed business validation.",
  "debug_id": "70c28ae654da",
  "links": [
    {
      "href": "https://developer.paypal.com/docs/api/orders/v2/#error-DUPLICATE_INVOICE_ID",
      "rel": "information_link",
      "method": "GET"
    }
  ]
}

 

But when I simulate another negative responses, for example CARD_TYPE_NOT_SUPPORTED, I catch this useless response message:

 

PayPalHttp\HttpException in /home/vagrant/Code/mercadocodigo/vendor/paypal/paypalhttp/lib/PayPalHttp/HttpClient.php:215

 

Why?! How can I get a useful response so I can know what is the error?

Login to Me Too
1 ACCEPTED SOLUTION

Accepted Solutions
Solved

MTS_Jennifer
Moderator
Moderator

Hello,

Thank you for posting to the PayPal Merchant Technical Support Community.

Unless you are processing direct credit cards you will not receive a proper response of CARD_TYPE_NOT_SUPPORTED.

Orders API V2 is setup for PayPal Processing so you will not see that error, which explains when you were completing negative testing you did not see that error response.

Also Negative Testing for Rest API is still in beta so there are options that may not show up when testing.

 

Thank you,

Jennifer

PayPal

 

 

View solution in original post

Login to Me Too
2 REPLIES 2
Solved

MTS_Jennifer
Moderator
Moderator

Hello,

Thank you for posting to the PayPal Merchant Technical Support Community.

Unless you are processing direct credit cards you will not receive a proper response of CARD_TYPE_NOT_SUPPORTED.

Orders API V2 is setup for PayPal Processing so you will not see that error, which explains when you were completing negative testing you did not see that error response.

Also Negative Testing for Rest API is still in beta so there are options that may not show up when testing.

 

Thank you,

Jennifer

PayPal

 

 

Login to Me Too

cawecoy
Contributor
Contributor

Thank you for your response, Jennifer!

 


Unless you are processing direct credit cards you will not receive a proper response of CARD_TYPE_NOT_SUPPORTED.

Actually I am paying through sandbox account's credit card, and not receiving a proper response of CARD_TYPE_NOT_SUPPORTED.

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.