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

feat(payments_v2): add payment_confirm_intent api endpoint #6263

Open
wants to merge 123 commits into
base: main
Choose a base branch
from

Conversation

Narayanbhat166
Copy link
Member

@Narayanbhat166 Narayanbhat166 commented Oct 8, 2024

Type of Change

  • New feature

Description

This PR introduces the payment-confirm-intent endpoint. This is used to confirm the payment intent with payment method data.

This PR also includes changes to the payment attempt for api v2. Few columns have been added and few have been removed. The major changes that have been made to payment attempt are

  • The id type is changed to GlobalId
  • Amount related details are stored in a struct in the domain model. This is to ensure that all the operations / getters / setters related to amount are available in a single struct.
  • Few fields that have been removed as a part of backwards compatibility removal have been deleted in the database.
  • The address details have been de - normalized and stored in the payment attempt table. This is because we will not be reusing the address.

This PR contains only the minimum changes that are required to call the connector.

  • There is a bare minimum implementation of routing which is based on the fallback connector config of the business profile.
  • There is no surcharge, decision manager, tokenization and other features. These would be refactored and slowly added to the v2 feature set.
  • There is no implementation to save the card. These features would eventually be added to v2.

Additional Changes

  • This PR modifies the API contract
    Add new api endpoint to payments. The openapi reference has been generated.
Screenshot 2024-10-11 at 11 00 15 AM
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

How did you test it?

  • Create the payment intent
  • Confirm the payment intent.
curl --location 'http://localhost:8080/v2/payments/12345_pay_0192b430fb0272b2a4ef5efdbfb06f68/confirm-intent' \
--header 'x-profile-id: pro_an7sjopN2AXVvhEEYvSm' \
--header 'x-client-secret: 12345_pay_0192b430fb0272b2a4ef5efdbfb06f68_secret_0192b430fb0272b2a4ef5f08095c2b1b' \
--header 'Content-Type: application/json' \
--header 'api-key: pk_dev_78d1c87dc958419587490ece50cbfd0c' \
--data '{
    "payment_method_data": {
            "card": {
                "card_number": "4242424242424242",
                "card_exp_month": "01",
                "card_exp_year": "27",
                "card_holder_name": "John Doe",
                "card_cvc": "100"
            }
    },
    "payment_method_type": "card",
    "payment_method_subtype": "credit"
}'

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code

crates/api_models/src/payments.rs Outdated Show resolved Hide resolved
crates/api_models/src/payments.rs Show resolved Hide resolved
crates/api_models/src/payments.rs Outdated Show resolved Hide resolved
crates/api_models/src/payments.rs Outdated Show resolved Hide resolved
crates/api_models/src/payments.rs Outdated Show resolved Hide resolved
crates/router/src/core/payments/transformers.rs Outdated Show resolved Hide resolved

/// The payment method subtype to be used for the payment. This should match with the `payment_method_data` provided
#[schema(value_type = PaymentMethodType, example = "apple_pay")]
pub payment_method_subtype: api_enums::PaymentMethodType,
Copy link
Member

Choose a reason for hiding this comment

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

Change the api_enums::PaymentMethodType to api_enums::PaymentMethodSubType, and api_enums::PaymentMethod to api_enums::PaymentMethodType, this might be a bigger change so take this up separately.

crates/api_models/src/payments.rs Outdated Show resolved Hide resolved
crates/api_models/src/payments.rs Outdated Show resolved Hide resolved
crates/diesel_models/src/query/user/sample_data.rs Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
M-api-contract-changes Metadata: This PR involves API contract changes M-database-changes Metadata: This PR involves database schema changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants