hyperswitch icon indicating copy to clipboard operation
hyperswitch copied to clipboard

[FEATURE]: [Bambora] Currency Unit Conversion

Open Sakilmostak opened this issue 2 years ago • 7 comments

:memo: Feature Description

  • Each currency can be described in terms of base or minor units.
  • For instance, when dealing with USD currency, the Cent is considered as the minor unit, while the Dollar is considered the base unit.
  • In Hyperswitch, the amount value is expected to be always provided in minor units.
  • For example: In USD, If the amount is 1 in base unit (Dollar), then it will be equivalent to 100 in minor units (Cent)
  • Some of the connectors integrated require the amount to be converted to a desirable unit before being passed to them.
  • We have functions to_currency_base_unit and to_currency_lower_unit in place to convert the minor unit amount to its decimal equivalent and vice versa. These conversions are handled explicitly based on the connector.

:hammer: Possible Implementation

  • ConnectorCommon trait have been implemented for the connector.
  • This trait contains get_currency_unit method. This method needs to be implemented.
  • It will define what type of conversion needs to be done during connector_router_data creation. Concurrently handle the creation of connector_router_data to be passed for the connector request body creation.
  • You can check this PR for further reference https://github.com/juspay/hyperswitch/pull/2196

:bookmark: Note: All the changes needed should be contained within hyperswitch/crates/router/src/connector/

:package: Have you spent some time checking if this feature request has been raised before?

  • [X] I checked and didn't find a similar issue

:package: Have you read the Contributing Guidelines?

:sparkles: Are you willing to submit a PR?

Sakilmostak avatar Sep 21 '23 11:09 Sakilmostak

😊 "I'd be delighted to work on this issue! Could you please assign it to me?"

TechWizard9999 avatar Oct 01 '23 05:10 TechWizard9999

Hey @TechWizard9999 , I see that you're already assigned to #2352. For now, we'll leave this issue open to any other interested contributors. You may pick this up once your work on #2352 is completed, and if no other contributors have expressed interest on this. I hope that's fine by you

AkshayaFoiger avatar Oct 01 '23 05:10 AkshayaFoiger

Can I work on this one if @TechWizard9999 is not currently work on this?

speedhs avatar Oct 15 '23 18:10 speedhs

Sure @speedhs , I have assigned this issue to you

Sakilmostak avatar Oct 16 '23 06:10 Sakilmostak

Hey! Using the other prs as a reference I have made some changes to the code. Can you guide me as to how I can check if its working fine? Possibly by calling some API?

speedhs avatar Oct 19 '23 09:10 speedhs

Hey @speedhs Create a payment via hyperswitch, and match the amount you are passing in your request with amount you are getting in connector response. Both should be same.

swangi-kumari avatar Oct 19 '23 14:10 swangi-kumari

Hey @speedhs , Are you still working on this issue? Let us know if you need any help.

swangi-kumari avatar Mar 13 '24 12:03 swangi-kumari