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

Instalment Payment Option Implementation #148

Merged
merged 51 commits into from
Jan 11, 2019
Merged

Instalment Payment Option Implementation #148

merged 51 commits into from
Jan 11, 2019

Conversation

jacstn
Copy link
Contributor

@jacstn jacstn commented Sep 6, 2018

Instalment Payment Integration.

1. Objective

Introduce Installment Payment Option in Magento 2 plugin.

2. Description of change

Added support for Installment Payments.

Key notes:

  • minimum order is hardcoded in JavaScript payment rendering file as 5000 THB, if minimum order is not met than plugin behave in the same way as it is in situation when user choose different payment currency than THB
  • payment option is only available in THB orders
  • translations has been added to Thai Language only.
  • payment cancellation on backend side (after forwarding to bank site) will be implemented once Omise Backend will support sending cancellation event.
  • currently after payment is cancelled by user after redirection to bank page it is treated as pending payment and cart is cleared by Magento, in that case user need to re-do shopping.
  • renamed styles file. File offsite-internetbanking.css had definitions of styles used in checkout internet banking payment method. Renamed file to general style.css and extended styles for supporting displaying installment payment method.
  • renamed CCConfigProvider.php file/class to more generic OmiseConfigProvider.php as included also omise capabilities object.

screenshot 2018-12-18 at 15 26 05

Display message when 5000 THB value of order is not met.

image

3. Quality assurance

🔧 Environments:

  • Platform version: Magento CE 2.2.4.
  • Omise plugin version: Omise-Magento 2.4.
  • PHP version: 7.0.29.

✏️ Details:

To properly test it make successful payment with Installment Option and Credit Card Payment Method.

4. Impact of the change

N/A

5. Priority of change

High

6. Additional Notes

This PR requires omise/omise-php#99 to be merged first.
This PR requires new version of omise-php library to be released with above Capabilities PR

@jacstn jacstn closed this Sep 6, 2018
@jacstn jacstn deleted the 2-installment branch September 6, 2018 08:32
@jacstn jacstn restored the 2-installment branch September 6, 2018 08:33
@jacstn jacstn reopened this Sep 6, 2018
@jacstn jacstn changed the title 2 installment WIP MAG-2 Instalment Payment Sep 6, 2018
…ed html labels

added comment to function
fixed labels
@jacstn jacstn force-pushed the 2-installment branch 2 times, most recently from 4b6150a to bec17ea Compare January 11, 2019 06:48
@jonrandy jonrandy dismissed their stale review January 11, 2019 07:09

Re-reviewing

Copy link
Contributor

@jonrandy jonrandy left a comment

Choose a reason for hiding this comment

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

Just a few small things remaining to fix. I'm also not comfortable with the amount of hardcoded stuff given that all the information to remove this is already present in the Capabilities API response, but for this first release I guess we can let most of that slide to the next release

@jacstn jacstn force-pushed the 2-installment branch 5 times, most recently from bd14ab3 to c17d96c Compare January 11, 2019 08:29
…lities::retrieveInstallmentBackends

added to composer requirement, about newer omise-php library
Copy link
Contributor

@guzzilar guzzilar left a comment

Choose a reason for hiding this comment

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

👍 Thanks for your hard work @jacstn !
I left 3 more comments but those are minors. So.. your call 💪

🎉

use Omise\Payment\Model\Capabilities;
use Omise\Payment\Model\Config\Installment as OmiseInstallmentConfig;

class CapabilitiesConfigProvider implements ConfigProviderInterface
Copy link
Contributor

Choose a reason for hiding this comment

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

So since this class is providing configs specifically for Installment, should we rename this one to just InstallmentConfigProvider?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure...

Capabilities, we provide here capabilities for all payment methods in the future?

foreach ($listOfActivePaymentMethods as $method) {
if ($method->getCode() === OmiseInstallmentConfig::CODE) {
return [
'installment_backends' => $this->capabilities->retrieveInstallmentBackends()
Copy link
Contributor

Choose a reason for hiding this comment

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

just want to note it out that we are sending out 3 unnecessary properties. From Capabilities API response,

{
  "installment_bay": {
    "type": "installment",
    "currencies": [
      "thb"
    ],
    "allowed_installment_terms": [
      3,
      4,
      6,
      9,
      10
    ],
    "amount": {
      "min": 2000,
      "max": 100000000
    }
  }
}

In this pull request, it uses only allowed_installment_terms and _id (special attribute generated by Omise-PHP).
We don't use type, currencies, and amount at the moment.

Would be nice if we limit an access to only what we will use in the frontend.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will use them in the future... when we will have correct values in amount.
than I will also use currencies, now, it is also hardcoded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants