## Checklist
<!-- Put an `x` in the boxes that apply -->
- [x] I formatted the code `cargo +nightly fmt --all`
- [x] I addressed lints thrown by `cargo clippy`
- [x] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible
Type of Change
Description
In the confirm call response sometimes doesn't contain
status
field. This PR handles such cases and marks the payment as pending.How did you test it?
Sanity
Do a confirm call
Response
Response
Do a capture
Response
}'
curl --location 'http://localhost:8080/payments/pay_c5gp7TD38k1V1uq2u2yv/cancel' \ --header 'Content-Type: application/json' \ --header 'api-key: dev_UMYrlrTOfXgmG1cmaM9S6vgFGVUZmli3P5s6tMyPcnn6eYRZju0dx07WqgvEii8y' \ --data '{ "cancellation_reason": "test cancel" }'
{ "payment_id": "pay_c5gp7TD38k1V1uq2u2yv", "merchant_id": "merchant_1719914554", "status": "cancelled", "amount": 1000, "net_amount": 1000, "amount_capturable": 0, "amount_received": null, "connector": "cybersource", "client_secret": "pay_c5gp7TD38k1V1uq2u2yv_secret_zU5g2yR2NkDiwhr8mCjy", "created": "2024-07-02T10:42:07.860Z", "currency": "USD", "customer_id": "ffff", "customer": { "id": "ffff", "name": "John Doe", "email": "abcdef123@gmail.com", "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": null, "capture_on": null, "capture_method": "manual", "payment_method": "card", "payment_method_data": { "card": { "last4": "0002", "card_type": null, "card_network": null, "card_issuer": null, "card_issuing_country": null, "card_isin": "400000", "card_extended_bin": null, "card_exp_month": "10", "card_exp_year": "25", "card_holder_name": "joseph Doe", "payment_checks": { "avs_response": { "code": "Y", "codeRaw": "Y" }, "card_verification": null }, "authentication_data": null }, "billing": null }, "payment_token": "token_uzYvyzQfcuk7b9lJ5qN0", "shipping": { "address": { "city": "San Fransico", "country": "HK", "line1": "1467", "line2": "Harrison Street", "line3": "Harrison Street", "zip": "94122", "state": "California", "first_name": "John", "last_name": "Doe" }, "phone": null, "email": null }, "billing": { "address": { "city": "San Fransico", "country": "MD", "line1": "1467", "line2": "Harrison Street", "line3": "Harrison Street", "zip": "94122", "state": "California", "first_name": "John", "last_name": "Doe" }, "phone": null, "email": null }, "order_details": null, "email": "abcdef123@gmail.com", "name": "John Doe", "phone": "999999999", "return_url": "https://google.com/", "authentication_type": "no_three_ds", "statement_descriptor_name": "joseph", "statement_descriptor_suffix": "JS", "next_action": null, "cancellation_reason": "test cancel", "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": "7199169515866097004953", "frm_message": null, "metadata": null, "connector_metadata": { "apple_pay": null, "airwallex": null, "noon": { "order_category": "pay" } }, "feature_metadata": null, "reference_id": "pay_c5gp7TD38k1V1uq2u2yv_1", "payment_link": null, "profile_id": "pro_FNefrde5oZ4nFPXPgXbY", "surcharge_details": null, "attempt_count": 1, "merchant_decision": null, "merchant_connector_id": "mca_95hO2QEn4SJV4WwUp63I", "incremental_authorization_allowed": false, "authorization_count": null, "incremental_authorizations": null, "external_authentication_details": null, "external_3ds_authentication_attempted": false, "expires_on": "2024-07-02T10:57:07.860Z", "fingerprint": null, "browser_info": { "language": "nl-NL", "time_zone": 0, "ip_address": "13.232.74.226", "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", "color_depth": 24, "java_enabled": true, "screen_width": 1536, "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8", "screen_height": 723, "java_script_enabled": true }, "payment_method_id": null, "payment_method_status": null, "updated": "2024-07-02T10:42:31.886Z", "charges": null, "frm_metadata": null }
curl --location 'http://localhost:8080/payments' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'api-key: dev_UMYrlrTOfXgmG1cmaM9S6vgFGVUZmli3P5s6tMyPcnn6eYRZju0dx07WqgvEii8y' \ --data-raw '{ "amount": 1000, "currency": "USD", "confirm": true, "capture_method": "manual", "capture_on": "2022-09-10T10:11:12Z", "customer_id": "ffff", "email": "abcdef123@gmail.com", "name": "John Doe", "phone": "999999999", "phone_country_code": "+65", "description": "Its my first payment request", "authentication_type": "no_three_ds", "return_url": "https://google.com", "billing": { "address": { "line1": "1467", "line2": "Harrison Street", "line3": "Harrison Street", "city": "San Fransico", "state": "California", "zip": "94122", "country": "MD", "first_name": "John", "last_name": "Doe" } }, "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": "13.232.74.226" }, "shipping": { "address": { "line1": "1467", "line2": "Harrison Street", "line3": "Harrison Street", "city": "San Fransico", "state": "California", "zip": "94122", "country": "HK", "first_name": "John", "last_name": "Doe" } }, "statement_descriptor_name": "joseph", "statement_descriptor_suffix": "JS", "payment_method": "card", "payment_method_data": { "card": { "card_number": "4000000000000002", "card_exp_month": "10", "card_exp_year": "25", "card_holder_name": "joseph Doe", "card_cvc": "123" } }, "connector_metadata": { "noon": { "order_category": "pay" } }
}'
{ "payment_id": "pay_jnsvenuAE36Gj3XUuAuM", "merchant_id": "merchant_1719914554", "status": "requires_capture", "amount": 1000, "net_amount": 1000, "amount_capturable": 1000, "amount_received": null, "connector": "cybersource", "client_secret": "pay_jnsvenuAE36Gj3XUuAuM_secret_JPWuw36ToxqJmW0X4sJO", "created": "2024-07-02T10:44:04.000Z", "currency": "USD", "customer_id": "ffff", "customer": { "id": "ffff", "name": "John Doe", "email": "abcdef123@gmail.com", "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": "manual", "payment_method": "card", "payment_method_data": { "card": { "last4": "0002", "card_type": null, "card_network": null, "card_issuer": null, "card_issuing_country": null, "card_isin": "400000", "card_extended_bin": null, "card_exp_month": "10", "card_exp_year": "25", "card_holder_name": "joseph Doe", "payment_checks": { "avs_response": { "code": "Y", "codeRaw": "Y" }, "card_verification": null }, "authentication_data": null }, "billing": null }, "payment_token": "token_LNtE7zj7ukZQbBbMu3K0", "shipping": { "address": { "city": "San Fransico", "country": "HK", "line1": "1467", "line2": "Harrison Street", "line3": "Harrison Street", "zip": "94122", "state": "California", "first_name": "John", "last_name": "Doe" }, "phone": null, "email": null }, "billing": { "address": { "city": "San Fransico", "country": "MD", "line1": "1467", "line2": "Harrison Street", "line3": "Harrison Street", "zip": "94122", "state": "California", "first_name": "John", "last_name": "Doe" }, "phone": null, "email": null }, "order_details": null, "email": "abcdef123@gmail.com", "name": "John Doe", "phone": "999999999", "return_url": "https://google.com/", "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": "ffff", "created_at": 1719917043, "expires": 1719920643, "secret": "epk_71d023a3453c4087b28cae688d2a3ed7" }, "manual_retry_allowed": false, "connector_transaction_id": "7199170449336280504953", "frm_message": null, "metadata": null, "connector_metadata": { "apple_pay": null, "airwallex": null, "noon": { "order_category": "pay" } }, "feature_metadata": null, "reference_id": "pay_jnsvenuAE36Gj3XUuAuM_1", "payment_link": null, "profile_id": "pro_FNefrde5oZ4nFPXPgXbY", "surcharge_details": null, "attempt_count": 1, "merchant_decision": null, "merchant_connector_id": "mca_95hO2QEn4SJV4WwUp63I", "incremental_authorization_allowed": true, "authorization_count": null, "incremental_authorizations": null, "external_authentication_details": null, "external_3ds_authentication_attempted": false, "expires_on": "2024-07-02T10:59:04.000Z", "fingerprint": null, "browser_info": { "language": "nl-NL", "time_zone": 0, "ip_address": "13.232.74.226", "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", "color_depth": 24, "java_enabled": true, "screen_width": 1536, "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8", "screen_height": 723, "java_script_enabled": true }, "payment_method_id": "pm_ktJzRf8SZkAYuIfwmvMG", "payment_method_status": null, "updated": "2024-07-02T10:44:06.173Z", "charges": null, "frm_metadata": null }
curl --location 'http://localhost:8080/payments' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'api-key: dev_UMYrlrTOfXgmG1cmaM9S6vgFGVUZmli3P5s6tMyPcnn6eYRZju0dx07WqgvEii8y' \ --data '{ "amount": 999, "currency": "USD", "confirm": true, "customer_id": "ffff", "return_url": "https://google.com", "recurring_details": { "type": "payment_method_id", "data": "pm_ktJzRf8SZkAYuIfwmvMG" }, "off_session": true }'
{ "payment_id": "pay_2MMVuMOHmnuZXjxvoMaS", "merchant_id": "merchant_1719914554", "status": "succeeded", "amount": 999, "net_amount": 999, "amount_capturable": 0, "amount_received": 999, "connector": "cybersource", "client_secret": "pay_2MMVuMOHmnuZXjxvoMaS_secret_5BDDAbAvMy4RFBkOAlY8", "created": "2024-07-02T10:44:55.203Z", "currency": "USD", "customer_id": "ffff", "customer": { "id": "ffff", "name": "John Doe", "email": "abcdef123@gmail.com", "phone": "999999999", "phone_country_code": "+65" }, "description": null, "refunds": null, "disputes": null, "mandate_id": null, "mandate_data": null, "setup_future_usage": null, "off_session": null, "capture_on": null, "capture_method": null, "payment_method": "card", "payment_method_data": { "card": { "last4": "0002", "card_type": null, "card_network": null, "card_issuer": null, "card_issuing_country": null, "card_isin": "400000", "card_extended_bin": null, "card_exp_month": "10", "card_exp_year": "25", "card_holder_name": "joseph Doe", "payment_checks": { "avs_response": { "code": "Y", "codeRaw": "Y" }, "card_verification": null }, "authentication_data": null }, "billing": null }, "payment_token": null, "shipping": null, "billing": null, "order_details": null, "email": "abcdef123@gmail.com", "name": "John Doe", "phone": "999999999", "return_url": "https://google.com/", "authentication_type": "no_three_ds", "statement_descriptor_name": null, "statement_descriptor_suffix": null, "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": "ffff", "created_at": 1719917095, "expires": 1719920695, "secret": "epk_e539ad791a7143289a4e6cc7575106b1" }, "manual_retry_allowed": false, "connector_transaction_id": "7199170954366380604953", "frm_message": null, "metadata": null, "connector_metadata": null, "feature_metadata": null, "reference_id": "pay_2MMVuMOHmnuZXjxvoMaS_1", "payment_link": null, "profile_id": "pro_FNefrde5oZ4nFPXPgXbY", "surcharge_details": null, "attempt_count": 1, "merchant_decision": null, "merchant_connector_id": "mca_95hO2QEn4SJV4WwUp63I", "incremental_authorization_allowed": false, "authorization_count": null, "incremental_authorizations": null, "external_authentication_details": null, "external_3ds_authentication_attempted": false, "expires_on": "2024-07-02T10:59:55.203Z", "fingerprint": null, "browser_info": null, "payment_method_id": "pm_ktJzRf8SZkAYuIfwmvMG", "payment_method_status": "active", "updated": "2024-07-02T10:44:56.425Z", "charges": null, "frm_metadata": null }
curl --location 'http://localhost:8080/payments' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'api-key: dev_UMYrlrTOfXgmG1cmaM9S6vgFGVUZmli3P5s6tMyPcnn6eYRZju0dx07WqgvEii8y' \ --data-raw '{ "amount": 0, "currency": "USD", "confirm": true, "capture_method": "manual", "capture_on": "2022-09-10T10:11:12Z", "customer_id": "ffff", "email": "abcdef123@gmail.com", "name": "John Doe", "phone": "999999999", "phone_country_code": "+65", "description": "Its my first payment request", "authentication_type": "no_three_ds", "return_url": "https://google.com", "billing": { "address": { "line1": "1467", "line2": "Harrison Street", "line3": "Harrison Street", "city": "San Fransico", "state": "California", "zip": "94122", "country": "MD", "first_name": "John", "last_name": "Doe" } }, "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": "13.232.74.226" }, "shipping": { "address": { "line1": "1467", "line2": "Harrison Street", "line3": "Harrison Street", "city": "San Fransico", "state": "California", "zip": "94122", "country": "HK", "first_name": "John", "last_name": "Doe" } }, "statement_descriptor_name": "joseph", "statement_descriptor_suffix": "JS", "payment_method": "card", "payment_method_data": { "card": { "card_number": "4000000000000002", "card_exp_month": "10", "card_exp_year": "25", "card_holder_name": "joseph Doe", "card_cvc": "123" } }, "payment_type": "setup_mandate" ,"setup_future_usage": "off_session", "customer_acceptance": { "acceptance_type": "offline", "accepted_at": "1963-05-03T04:07:52.723Z", "online": { "ip_address": "13.232.74.226", "user_agent": "amet irure esse" } } }'
{ "payment_id": "pay_amQ1A6bxB5HfrWskmh92", "merchant_id": "merchant_1719914554", "status": "succeeded", "amount": 0, "net_amount": 0, "amount_capturable": 0, "amount_received": null, "connector": "cybersource", "client_secret": "pay_amQ1A6bxB5HfrWskmh92_secret_eBNr2wSm7by2TzCcXFPG", "created": "2024-07-02T10:51:59.973Z", "currency": "USD", "customer_id": "ffff", "customer": { "id": "ffff", "name": "John Doe", "email": "abcdef123@gmail.com", "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": "manual", "payment_method": "card", "payment_method_data": { "card": { "last4": "0002", "card_type": null, "card_network": null, "card_issuer": null, "card_issuing_country": null, "card_isin": "400000", "card_extended_bin": null, "card_exp_month": "10", "card_exp_year": "25", "card_holder_name": "joseph Doe", "payment_checks": { "avs_response": { "code": "Y", "codeRaw": "Y" }, "card_verification": null }, "authentication_data": null }, "billing": null }, "payment_token": "token_dTAfjLew6dkXKnpRmAqv", "shipping": { "address": { "city": "San Fransico", "country": "HK", "line1": "1467", "line2": "Harrison Street", "line3": "Harrison Street", "zip": "94122", "state": "California", "first_name": "John", "last_name": "Doe" }, "phone": null, "email": null }, "billing": { "address": { "city": "San Fransico", "country": "MD", "line1": "1467", "line2": "Harrison Street", "line3": "Harrison Street", "zip": "94122", "state": "California", "first_name": "John", "last_name": "Doe" }, "phone": null, "email": null }, "order_details": null, "email": "abcdef123@gmail.com", "name": "John Doe", "phone": "999999999", "return_url": "https://google.com/", "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": "ffff", "created_at": 1719917519, "expires": 1719921119, "secret": "epk_dea606b8529a4b89bfdb4ad36dc6c5f4" }, "manual_retry_allowed": false, "connector_transaction_id": "7199175209256331004953", "frm_message": null, "metadata": null, "connector_metadata": { "apple_pay": null, "airwallex": null, "noon": { "order_category": "pay" } }, "feature_metadata": null, "reference_id": "pay_amQ1A6bxB5HfrWskmh92_1", "payment_link": null, "profile_id": "pro_FNefrde5oZ4nFPXPgXbY", "surcharge_details": null, "attempt_count": 1, "merchant_decision": null, "merchant_connector_id": "mca_95hO2QEn4SJV4WwUp63I", "incremental_authorization_allowed": false, "authorization_count": null, "incremental_authorizations": null, "external_authentication_details": null, "external_3ds_authentication_attempted": false, "expires_on": "2024-07-02T11:06:59.973Z", "fingerprint": null, "browser_info": { "language": "nl-NL", "time_zone": 0, "ip_address": "13.232.74.226", "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", "color_depth": 24, "java_enabled": true, "screen_width": 1536, "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8", "screen_height": 723, "java_script_enabled": true }, "payment_method_id": "pm_VTHig1GzeJTavFBSCVEE", "payment_method_status": null, "updated": "2024-07-02T10:52:02.279Z", "charges": null, "frm_metadata": null }
curl --location 'http://localhost:8080/payments' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'api-key: dev_UMYrlrTOfXgmG1cmaM9S6vgFGVUZmli3P5s6tMyPcnn6eYRZju0dx07WqgvEii8y' \ --data '{ "amount": 999, "currency": "USD", "confirm": true, "customer_id": "ffff", "return_url": "https://google.com", "recurring_details": { "type": "payment_method_id", "data": "pm_VTHig1GzeJTavFBSCVEE" }, "off_session": true }'
{ "payment_id": "pay_OjCuhi8nv0ex6DtjN9Gx", "merchant_id": "merchant_1719914554", "status": "succeeded", "amount": 999, "net_amount": 999, "amount_capturable": 0, "amount_received": 999, "connector": "cybersource", "client_secret": "pay_OjCuhi8nv0ex6DtjN9Gx_secret_Cmu1rCHeclgj6P6X5uDK", "created": "2024-07-02T10:53:20.823Z", "currency": "USD", "customer_id": "ffff", "customer": { "id": "ffff", "name": "John Doe", "email": "abcdef123@gmail.com", "phone": "999999999", "phone_country_code": "+65" }, "description": null, "refunds": null, "disputes": null, "mandate_id": null, "mandate_data": null, "setup_future_usage": null, "off_session": null, "capture_on": null, "capture_method": null, "payment_method": "card", "payment_method_data": { "card": { "last4": "0002", "card_type": null, "card_network": null, "card_issuer": null, "card_issuing_country": null, "card_isin": "400000", "card_extended_bin": null, "card_exp_month": "10", "card_exp_year": "25", "card_holder_name": "joseph Doe", "payment_checks": { "avs_response": { "code": "Y", "codeRaw": "Y" }, "card_verification": null }, "authentication_data": null }, "billing": null }, "payment_token": null, "shipping": null, "billing": null, "order_details": null, "email": "abcdef123@gmail.com", "name": "John Doe", "phone": "999999999", "return_url": "https://google.com/", "authentication_type": "no_three_ds", "statement_descriptor_name": null, "statement_descriptor_suffix": null, "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": "ffff", "created_at": 1719917600, "expires": 1719921200, "secret": "epk_a57597e7cba14a7ba75314538819cbe6" }, "manual_retry_allowed": false, "connector_transaction_id": "7199176010366471504953", "frm_message": null, "metadata": null, "connector_metadata": null, "feature_metadata": null, "reference_id": "pay_OjCuhi8nv0ex6DtjN9Gx_1", "payment_link": null, "profile_id": "pro_FNefrde5oZ4nFPXPgXbY", "surcharge_details": null, "attempt_count": 1, "merchant_decision": null, "merchant_connector_id": "mca_95hO2QEn4SJV4WwUp63I", "incremental_authorization_allowed": false, "authorization_count": null, "incremental_authorizations": null, "external_authentication_details": null, "external_3ds_authentication_attempted": false, "expires_on": "2024-07-02T11:08:20.823Z", "fingerprint": null, "browser_info": null, "payment_method_id": "pm_VTHig1GzeJTavFBSCVEE", "payment_method_status": "active", "updated": "2024-07-02T10:53:21.991Z", "charges": null, "frm_metadata": null }