-
Notifications
You must be signed in to change notification settings - Fork 1
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
Bug/ts 67 bug with issuing refund programmatically #19
Bug/ts 67 bug with issuing refund programmatically #19
Conversation
?wc-api=globalpayments_test_refund&order-id=136&reason=something&amount=1
* | ||
* @return array | ||
*/ | ||
public function test_refund_programmatically () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@javiercrac if we want to use this endpoint for QA, it shouldn't do any validation data. It should just send the data and print the response.
These are things that the process_refund method should be able to deal with and respond accordingly.
e.g. null amount, invalid amount format "0,99", etc.
In case of any error the endpoint response should replicate the response received after clicking "Refund" in the Admin Dashboard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed those validations in the endpoint.
$request->set_request_data( array( | ||
'refund_amount' => $amount, | ||
'refund_reason' => $reason, | ||
)); | ||
$request_args = $request->get_args(); | ||
if ( 0 >= (float)$request_args[ RequestArg::AMOUNT ] ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should validate the refund amount. You can check https://github.heartlandapps.net/DevPortal/opencart-hybrid/blob/f29fe16495ce0bf62c70b94d94242d6aa6555f9a/upload/admin/controller/extension/payment/globalpayments_ucp.php#L411
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested, and if we pass a refund value > refundable order value, there will be an error the same as in the admin.
{ ["error"]=> array(1) { [0]=> string(22) "Invalid refund amount." } } is resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@javiercrac I still consider that we need to do our own validation.
e.g. an amount of "0,12" will create a refund of "12"
$request->set_request_data( array( | ||
'refund_amount' => $amount, | ||
'refund_reason' => $reason, | ||
)); | ||
$request_args = $request->get_args(); | ||
if ( 0 >= (float)$request_args[ RequestArg::AMOUNT ] ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@javiercrac I still consider that we need to do our own validation.
e.g. an amount of "0,12" will create a refund of "12"
@@ -866,6 +866,14 @@ public function process_refund( $order_id, $amount = null, $reason = '' ) { | |||
|
|||
$order = new WC_Order( $order_id ); | |||
$request = $this->prepare_request( $txn_type, $order ); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The validation looks good, but let's format it to respect the WooCommerce standards
@javiercrac @ahumulescu this PR has the test endpoint that shouldn't be delivered within the plugin. Please revert the merge and remove the endpoint. Thanks. |
* Bug/ts 24 Order notes for transactions id are missing after a new order for admin page is added (#20) * add order note after order created * debug status * TS-24: add order note when has T_id * TR-24: [Integrations]: allow gateway instantiation without wp custom functionality Co-authored-by: apetrovici <[email protected]> * Bug/ts 67 bug with issuing refund programmatically (#19) * TS-67 [Woo-commerce] - refund bug when method is called with testendpoint * TS-67 [Woocommerce] - update readme file. * TS-67: [Wocommerce] For testing - all params can be sent ?wc-api=globalpayments_test_refund&order-id=136&reason=something&amount=1 * update version to 1.2.3 * Remove validations at endpoint. code review requested changes. * TR-67: [WooCommerce]: refine test endpoint * add validation for amount * Code standar fix Co-authored-by: apetrovici <[email protected]> * TS-65 Add apple pay button style in admin (#21) * TS-65 Add apple pay button style in admin * TS-68 bug for order pay in user account Fix for Apple pay and Google pay * Remove test endpoint * Update sdk and fix digital wallets payment * Fix apple pay payment action text * tested up to tested on wordpress 6.0. and woocommerce 6.6 * Change merchant id to Client id Google pay change. * minimum php requirement change 5.5.9 to 7.1 php version * TR-25: [WooCommerce]: admin pay for order * TR-25: [WooCommerce]: version udate * add styling to button pay for order * modal margin reduce overlap * TR-25: [WooCommerce]: admin pay for order * TR-25: [WooCommerce]: update changelog * TR-25: [WooCommerce] update php sdk * TR-25: bug fix * TR-25: update readme * TR-25: [WooCommerce]: coding standards update * TR-79: [WooCommerce]: bug fix option * TR-80: [WooCommerce]: bug fix capture * TR-25: [WooCommerce]: update comments * 78-bug-design-button-for-pay-from-pay-for-order 78-bug-design-button-for-pay-from-pay-for-order * TR-25: [WooCommerce]: bug fix handle empty data * TR-25: [WooCommerce]: bug fix handle empty data * TR-77: [WooCommerce]: bug fix retrieve user token * Revert "78-bug-design-button-for-pay-from-pay-for-order" This reverts commit e7323c2. * 78-fix-button-style * fix for other fields in modal * TR-78: [WooCommerce]: bug fix button style Co-authored-by: javiercrac <[email protected]>
/**
* Test endpoint for testing a programmatically refund instead of using admin
*
* URL ENDPOINT www.domain.com/?wc-api=globalpayments_test_refund&order-id=136&reason=something&amount=1
*
* @param int $order-id // valid order-id from a refundable order.
*
* @param string $reason // reason of refund.
*
* @param int $amount // amount of refund , only integer for testing.
*
* @return array
*/