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

Bug/ts 67 bug with issuing refund programmatically #19

Merged
merged 9 commits into from
Jun 22, 2022

Conversation

javiercrac
Copy link

/**
* 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
*/

@javiercrac javiercrac requested a review from apetrovici June 14, 2022 18:03
@javiercrac javiercrac self-assigned this Jun 14, 2022
*
* @return array
*/
public function test_refund_programmatically () {
Copy link
Owner

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.

Copy link
Author

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 ] ) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

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.

Copy link
Owner

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 ] ) {
Copy link
Owner

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"

@apetrovici apetrovici requested a review from ahumulescu June 17, 2022 11:13
@@ -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 );

Copy link
Collaborator

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

@ahumulescu ahumulescu merged commit e77b2da into 1.2.3 Jun 22, 2022
@apetrovici
Copy link
Owner

@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.

ahumulescu pushed a commit that referenced this pull request Aug 1, 2022
* 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]>
@apetrovici apetrovici deleted the bug/TS-67-bug-with-issuing-refund-programmatically branch November 25, 2022 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants