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

refactor(connector): add amount conversion framework to bluesnap #4825

Merged

Conversation

sahkal
Copy link
Contributor

@sahkal sahkal commented May 30, 2024

Type of Change

  • Refactoring

Description

This PR adds amount conversion framework to bluesnap, for sending to connector

Note: Bluesnap works in String Major Unit

Screenshot 2024-06-05 at 4 00 36 PM

Test Cases

Need to test

  • Authorise (three_ds & no_three_ds)
  • Refund
  • Capture

Three_Ds

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_MxnGsRO8MXhIAySOei4gZcFKR3cgtXUTSLus517RPbDc8cBBspnv2TBys6reOxjn' \
--data-raw '{
    "amount": 65401,
    "currency": "USD",
    "confirm": true,    
    "customer_id": "StripeCustomer",
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+1",
    "description": "Its my first payment request",
    "authentication_type": "three_ds",
    "return_url": "https://duck.com",
    "payment_method": "card",
    "payment_method_type":"credit",
    "payment_method_data": {
        "card": {
            "card_number": "4000000000001091",
            "card_exp_month": "04",
            "card_exp_year": "2026",
            "card_holder_name": "joseph Doe",
            "card_cvc": "323"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "sundari"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "sundari"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
'
Screenshot 2024-06-05 at 3 39 08 PM

No_three_ds

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_MxnGsRO8MXhIAySOei4gZcFKR3cgtXUTSLus517RPbDc8cBBspnv2TBys6reOxjn' \
--data-raw '{
    "amount": 65401,
    "currency": "USD",
    "confirm": true,
    "customer_id": "StripeCustomer",
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+1",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "return_url": "https://duck.com",
    "payment_method": "card",
    "payment_method_type":"credit",
    "payment_method_data": {
        "card": {
            "card_number": "4000000000001091",
            "card_exp_month": "04",
            "card_exp_year": "2026",
            "card_holder_name": "joseph Doe",
            "card_cvc": "323"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "sundari"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "sundari"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    } 
}
'
Screenshot 2024-06-05 at 3 40 40 PM

Refund

curl --location 'http://localhost:8080/refunds' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_MxnGsRO8MXhIAySOei4gZcFKR3cgtXUTSLus517RPbDc8cBBspnv2TBys6reOxjn' \
--data '{
    "payment_id": "pay_e2QhahyhDNOajqk8yyV9",
    "amount": 65401,
    "reason": "Customer returned product",
    "refund_type": "instant",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}'
Screenshot 2024-06-05 at 3 46 03 PM

Capture (Manual)

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_MxnGsRO8MXhIAySOei4gZcFKR3cgtXUTSLus517RPbDc8cBBspnv2TBys6reOxjn' \
--data-raw '{
    "amount": 65401,
    "currency": "USD",
    "confirm": true,
    "capture_method": "manual",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 65401,
    "customer_id": "StripeCustomer",
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+1",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "return_url": "https://duck.com",
    "payment_method": "card",
    "payment_method_type":"credit",
    "payment_method_data": {
        "card": {
            "card_number": "4000000000001091",
            "card_exp_month": "04",
            "card_exp_year": "2026",
            "card_holder_name": "joseph Doe",
            "card_cvc": "323"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "sundari"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "sundari"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }  
}
'
Screenshot 2024-06-05 at 3 50 53 PM

Capture call

curl --location 'http://localhost:8080/payments/pay_DcOCj3ilkdchYnhNqlUI/capture' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_MxnGsRO8MXhIAySOei4gZcFKR3cgtXUTSLus517RPbDc8cBBspnv2TBys6reOxjn' \
--data '{
  "amount_to_capture": 65401
}'
Screenshot 2024-06-05 at 3 52 53 PM

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

How did you test it?

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

sahkal and others added 30 commits May 13, 2024 16:50
@likhinbopanna likhinbopanna added this pull request to the merge queue Jun 12, 2024
Merged via the queue into main with commit fb0a7aa Jun 12, 2024
11 checks passed
@likhinbopanna likhinbopanna deleted the 5178-amount-conversion-do-amount-conversion-for-bluesnap branch June 12, 2024 07:25
@SanchithHegde SanchithHegde removed S-waiting-on-review Status: This PR has been implemented and needs to be reviewed high-risk labels Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-connector-integration Area: Connector integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants