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(payment_charges): add support for collecting and refunding charges on payments #4628

Merged
merged 49 commits into from
May 24, 2024

Conversation

kashif-m
Copy link
Contributor

@kashif-m kashif-m commented May 13, 2024

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

Detailed description - #4659

This PR adds functionality to create charges on payment intents using Stripe

  • create charges on payment_intent
  • store charge_id in payment_attempt
  • use charge_id for refunds
    • Direct
     "charges": {
         "charge_id": "ch_3PJDz8Ihl7EEkW0O16Wetnl5",
         "revert_platform_fee": true
     }
    
    • Destination
     "charges": {
         "charge_id": "ch_3PJDz8Ihl7EEkW0O16Wetnl5",
         "revert_platform_fee": true,
         "revert_transfer": true
     }
    

Note - charges on mandates is not added in this PR.

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?

Tested locally using postman collection.

Steps for testing

  • Make sure Stripe Connect is enabled on your Stripe account
  • Onboard a Standard user by initiating an account link from Stripe's dashboard
  • Make sure merchant account is created and Stripe is added as a payment connector
  • Create a direct charge on payment by adding below field in /payment_intents request
"charges": {
        "charge_type": "direct",
        "fees": 123,
        "transfer_account_id": "acct_1PDftAIhl7EEkW0O"
}
  • Create a destination charge on payment by adding below field in /payment_intents request
"charges": {
        "charge_type": "destination",
        "fees": 123,
        "transfer_account_id": "acct_1PDftAIhl7EEkW0O"
}

Direct charges

  • ref - https://docs.stripe.com/connect/direct-charges
  • these help in directly creating charges when customer is paying to the connected account
  • charges are created, money is split (Stripe fees + reseller’s fees) and the remaining amount is transferred to connected account’s balance

Destination charges

  • ref - https://docs.stripe.com/connect/destination-charges
  • charges are created on the reseller’s account
  • reseller decides whether some of all of those funds are to be transferred to the connected account
  • reseller’s account is used for debiting the cost of Stripe fees, refunds and chargebacks
  • only supported when both reseller and connected accounts belong to the same country

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

@kashif-m kashif-m changed the title Payment charges feat(payment_charges): add support for collecting and refunding charges on payments May 15, 2024
@kashif-m kashif-m linked an issue May 15, 2024 that may be closed by this pull request
2 tasks
@kashif-m kashif-m self-assigned this May 15, 2024
@kashif-m kashif-m added A-core Area: Core flows C-feature Category: Feature request or enhancement S-waiting-on-review Status: This PR has been implemented and needs to be reviewed M-database-changes Metadata: This PR involves database schema changes M-api-contract-changes Metadata: This PR involves API contract changes A-refunds Area: Refund flows A-payments Area: payments and removed A-core Area: Core flows labels May 15, 2024
@kashif-m kashif-m marked this pull request as ready for review May 15, 2024 17:35
@kashif-m kashif-m requested review from a team as code owners May 15, 2024 17:35
SamraatBansal
SamraatBansal previously approved these changes May 22, 2024
Copy link
Contributor

@SamraatBansal SamraatBansal left a comment

Choose a reason for hiding this comment

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

LGTM! Approving on behalf of connectors

SamraatBansal
SamraatBansal previously approved these changes May 22, 2024
Narayanbhat166
Narayanbhat166 previously approved these changes May 22, 2024
SamraatBansal
SamraatBansal previously approved these changes May 23, 2024
ThisIsMani
ThisIsMani previously approved these changes May 23, 2024
Copy link
Contributor

@ThisIsMani ThisIsMani left a comment

Choose a reason for hiding this comment

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

Dashboard specific changes looks fine.

@likhinbopanna likhinbopanna added this pull request to the merge queue May 24, 2024
Merged via the queue into main with commit 55ccce6 May 24, 2024
22 checks passed
@likhinbopanna likhinbopanna deleted the payment_charges branch May 24, 2024 08:23
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-payments Area: payments A-refunds Area: Refund flows C-feature Category: Feature request or enhancement 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.

[FEATURE] add support for collecting and refunding charges on payments