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): [worldpay] add support for mandates #6479

Merged
merged 16 commits into from
Nov 8, 2024

Conversation

kashif-m
Copy link
Contributor

@kashif-m kashif-m commented Nov 5, 2024

Type of Change

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

Description

Described in #6316 point #6

Additional Changes

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

Motivation and Context

This PR -

  • integrates mandates through Worldpay enabling HS to perform CIT and MITs.
  • adds webhook source verification

How did you test it?

Things to test

  • Card mandates (no3DS + 3DS)
    • CIT
    • MIT
1. CIT for setting up mandates for non 3DS cards

cURL

curl --location --request POST 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_sMl3D9efytjSoXznSOKCv5PHyql50M1BMhU8e7qsa5m6mXxHvyROVg7cER7AWue9' \
--data-raw '{"amount":6500,"currency":"USD","confirm":true,"capture_method":"automatic","capture_on":"2022-09-10T10:11:12Z","customer_id":"cus_5A3VgopTFe8q83EEHgTq_1234","email":"[email protected]","name":"John Doe","phone":"999999999","profile_id":"pro_OodaMoJ1Y9nlnegU4soR","phone_country_code":"+65","description":"Its my first payment request","authentication_type":"no_three_ds","return_url":"https://hyperswitch.io","setup_future_usage":"off_session","customer_acceptance":{"acceptance_type":"online","accepted_at":"1963-05-03T04:07:52.723Z","online":{"ip_address":"127.0.0.1","user_agent":"amet irure esse"}},"connector":["worldpay"],"payment_method":"card","payment_method_data":{"card":{"card_number":"4000000000001091","card_exp_month":"10","card_exp_year":"2030","card_holder_name":"New Cust","card_cvc":"321"}},"billing":{"address":{"line1":"1467","line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","state":"California","zip":"94122","country":"US","first_name":"John"}},"statement_descriptor_name":"joseph","statement_descriptor_suffix":"JS","metadata":{"udf1":"value1","new_customer":"true","login_date":"2019-09-10T10:11:12Z"},"browser_info":{"ip_address":"129.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","accept_header":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8","language":"en-US","color_depth":32,"screen_height":1117,"screen_width":1728,"time_zone":-330,"java_enabled":true,"java_script_enabled":true}}'

Response

{"payment_id":"pay_f7PIGeDAuN8ui66mfa3g","merchant_id":"merchant_1728979001","status":"processing","amount":6500,"net_amount":6500,"shipping_cost":null,"amount_capturable":0,"amount_received":null,"connector":"worldpay","client_secret":"pay_f7PIGeDAuN8ui66mfa3g_secret_wmxzgisS23jmUzi6LaCK","created":"2024-11-05T04:00:16.068Z","currency":"USD","customer_id":"cus_5A3VgopTFe8q83EEHgTq_1234","customer":{"id":"cus_5A3VgopTFe8q83EEHgTq_1234","name":"John Doe","email":"[email protected]","phone":"999999999","phone_country_code":"+65"},"description":"Its my first payment request","refunds":null,"disputes":null,"mandate_id":null,"mandate_data":null,"setup_future_usage":"off_session","off_session":null,"capture_on":null,"capture_method":"automatic","payment_method":"card","payment_method_data":{"card":{"last4":"1091","card_type":"CREDIT","card_network":"Visa","card_issuer":"INTL HDQTRS-CENTER OWNED","card_issuing_country":"UNITEDSTATES","card_isin":"400000","card_extended_bin":null,"card_exp_month":"10","card_exp_year":"2030","card_holder_name":null,"payment_checks":null,"authentication_data":null},"billing":null},"payment_token":null,"shipping":null,"billing":{"address":{"city":"San Fransico","country":"US","line1":"1467","line2":"Harrison Street","line3":"Harrison Street","zip":"94122","state":"California","first_name":"John","last_name":null},"phone":null,"email":null},"order_details":null,"email":"[email protected]","name":"John Doe","phone":"999999999","return_url":"https://hyperswitch.io/","authentication_type":"no_three_ds","statement_descriptor_name":"joseph","statement_descriptor_suffix":"JS","next_action":null,"cancellation_reason":null,"error_code":null,"error_message":null,"unified_code":null,"unified_message":null,"payment_experience":null,"payment_method_type":null,"connector_label":null,"business_country":null,"business_label":"default","business_sub_label":null,"allowed_payment_method_types":null,"ephemeral_key":{"customer_id":"cus_5A3VgopTFe8q83EEHgTq_1234","created_at":1730779216,"expires":1730782816,"secret":"epk_25b1cc698d7f4442b519b01e59d594c9"},"manual_retry_allowed":false,"connector_transaction_id":"eyJrIjoiazNhYjYzMiIsImxpbmtWZXJzaW9uIjoiNS4wLjAifQ==.sN:g8wd64bwkbrp0md+bPxcanBnk2zLdsIqSa1pR99GGg8fCNQpPLoWNslSzWNPFBM5Tpa8tW7EFI5onKINsgChMHeJVoeH2lrBWCRyjZYT6h+lbqfJa+1BSoKFSY8HLOF6B0tZncBs7SwFiJDsUm4ye6ZBkHUg26Hk6rn+lSpSmfgF9Uk2Www3mSVoKRxeIXIe9pic4l22Rveu3MW0qp:7+4GYJYOg3e9WdLnxDKf8zDOVuNV9Smp3TrKAPuNF+mGHv+EpbUsv07dKPa3jQZMZkSLOAGYpq4tIxEOnFazFMnNixp9xnyekZxhsndH6QYG9PvEiRYH4jvUN3Rj+v361XbX6vZLEHnxgSeac2MDbYIZ+yXrLMCBE1SsMnFcov03cMKErtU9SPLnJxH7q4bw==","frm_message":null,"metadata":{"udf1":"value1","login_date":"2019-09-10T10:11:12Z","new_customer":"true"},"connector_metadata":null,"feature_metadata":null,"reference_id":"7e4a9877-6c3d-4797-a649-404932d23df2","payment_link":null,"profile_id":"pro_OodaMoJ1Y9nlnegU4soR","surcharge_details":null,"attempt_count":1,"merchant_decision":null,"merchant_connector_id":"mca_omabWO9B7CSmaCMuT6eh","incremental_authorization_allowed":null,"authorization_count":null,"incremental_authorizations":null,"external_authentication_details":null,"external_3ds_authentication_attempted":false,"expires_on":"2024-11-05T04:15:16.067Z","fingerprint":null,"browser_info":{"language":"en-US","time_zone":-330,"ip_address":"129.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","color_depth":32,"java_enabled":true,"screen_width":1728,"accept_header":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8","screen_height":1117,"java_script_enabled":true},"payment_method_id":"pm_bxZWCSz5EHkIp005hsFV","payment_method_status":"inactive","updated":"2024-11-05T04:00:18.577Z","charges":null,"frm_metadata":null,"merchant_order_reference_id":null,"order_tax_amount":null,"connector_mandate_id":"https://try.access.worldpay.com/tokens/eyJrIjoxLCJkIjoiM21JUGNNUlNUTEVQNzlPeGNFUktybHZSVkN0eWNpeGthTUtOMld3UlUrYz0ifQ"}

Send a webhook manually for completing the txn

  1. Setup connector's webhook secret (in hex format)
  2. Use payment_attempt_id as transactionReference in the webhook request
  3. Generate a HMAC using SHA256 algorithm online
  4. Use the generated signature in Event-Signature header in the request

cURL

curl --location --request POST 'http://localhost:8080/webhooks/merchant_1728979001/mca_omabWO9B7CSmaCMuT6eh' \
    --header 'Event-Signature: 1/SHA256/cec367bc5eecff7a09ff482be9addad26d7e26e8a24fbf60d79e2cd87f2c12c4' \
    --header 'Content-Type: application/json' \
    --data '{"eventId":"wp-event-id-pay_f7PIGeDAuN8ui66mfa3g","eventTimestamp":"2018-06-13T14:18:13.407","eventDetails":{"classification":"payment","downstreamReference":"3378792436","transactionReference":"pay_f7PIGeDAuN8ui66mfa3g_1","type":"settled","date":"2017-11-03","amount":{"value":6500,"currencyCode":"USD"},"_links":{"payment":{"href":""}}}}'

Retrieve payment for checking the payment_method_status (should be active)

curl --location --request GET 'http://localhost:8080/payments/pay_f7PIGeDAuN8ui66mfa3g?force_sync=true' \
--header 'Accept: application/json' \
--header 'api-key: dev_sMl3D9efytjSoXznSOKCv5PHyql50M1BMhU8e7qsa5m6mXxHvyROVg7cER7AWue9'

{"payment_id":"pay_f7PIGeDAuN8ui66mfa3g","merchant_id":"merchant_1728979001","status":"succeeded","amount":6500,"net_amount":6500,"shipping_cost":null,"amount_capturable":0,"amount_received":6500,"connector":"worldpay","client_secret":"pay_f7PIGeDAuN8ui66mfa3g_secret_wmxzgisS23jmUzi6LaCK","created":"2024-11-05T04:00:16.068Z","currency":"USD","customer_id":"cus_5A3VgopTFe8q83EEHgTq_1234","customer":{"id":"cus_5A3VgopTFe8q83EEHgTq_1234","name":"John Doe","email":"[email protected]","phone":"999999999","phone_country_code":"+65"},"description":"Its my first payment request","refunds":null,"disputes":null,"mandate_id":null,"mandate_data":null,"setup_future_usage":"off_session","off_session":null,"capture_on":null,"capture_method":"automatic","payment_method":"card","payment_method_data":{"card":{"last4":"1091","card_type":"CREDIT","card_network":"Visa","card_issuer":"INTL HDQTRS-CENTER OWNED","card_issuing_country":"UNITEDSTATES","card_isin":"400000","card_extended_bin":null,"card_exp_month":"10","card_exp_year":"2030","card_holder_name":null,"payment_checks":null,"authentication_data":null},"billing":null},"payment_token":null,"shipping":null,"billing":{"address":{"city":"San Fransico","country":"US","line1":"1467","line2":"Harrison Street","line3":"Harrison Street","zip":"94122","state":"California","first_name":"John","last_name":null},"phone":null,"email":null},"order_details":null,"email":"[email protected]","name":"John Doe","phone":"999999999","return_url":"https://hyperswitch.io/","authentication_type":"no_three_ds","statement_descriptor_name":"joseph","statement_descriptor_suffix":"JS","next_action":null,"cancellation_reason":null,"error_code":null,"error_message":null,"unified_code":null,"unified_message":null,"payment_experience":null,"payment_method_type":null,"connector_label":null,"business_country":null,"business_label":"default","business_sub_label":null,"allowed_payment_method_types":null,"ephemeral_key":null,"manual_retry_allowed":false,"connector_transaction_id":"eyJrIjoiazNhYjYzMiIsImxpbmtWZXJzaW9uIjoiNS4wLjAifQ==.sN:g8wd64bwkbrp0md+bPxcanBnk2zLdsIqSa1pR99GGg8fCNQpPLoWNslSzWNPFBM5Tpa8tW7EFI5onKINsgChMHeJVoeH2lrBWCRyjZYT6h+lbqfJa+1BSoKFSY8HLOF6B0tZncBs7SwFiJDsUm4ye6ZBkHUg26Hk6rn+lSpSmfgF9Uk2Www3mSVoKRxeIXIe9pic4l22Rveu3MW0qp:7+4GYJYOg3e9WdLnxDKf8zDOVuNV9Smp3TrKAPuNF+mGHv+EpbUsv07dKPa3jQZMZkSLOAGYpq4tIxEOnFazFMnNixp9xnyekZxhsndH6QYG9PvEiRYH4jvUN3Rj+v361XbX6vZLEHnxgSeac2MDbYIZ+yXrLMCBE1SsMnFcov03cMKErtU9SPLnJxH7q4bw==","frm_message":null,"metadata":{"udf1":"value1","login_date":"2019-09-10T10:11:12Z","new_customer":"true"},"connector_metadata":null,"feature_metadata":null,"reference_id":"7e4a9877-6c3d-4797-a649-404932d23df2","payment_link":null,"profile_id":"pro_OodaMoJ1Y9nlnegU4soR","surcharge_details":null,"attempt_count":1,"merchant_decision":null,"merchant_connector_id":"mca_omabWO9B7CSmaCMuT6eh","incremental_authorization_allowed":null,"authorization_count":null,"incremental_authorizations":null,"external_authentication_details":null,"external_3ds_authentication_attempted":false,"expires_on":"2024-11-05T04:15:16.067Z","fingerprint":null,"browser_info":{"language":"en-US","time_zone":-330,"ip_address":"129.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","color_depth":32,"java_enabled":true,"screen_width":1728,"accept_header":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8","screen_height":1117,"java_script_enabled":true},"payment_method_id":"pm_bxZWCSz5EHkIp005hsFV","payment_method_status":"active","updated":"2024-11-05T04:03:12.974Z","charges":null,"frm_metadata":null,"merchant_order_reference_id":null,"order_tax_amount":null,"connector_mandate_id":"https://try.access.worldpay.com/tokens/eyJrIjoxLCJkIjoiM21JUGNNUlNUTEVQNzlPeGNFUktybHZSVkN0eWNpeGthTUtOMld3UlUrYz0ifQ"}
2. CIT for setting up mandates for 3DS cards

cURL

curl --location --request POST 'http://localhost:8080/payments' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: dev_sMl3D9efytjSoXznSOKCv5PHyql50M1BMhU8e7qsa5m6mXxHvyROVg7cER7AWue9' \
    --data-raw '{"amount":6500,"currency":"USD","confirm":true,"capture_method":"automatic","capture_on":"2022-09-10T10:11:12Z","customer_id":"cus_5A3VgopTFe8q83EEHgTq_1234","email":"[email protected]","name":"John Doe","phone":"999999999","profile_id":"pro_OodaMoJ1Y9nlnegU4soR","phone_country_code":"+65","description":"Its my first payment request","authentication_type":"three_ds","return_url":"https://hyperswitch.io","setup_future_usage":"off_session","customer_acceptance":{"acceptance_type":"online","accepted_at":"1963-05-03T04:07:52.723Z","online":{"ip_address":"127.0.0.1","user_agent":"amet irure esse"}},"connector":["worldpay"],"payment_method":"card","payment_method_data":{"card":{"card_number":"4000000000001091","card_exp_month":"10","card_exp_year":"2030","card_holder_name":"New Cust","card_cvc":"321"}},"billing":{"address":{"line1":"1467","line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","state":"California","zip":"94122","country":"US","first_name":"John"}},"statement_descriptor_name":"joseph","statement_descriptor_suffix":"JS","metadata":{"udf1":"value1","new_customer":"true","login_date":"2019-09-10T10:11:12Z"},"browser_info":{"ip_address":"129.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","accept_header":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8","language":"en-US","color_depth":32,"screen_height":1117,"screen_width":1728,"time_zone":-330,"java_enabled":true,"java_script_enabled":true}}'

Response

{"payment_id":"pay_TTKFV9sqLgsZOg13ImuK","merchant_id":"merchant_1728979001","status":"requires_customer_action","amount":6500,"net_amount":6500,"shipping_cost":null,"amount_capturable":6500,"amount_received":null,"connector":"worldpay","client_secret":"pay_TTKFV9sqLgsZOg13ImuK_secret_BQl69KZ81x8aEhPJ6Jh4","created":"2024-11-05T04:10:48.297Z","currency":"USD","customer_id":"cus_5A3VgopTFe8q83EEHgTq_1234","customer":{"id":"cus_5A3VgopTFe8q83EEHgTq_1234","name":"John Doe","email":"[email protected]","phone":"999999999","phone_country_code":"+65"},"description":"Its my first payment request","refunds":null,"disputes":null,"mandate_id":null,"mandate_data":null,"setup_future_usage":"off_session","off_session":null,"capture_on":null,"capture_method":"automatic","payment_method":"card","payment_method_data":{"card":{"last4":"1091","card_type":"CREDIT","card_network":"Visa","card_issuer":"INTL HDQTRS-CENTER OWNED","card_issuing_country":"UNITEDSTATES","card_isin":"400000","card_extended_bin":null,"card_exp_month":"10","card_exp_year":"2030","card_holder_name":null,"payment_checks":null,"authentication_data":null},"billing":null},"payment_token":null,"shipping":null,"billing":{"address":{"city":"San Fransico","country":"US","line1":"1467","line2":"Harrison Street","line3":"Harrison Street","zip":"94122","state":"California","first_name":"John","last_name":null},"phone":null,"email":null},"order_details":null,"email":"[email protected]","name":"John Doe","phone":"999999999","return_url":"https://hyperswitch.io/","authentication_type":"three_ds","statement_descriptor_name":"joseph","statement_descriptor_suffix":"JS","next_action":{"type":"redirect_to_url","redirect_to_url":"http://localhost:8080/payments/redirect/pay_TTKFV9sqLgsZOg13ImuK/merchant_1728979001/pay_TTKFV9sqLgsZOg13ImuK_1"},"cancellation_reason":null,"error_code":null,"error_message":null,"unified_code":null,"unified_message":null,"payment_experience":null,"payment_method_type":null,"connector_label":null,"business_country":null,"business_label":"default","business_sub_label":null,"allowed_payment_method_types":null,"ephemeral_key":{"customer_id":"cus_5A3VgopTFe8q83EEHgTq_1234","created_at":1730779848,"expires":1730783448,"secret":"epk_266816d2b9204b0e9805d35ef6af29ab"},"manual_retry_allowed":null,"connector_transaction_id":"eyJrIjoxLCJkIjoiVnVsWkNreGxnNnhMVE1zNGMwd1hraHBjRkE1MzN3V2ZmRVBRbVFCUks3WTJJRGpBeDR3ekZaWWVqNDJzOTJkWiJ9","frm_message":null,"metadata":{"udf1":"value1","login_date":"2019-09-10T10:11:12Z","new_customer":"true"},"connector_metadata":null,"feature_metadata":null,"reference_id":"cda65cf9-ad59-4f40-ab42-b73f3d83896d","payment_link":null,"profile_id":"pro_OodaMoJ1Y9nlnegU4soR","surcharge_details":null,"attempt_count":1,"merchant_decision":null,"merchant_connector_id":"mca_omabWO9B7CSmaCMuT6eh","incremental_authorization_allowed":null,"authorization_count":null,"incremental_authorizations":null,"external_authentication_details":null,"external_3ds_authentication_attempted":false,"expires_on":"2024-11-05T04:25:48.297Z","fingerprint":null,"browser_info":{"language":"en-US","time_zone":-330,"ip_address":"129.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","color_depth":32,"java_enabled":true,"screen_width":1728,"accept_header":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8","screen_height":1117,"java_script_enabled":true},"payment_method_id":"pm_Ch8jSriaHKqw6em5UTYt","payment_method_status":"inactive","updated":"2024-11-05T04:10:49.272Z","charges":null,"frm_metadata":null,"merchant_order_reference_id":null,"order_tax_amount":null,"connector_mandate_id":null}

Open the link and complete the txn

Send a webhook manually for completing the txn

  1. Setup connector's webhook secret (in hex format)
  2. Use payment_attempt_id as transactionReference in the webhook request
  3. Generate a HMAC using SHA256 algorithm online
  4. Use the generated signature in Event-Signature header in the request

cURL

curl --location --request POST 'http://localhost:8080/webhooks/merchant_1728979001/mca_omabWO9B7CSmaCMuT6eh' \
    --header 'Event-Signature: 1/SHA256/7ae6606c91d5e1d6684f548f7a932b1f330448a90140bb629a6e84b6ce8b1c5f' \
    --header 'Content-Type: application/json' \
    --data '{"eventId":"wp-event-id-pay_f7PIGeDAuN8ui66mfa3g","eventTimestamp":"2018-06-13T14:18:13.407","eventDetails":{"classification":"payment","downstreamReference":"3378792436","transactionReference":"pay_TTKFV9sqLgsZOg13ImuK_1","type":"settled","date":"2017-11-03","amount":{"value":6500,"currencyCode":"USD"},"_links":{"payment":{"href":""}}}}'

Retrieve payment for checking the payment_method_status (should be active)

curl --location --request GET 'http://localhost:8080/payments/pay_TTKFV9sqLgsZOg13ImuK?force_sync=true' \
    --header 'Accept: application/json' \
    --header 'api-key: dev_sMl3D9efytjSoXznSOKCv5PHyql50M1BMhU8e7qsa5m6mXxHvyROVg7cER7AWue9'

Response

{"payment_id":"pay_TTKFV9sqLgsZOg13ImuK","merchant_id":"merchant_1728979001","status":"succeeded","amount":6500,"net_amount":6500,"shipping_cost":null,"amount_capturable":0,"amount_received":6500,"connector":"worldpay","client_secret":"pay_TTKFV9sqLgsZOg13ImuK_secret_BQl69KZ81x8aEhPJ6Jh4","created":"2024-11-05T04:10:48.297Z","currency":"USD","customer_id":"cus_5A3VgopTFe8q83EEHgTq_1234","customer":{"id":"cus_5A3VgopTFe8q83EEHgTq_1234","name":"John Doe","email":"[email protected]","phone":"999999999","phone_country_code":"+65"},"description":"Its my first payment request","refunds":null,"disputes":null,"mandate_id":null,"mandate_data":null,"setup_future_usage":"off_session","off_session":null,"capture_on":null,"capture_method":"automatic","payment_method":"card","payment_method_data":{"card":{"last4":"1091","card_type":"CREDIT","card_network":"Visa","card_issuer":"INTL HDQTRS-CENTER OWNED","card_issuing_country":"UNITEDSTATES","card_isin":"400000","card_extended_bin":null,"card_exp_month":"10","card_exp_year":"2030","card_holder_name":null,"payment_checks":null,"authentication_data":null},"billing":null},"payment_token":null,"shipping":null,"billing":{"address":{"city":"San Fransico","country":"US","line1":"1467","line2":"Harrison Street","line3":"Harrison Street","zip":"94122","state":"California","first_name":"John","last_name":null},"phone":null,"email":null},"order_details":null,"email":"[email protected]","name":"John Doe","phone":"999999999","return_url":"https://hyperswitch.io/","authentication_type":"three_ds","statement_descriptor_name":"joseph","statement_descriptor_suffix":"JS","next_action":null,"cancellation_reason":null,"error_code":null,"error_message":null,"unified_code":null,"unified_message":null,"payment_experience":null,"payment_method_type":null,"connector_label":null,"business_country":null,"business_label":"default","business_sub_label":null,"allowed_payment_method_types":null,"ephemeral_key":null,"manual_retry_allowed":false,"connector_transaction_id":"eyJrIjoiazNhYjYzMiIsImxpbmtWZXJzaW9uIjoiNS4wLjAifQ==.sN:g8wd64bwkbrp0md+bPxcanBnk2zLdsIqSa1pR99GGg8fCNQpPLoWNslSzWNPFBM5Tpa8tW7EFI5onKINsgChMHeJVoeH2lrBWCRyjZYT6h+lbqfJa+1BSoKFSY8HLsZg56ffytGaY6kviYdeQ3oMFm3I1bdi0LE6+bmsttnumfgF9Uk2Www3mSVoKRxeIXIe9pic4l22Rveu3MW0qp:7+4GYJYOg3e9WdLnxDKf8zDOVuNV9Smp3TrKAPuNF+mGHv+EpbUsv07dKPa3jQZMZkSLOAGYpq4tIxEOnFazFMnNixp9xnyekZxhsndH6QYG9PvEiRYH4jvUN3Rj+v30USXlKxy5DXHS56qQBs16LSjYQgpsQ4hxxgd4CkrfGrpmydzhJke9FdpJBCRDfEFQ==","frm_message":null,"metadata":{"udf1":"value1","login_date":"2019-09-10T10:11:12Z","new_customer":"true"},"connector_metadata":null,"feature_metadata":null,"reference_id":"95ec0989-6586-4dc9-8db3-8840cd61975e","payment_link":null,"profile_id":"pro_OodaMoJ1Y9nlnegU4soR","surcharge_details":null,"attempt_count":1,"merchant_decision":null,"merchant_connector_id":"mca_omabWO9B7CSmaCMuT6eh","incremental_authorization_allowed":null,"authorization_count":null,"incremental_authorizations":null,"external_authentication_details":null,"external_3ds_authentication_attempted":false,"expires_on":"2024-11-05T04:25:48.297Z","fingerprint":null,"browser_info":{"language":"en-US","time_zone":-330,"ip_address":"129.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","color_depth":32,"java_enabled":true,"screen_width":1728,"accept_header":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8","screen_height":1117,"java_script_enabled":true},"payment_method_id":"pm_Ch8jSriaHKqw6em5UTYt","payment_method_status":"active","updated":"2024-11-05T04:13:36.645Z","charges":null,"frm_metadata":null,"merchant_order_reference_id":null,"order_tax_amount":null,"connector_mandate_id":"https://try.access.worldpay.com/tokens/eyJrIjoxLCJkIjoiM21JUGNNUlNUTEVQNzlPeGNFUktybHZSVkN0eWNpeGthTUtOMld3UlUrYz0ifQ"}
2. MIT for subsequent txns

cURL (using the payment_method_id from previous txn)

curl --location --request POST 'http://localhost:8080/payments' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: dev_sMl3D9efytjSoXznSOKCv5PHyql50M1BMhU8e7qsa5m6mXxHvyROVg7cER7AWue9' \
    --data-raw '{"amount":6500,"currency":"USD","confirm":true,"capture_method":"automatic","capture_on":"2022-09-10T10:11:12Z","customer_id":"cus_5A3VgopTFe8q83EEHgTq_1234","email":"[email protected]","name":"John Doe","phone":"999999999","profile_id":"pro_OodaMoJ1Y9nlnegU4soR","phone_country_code":"+65","description":"Its my first payment request","authentication_type":"no_three_ds","return_url":"https://hyperswitch.io","off_session":true,"recurring_details":{"type":"payment_method_id","data":"pm_bxZWCSz5EHkIp005hsFV"},"connector":["worldpay"],"statement_descriptor_name":"joseph","statement_descriptor_suffix":"JS","metadata":{"udf1":"value1","new_customer":"true","login_date":"2019-09-10T10:11:12Z"},"browser_info":{"ip_address":"129.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","accept_header":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8","language":"en-US","color_depth":32,"screen_height":1117,"screen_width":1728,"time_zone":-330,"java_enabled":true,"java_script_enabled":true}}'

Response

{"payment_id":"pay_VzxIcNQg80u9ETlUb552","merchant_id":"merchant_1728979001","status":"processing","amount":6500,"net_amount":6500,"shipping_cost":null,"amount_capturable":0,"amount_received":null,"connector":"worldpay","client_secret":"pay_VzxIcNQg80u9ETlUb552_secret_pk9mW3mw0knGtV2rEqML","created":"2024-11-05T04:07:49.284Z","currency":"USD","customer_id":"cus_5A3VgopTFe8q83EEHgTq_1234","customer":{"id":"cus_5A3VgopTFe8q83EEHgTq_1234","name":"John Doe","email":"[email protected]","phone":"999999999","phone_country_code":"+65"},"description":"Its my first payment request","refunds":null,"disputes":null,"mandate_id":null,"mandate_data":null,"setup_future_usage":null,"off_session":true,"capture_on":null,"capture_method":"automatic","payment_method":"card","payment_method_data":{"card":{"last4":"1091","card_type":"CREDIT","card_network":"Visa","card_issuer":"INTL HDQTRS-CENTER OWNED","card_issuing_country":"UNITEDSTATES","card_isin":"400000","card_extended_bin":null,"card_exp_month":"10","card_exp_year":"2030","card_holder_name":"New Cust","payment_checks":null,"authentication_data":null},"billing":null},"payment_token":null,"shipping":null,"billing":null,"order_details":null,"email":"[email protected]","name":"John Doe","phone":"999999999","return_url":"https://hyperswitch.io/","authentication_type":"no_three_ds","statement_descriptor_name":"joseph","statement_descriptor_suffix":"JS","next_action":null,"cancellation_reason":null,"error_code":null,"error_message":null,"unified_code":null,"unified_message":null,"payment_experience":null,"payment_method_type":null,"connector_label":null,"business_country":null,"business_label":"default","business_sub_label":null,"allowed_payment_method_types":null,"ephemeral_key":{"customer_id":"cus_5A3VgopTFe8q83EEHgTq_1234","created_at":1730779669,"expires":1730783269,"secret":"epk_6875ddcad68a4f75abca0541827381ea"},"manual_retry_allowed":false,"connector_transaction_id":"eyJrIjoiazNhYjYzMiIsImxpbmtWZXJzaW9uIjoiNS4wLjAifQ==.sN:g8wd64bwkbrp0md+bPxcanBnk2zLdsIqSa1pR99GGg8fCNQpPLoWNslSzWNPFBM5Tpa8tW7EFI5onKINsgChMHeJVoeH2lrBWCRyjZYT6h+lbqfJa+1BSoKFSY8HL1pxhLLvex9cXiey82ADAqLhmHF8GikqGQ6HjlU40U56mfgF9Uk2Www3mSVoKRxeIXIe9pic4l22Rveu3MW0qp:7+4GYJYOg3e9WdLnxDKf8zDOVuNV9Smp3TrKAPuNF+mGHv+EpbUsv07dKPa3jQZMZkSLOAGYpq4tIxEOnFazFMnNixp9xnyekZxhsndH6QYG9PvEiRYH4jvUN3Rj+v3wz1O+vl6m108JhqrKvq3afbNIuD+yJDmY7OemfgPo4MPa0TaXoA+VAVynZedasIKw==","frm_message":null,"metadata":{"udf1":"value1","login_date":"2019-09-10T10:11:12Z","new_customer":"true"},"connector_metadata":null,"feature_metadata":null,"reference_id":"4b343e0d-9e01-4236-a76d-99a5b02325ec","payment_link":null,"profile_id":"pro_OodaMoJ1Y9nlnegU4soR","surcharge_details":null,"attempt_count":1,"merchant_decision":null,"merchant_connector_id":"mca_omabWO9B7CSmaCMuT6eh","incremental_authorization_allowed":null,"authorization_count":null,"incremental_authorizations":null,"external_authentication_details":null,"external_3ds_authentication_attempted":false,"expires_on":"2024-11-05T04:22:49.284Z","fingerprint":null,"browser_info":{"language":"en-US","time_zone":-330,"ip_address":"129.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","color_depth":32,"java_enabled":true,"screen_width":1728,"accept_header":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8","screen_height":1117,"java_script_enabled":true},"payment_method_id":"pm_bxZWCSz5EHkIp005hsFV","payment_method_status":"active","updated":"2024-11-05T04:07:52.953Z","charges":null,"frm_metadata":null,"merchant_order_reference_id":null,"order_tax_amount":null,"connector_mandate_id":"https://try.access.worldpay.com/tokens/eyJrIjoxLCJkIjoiM21JUGNNUlNUTEVQNzlPeGNFUktybHZSVkN0eWNpeGthTUtOMld3UlUrYz0ifQ"}

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 self-assigned this Nov 5, 2024
@kashif-m kashif-m linked an issue Nov 5, 2024 that may be closed by this pull request
2 tasks
@kashif-m kashif-m changed the title Worldpay mandates feat(connector): [worldpay] add support for mandates Nov 5, 2024
@kashif-m kashif-m marked this pull request as ready for review November 5, 2024 04:57
@kashif-m kashif-m requested review from a team as code owners November 5, 2024 04:57
deepanshu-iiitu
deepanshu-iiitu previously approved these changes Nov 5, 2024
@Gnanasundari24
Copy link
Contributor

@kashif-m Can you run the cypress testcases for this

@likhinbopanna likhinbopanna added this pull request to the merge queue Nov 8, 2024
Merged via the queue into main with commit 378ec44 Nov 8, 2024
16 of 17 checks passed
@likhinbopanna likhinbopanna deleted the worldpay-mandates branch November 8, 2024 13:37
bsayak03 pushed a commit that referenced this pull request Nov 26, 2024
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
bsayak03 pushed a commit that referenced this pull request Nov 26, 2024
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[REFACTOR] Worldpay payments integration
6 participants