0

In my store I need to be able to cancel a customers order and refund them the total amount they paid.

On PayPal checkout the customer is shown the cost of their items and a shipping rate and then the total cost. When I try to issue a full refund via the NVP API it only ever refunds the amount for the items and doesn't include the shipping cost that they paid.

Is there a way to make sure if refunds the absolute total amount?

Originally I passed through just the PayPal transaction ID as it defaults to a full refund automatically,

    'TRANSACTIONID' => $paypalTransactionId

but I received the following in the data passed back from the API.

    ["TOTALREFUNDEDAMOUNT"]=> string(5) "64.40"

The total amount should have been 69.40. (64.00 for the products and 5.00 for the shipping).

I have tried passing through the total amount (AMT) myself but the API complains that the refund needs to be less than or equal to the cost of the products.

    'TRANSACTIONID' => $paypalTransactionId,
    'AMT' => $totalPrice,
    'REFUNDTYPE' => 'Full'

And also tried passing through the shipping amount

    'TRANSACTIONID' => $paypalTransactionId,
    'SHIPPINGAMT' => $shipping_price,
    'REFUNDTYPE' => 'Full'

Neither do the job.

One possible way around this would be to not pass any shipping cost through Paypal when the customer checks out and just mix it in to the cost of the products. But that isn;t going to be an optimal customer experience and feels kinda hacky.

PayPal RefundTransaction docs

Mark
  • 622
  • 11
  • 27

2 Answers2

0

You must be pulling the subtotal out of your system for the refund instead of the grand total. Simple fix, though. If you're doing a full refund just leave the AMT and REFUNDTYPE parameters out of the request. This will default to a full refund. Those are only required if you're doing a partial refund.

Drew Angell
  • 25,968
  • 5
  • 32
  • 51
  • I had originally done that Andrew as the default is a full refund but still the shipping is never added. Also I tried not sending an amount and nowhere else do I pass it any values to refund. Updated my question to reflect this, cheers. – Mark May 21 '17 at 09:37
  • Your original post still isn't showing what I said. Get rid of all that refund type stuff. Just leave it out and let it fall to default. It will refund the full amount. If you're saying it's not then I would need to see a sample of the raw request / response. – Drew Angell May 21 '17 at 22:08
0

I fixed this, turns out the error was in the original purchase. I sent the following to PayPal when the customer makes an order:

[AMT] => 60.00 // this amount should contain total including shipping
[ITEMAMT] => 60.00 
[SHIPPINGAMT] => 4.99

But the customer was still charged the correct 64.99.

Adding the shipping cost to [AMT] results in the customer still being charged 64.99 (and not 69.98 like I'd have thought it would).

[AMT] => 64.99
[ITEMAMT] => 60.00
[SHIPPINGAMT] => 4.99
Mark
  • 622
  • 11
  • 27