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(connector): [billwerk] implement payment and refund flows #4245

Merged
merged 25 commits into from
Apr 1, 2024

Conversation

SamraatBansal
Copy link
Contributor

@SamraatBansal SamraatBansal commented Mar 28, 2024

Type of Change

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

Description

implement all the basic flows for Billwerk (Reepay):

Additional Changes

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

Add Secondary Base Url and tokenisation config.

Motivation and Context

#4246

How did you test it?

Test all the basic (no-3DS) and error cases for above mentioned flows. Refer to this link for test cards, Visa and MasterCard are not enabled on this account.

  • Create Automatic Charge

curl --location 'http://localhost:8080/payments' \
--header 'Accept: application/json' \
--header 'api-key: dev_sLGOvjA9xpMI1LxK7CJ9wHVMdEkncSpHcT8LB5MwNmaA32bD8LTVMuWO9tXmyBjs' \
--header 'x-feature: router-custom' \
--header 'Content-Type: application/json' \
--data-raw '{
	"amount": 1337,
	"currency": "USD",
	"confirm": true,
	"capture_method": "automatic",
	"capture_on": "2022-09-10T10:11:12Z",
	"amount_to_capture": 1337,
	"customer_id": "customerg1",
	"email": "guest2@example.com",
	"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": "340000000000009",
			"card_exp_month": "12",
			"card_exp_year": "2099",
			"card_holder_name": "joseph Doe",
			"card_cvc": "123"
		}
	},
	"billing": {
		"address": {
			"line1": "1467",
			"line2": "Harrison Street",
			"line3": "Harrison Street",
			"city": "San Fransico",
			"state": "California",
			"zip": "94122",
			"country": "US",
			"first_name": "joseph",
			"last_name": "Doe"
		},
		"phone": {
			"number": "8056594427",
			"country_code": "+91"
		}
	},
	"shipping": {
		"address": {
			"line1": "1467",
			"line2": "Harrison Street",
			"line3": "Harrison Street",
			"city": "San Fransico",
			"state": "California",
			"zip": "94122",
			"country": "US",
			"first_name": "joseph",
			"last_name": "Doe"
		},
		"phone": {
			"number": "8056594427",
			"country_code": "+91"
		}
	},
    "browser_info": {
        "user_agent": "Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/70.0.3538.110 Safari\/537.36",
        "accept_header": "text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,image\/apng,*\/*;q=0.8",
        "language": "nl-NL",
        "color_depth": 24,
        "screen_height": 723,
        "screen_width": 1536,
        "time_zone": 0,
        "java_enabled": true,
        "java_script_enabled":true,
        "ip_address": "127.0.0.1"
    },
	"statement_descriptor_name": "joseph",
	"statement_descriptor_suffix": "JS",
    "metadata": {
        "test": "ket"
    }
}'
  • Create Manual Charge

curl --location 'http://localhost:8080/payments' \
--header 'Accept: application/json' \
--header 'api-key: dev_sLGOvjA9xpMI1LxK7CJ9wHVMdEkncSpHcT8LB5MwNmaA32bD8LTVMuWO9tXmyBjs' \
--header 'x-feature: router-custom' \
--header 'Content-Type: application/json' \
--data-raw '{
	"amount": 1337,
	"currency": "USD",
	"confirm": true,
	"capture_method": "manual",
	"capture_on": "2022-09-10T10:11:12Z",
	"amount_to_capture": 1337,
	"customer_id": "customerg1",
	"email": "guest2@example.com",
	"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": "340000000000009",
			"card_exp_month": "12",
			"card_exp_year": "2099",
			"card_holder_name": "joseph Doe",
			"card_cvc": "123"
		}
	},
	"billing": {
		"address": {
			"line1": "1467",
			"line2": "Harrison Street",
			"line3": "Harrison Street",
			"city": "San Fransico",
			"state": "California",
			"zip": "94122",
			"country": "US",
			"first_name": "joseph",
			"last_name": "Doe"
		},
		"phone": {
			"number": "8056594427",
			"country_code": "+91"
		}
	},
	"shipping": {
		"address": {
			"line1": "1467",
			"line2": "Harrison Street",
			"line3": "Harrison Street",
			"city": "San Fransico",
			"state": "California",
			"zip": "94122",
			"country": "US",
			"first_name": "joseph",
			"last_name": "Doe"
		},
		"phone": {
			"number": "8056594427",
			"country_code": "+91"
		}
	},
    "browser_info": {
        "user_agent": "Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/70.0.3538.110 Safari\/537.36",
        "accept_header": "text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,image\/apng,*\/*;q=0.8",
        "language": "nl-NL",
        "color_depth": 24,
        "screen_height": 723,
        "screen_width": 1536,
        "time_zone": 0,
        "java_enabled": true,
        "java_script_enabled":true,
        "ip_address": "127.0.0.1"
    },
	"statement_descriptor_name": "joseph",
	"statement_descriptor_suffix": "JS",
    "metadata": {
        "test": "ket"
    }
}'
  • Capture an authorised Payment

curl --location 'http://localhost:8080/payments/pay_8CO6aT7MPI3WAh2le81B/capture' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_sLGOvjA9xpMI1LxK7CJ9wHVMdEkncSpHcT8LB5MwNmaA32bD8LTVMuWO9tXmyBjs' \
--data '{
  "amount_to_capture": 1006,
  "statement_descriptor_name": "Joseph",
  "statement_descriptor_suffix": "JS"
}'
  • Void an Authorised Payment
curl --location 'http://localhost:8080/payments/pay_JH4ZARpgdDBt4akRLGAR/cancel' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_sLGOvjA9xpMI1LxK7CJ9wHVMdEkncSpHcT8LB5MwNmaA32bD8LTVMuWO9tXmyBjs' \
--data '{
  "cancellation_reason": "TIMEOUT"
}'
  • Refund a Payment

curl --location 'http://localhost:8080/refunds' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_sLGOvjA9xpMI1LxK7CJ9wHVMdEkncSpHcT8LB5MwNmaA32bD8LTVMuWO9tXmyBjs' \
--data '{
    "payment_id": "pay_6NDVXkL2qRWXh0Gq443H",
    "amount": 100,
    "reason": "Customer returned product",
    "refund_type": "instant",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}'

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
  • I added a CHANGELOG entry if applicable

@SamraatBansal SamraatBansal added A-connector-integration Area: Connector integration C-feature Category: Feature request or enhancement S-waiting-on-review Status: This PR has been implemented and needs to be reviewed M-configuration-changes Metadata: This PR involves configuration changes labels Mar 28, 2024
@SamraatBansal SamraatBansal self-assigned this Mar 28, 2024
@SamraatBansal SamraatBansal requested review from a team as code owners March 28, 2024 10:43
srujanchikke
srujanchikke previously approved these changes Mar 28, 2024
srujanchikke
srujanchikke previously approved these changes Mar 30, 2024
config/docker_compose.toml Show resolved Hide resolved
crates/router/src/connector/billwerk.rs Outdated Show resolved Hide resolved
crates/router/src/connector/billwerk.rs Show resolved Hide resolved
crates/router/src/connector/billwerk.rs Outdated Show resolved Hide resolved
crates/router/src/connector/billwerk.rs Outdated Show resolved Hide resolved
crates/router/src/connector/billwerk/transformers.rs Outdated Show resolved Hide resolved
crates/router/src/connector/billwerk/transformers.rs Outdated Show resolved Hide resolved
crates/router/src/connector/billwerk/transformers.rs Outdated Show resolved Hide resolved
@ArjunKarthik ArjunKarthik added the S-waiting-on-author Status: This PR is incomplete or needs to address review comments label Apr 1, 2024
@SamraatBansal SamraatBansal removed the S-waiting-on-author Status: This PR is incomplete or needs to address review comments label Apr 1, 2024
ArjunKarthik
ArjunKarthik previously approved these changes Apr 1, 2024
@likhinbopanna likhinbopanna removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Apr 1, 2024
@likhinbopanna likhinbopanna added this pull request to the merge queue Apr 1, 2024
Merged via the queue into main with commit aecf4ae Apr 1, 2024
10 of 12 checks passed
@likhinbopanna likhinbopanna deleted the feat/billwerk branch April 1, 2024 14:31
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 C-feature Category: Feature request or enhancement M-configuration-changes Metadata: This PR involves configuration changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] : [Billwerk] Add Payment and Refund Flows
4 participants