mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 10:06:32 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			573 lines
		
	
	
		
			13 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			573 lines
		
	
	
		
			13 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| import {} from "./Commons";
 | |
| 
 | |
| const successfulNo3DSCardDetails = {
 | |
|   card_number: "4242424242424242",
 | |
|   card_exp_month: "10",
 | |
|   card_exp_year: "50",
 | |
|   card_holder_name: "morino",
 | |
|   card_cvc: "737",
 | |
| };
 | |
| 
 | |
| const successfulThreeDSTestCardDetails = {
 | |
|   card_number: "4000002500003155",
 | |
|   card_exp_month: "10",
 | |
|   card_exp_year: "50",
 | |
|   card_holder_name: "morino",
 | |
|   card_cvc: "737",
 | |
| };
 | |
| 
 | |
| const singleUseMandateData = {
 | |
|   customer_acceptance: {
 | |
|     acceptance_type: "offline",
 | |
|     accepted_at: "1963-05-03T04:07:52.723Z",
 | |
|     online: {
 | |
|       ip_address: "125.0.0.1",
 | |
|       user_agent: "amet irure esse",
 | |
|     },
 | |
|   },
 | |
|   mandate_type: {
 | |
|     single_use: {
 | |
|       amount: 8000,
 | |
|       currency: "USD",
 | |
|     },
 | |
|   },
 | |
| };
 | |
| 
 | |
| const multiUseMandateData = {
 | |
|   customer_acceptance: {
 | |
|     acceptance_type: "offline",
 | |
|     accepted_at: "1963-05-03T04:07:52.723Z",
 | |
|     online: {
 | |
|       ip_address: "125.0.0.1",
 | |
|       user_agent: "amet irure esse",
 | |
|     },
 | |
|   },
 | |
|   mandate_type: {
 | |
|     multi_use: {
 | |
|       amount: 8000,
 | |
|       currency: "USD",
 | |
|     },
 | |
|   },
 | |
| };
 | |
| 
 | |
| export const connectorDetails = {
 | |
|   card_pm: {
 | |
|     PaymentIntent: {
 | |
|       Request: {
 | |
|         currency: "USD",
 | |
|         amount: 1100,
 | |
|         customer_acceptance: null,
 | |
|         setup_future_usage: "on_session",
 | |
|       },
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "requires_payment_method",
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     "3DSManualCapture": {
 | |
|       Request: {
 | |
|         payment_method: "card",
 | |
|         payment_method_data: {
 | |
|           card: successfulThreeDSTestCardDetails,
 | |
|         },
 | |
|         currency: "USD",
 | |
|         customer_acceptance: null,
 | |
|         setup_future_usage: "on_session",
 | |
|       },
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "requires_capture",
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     "3DSAutoCapture": {
 | |
|       Request: {
 | |
|         payment_method: "card",
 | |
|         payment_method_data: {
 | |
|           card: successfulThreeDSTestCardDetails,
 | |
|         },
 | |
|         currency: "USD",
 | |
|         customer_acceptance: null,
 | |
|         setup_future_usage: "on_session",
 | |
|       },
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "requires_customer_action",
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     No3DSManualCapture: {
 | |
|       Request: {
 | |
|         payment_method: "card",
 | |
|         payment_method_data: {
 | |
|           card: successfulNo3DSCardDetails,
 | |
|         },
 | |
|         currency: "USD",
 | |
|         customer_acceptance: null,
 | |
|         setup_future_usage: "on_session",
 | |
|       },
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "requires_capture",
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     No3DSAutoCapture: {
 | |
|       Request: {
 | |
|         payment_method: "card",
 | |
|         payment_method_type: "credit",
 | |
|         payment_method_data: {
 | |
|           card: successfulNo3DSCardDetails,
 | |
|         },
 | |
|         currency: "USD",
 | |
|         amount: 1100,
 | |
|         customer_acceptance: null,
 | |
|         setup_future_usage: "on_session",
 | |
|       },
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "succeeded",
 | |
|           connector: "stripe",
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     Capture: {
 | |
|       Request: {
 | |
|         payment_method: "card",
 | |
|         payment_method_data: {
 | |
|           card: successfulNo3DSCardDetails,
 | |
|         },
 | |
|         currency: "USD",
 | |
|         customer_acceptance: null,
 | |
|       },
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "succeeded",
 | |
|           amount: 6500,
 | |
|           amount_capturable: 0,
 | |
|           amount_received: 6500,
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     PartialCapture: {
 | |
|       Request: {},
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "partially_captured",
 | |
|           amount: 6500,
 | |
|           amount_capturable: 0,
 | |
|           amount_received: 100,
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     Void: {
 | |
|       Request: {},
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "cancelled",
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     MandateSingleUse3DSAutoCapture: {
 | |
|       Request: {
 | |
|         payment_method: "card",
 | |
|         payment_method_data: {
 | |
|           card: successfulThreeDSTestCardDetails,
 | |
|         },
 | |
|         currency: "USD",
 | |
|         mandate_data: singleUseMandateData,
 | |
|       },
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "succeeded",
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     MandateSingleUse3DSManualCapture: {
 | |
|       Request: {
 | |
|         payment_method: "card",
 | |
|         payment_method_data: {
 | |
|           card: successfulThreeDSTestCardDetails,
 | |
|         },
 | |
|         currency: "USD",
 | |
|         mandate_data: singleUseMandateData,
 | |
|       },
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "requires_customer_action",
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     MandateSingleUseNo3DSAutoCapture: {
 | |
|       Request: {
 | |
|         payment_method: "card",
 | |
|         payment_method_data: {
 | |
|           card: successfulNo3DSCardDetails,
 | |
|         },
 | |
|         currency: "USD",
 | |
|         mandate_data: singleUseMandateData,
 | |
|       },
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "succeeded",
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     MandateSingleUseNo3DSManualCapture: {
 | |
|       Request: {
 | |
|         payment_method: "card",
 | |
|         payment_method_data: {
 | |
|           card: successfulNo3DSCardDetails,
 | |
|         },
 | |
|         currency: "USD",
 | |
|         mandate_data: singleUseMandateData,
 | |
|       },
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "requires_capture",
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     MandateMultiUseNo3DSAutoCapture: {
 | |
|       Request: {
 | |
|         payment_method: "card",
 | |
|         payment_method_data: {
 | |
|           card: successfulNo3DSCardDetails,
 | |
|         },
 | |
|         currency: "USD",
 | |
|         mandate_data: multiUseMandateData,
 | |
|       },
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "succeeded",
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     MandateMultiUseNo3DSManualCapture: {
 | |
|       Request: {
 | |
|         payment_method: "card",
 | |
|         payment_method_data: {
 | |
|           card: successfulNo3DSCardDetails,
 | |
|         },
 | |
|         currency: "USD",
 | |
|         mandate_data: multiUseMandateData,
 | |
|       },
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "requires_capture",
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     MandateMultiUse3DSAutoCapture: {
 | |
|       Request: {
 | |
|         payment_method: "card",
 | |
|         payment_method_data: {
 | |
|           card: successfulThreeDSTestCardDetails,
 | |
|         },
 | |
|         currency: "USD",
 | |
|         mandate_data: multiUseMandateData,
 | |
|       },
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "requires_capture",
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     MandateMultiUse3DSManualCapture: {
 | |
|       Request: {
 | |
|         payment_method: "card",
 | |
|         payment_method_data: {
 | |
|           card: successfulThreeDSTestCardDetails,
 | |
|         },
 | |
|         currency: "USD",
 | |
|         mandate_data: multiUseMandateData,
 | |
|       },
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "requires_capture",
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     ZeroAuthMandate: {
 | |
|       Request: {
 | |
|         payment_method: "card",
 | |
|         payment_method_data: {
 | |
|           card: successfulNo3DSCardDetails,
 | |
|         },
 | |
|         currency: "USD",
 | |
|         mandate_data: singleUseMandateData,
 | |
|       },
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "succeeded",
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     SaveCardUseNo3DSAutoCapture: {
 | |
|       Request: {
 | |
|         payment_method: "card",
 | |
|         payment_method_data: {
 | |
|           card: successfulNo3DSCardDetails,
 | |
|         },
 | |
|         currency: "USD",
 | |
|         setup_future_usage: "on_session",
 | |
|         customer_acceptance: {
 | |
|           acceptance_type: "offline",
 | |
|           accepted_at: "1963-05-03T04:07:52.723Z",
 | |
|           online: {
 | |
|             ip_address: "127.0.0.1",
 | |
|             user_agent: "amet irure esse",
 | |
|           },
 | |
|         },
 | |
|       },
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "succeeded",
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     SaveCardUseNo3DSManualCapture: {
 | |
|       Request: {
 | |
|         payment_method: "card",
 | |
|         payment_method_data: {
 | |
|           card: successfulNo3DSCardDetails,
 | |
|         },
 | |
|         currency: "USD",
 | |
|         setup_future_usage: "on_session",
 | |
|         customer_acceptance: {
 | |
|           acceptance_type: "offline",
 | |
|           accepted_at: "1963-05-03T04:07:52.723Z",
 | |
|           online: {
 | |
|             ip_address: "127.0.0.1",
 | |
|             user_agent: "amet irure esse",
 | |
|           },
 | |
|         },
 | |
|       },
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "requires_capture",
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|   },
 | |
|   bank_redirect_pm: {
 | |
|     PaymentIntent: {
 | |
|       Request: {
 | |
|         currency: "EUR",
 | |
|       },
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "requires_payment_method",
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     ideal: {
 | |
|       Request: {
 | |
|         payment_method: "bank_redirect",
 | |
|         payment_method_type: "ideal",
 | |
|         payment_method_data: {
 | |
|           bank_redirect: {
 | |
|             ideal: {
 | |
|               bank_name: "ing",
 | |
|             },
 | |
|           },
 | |
|         },
 | |
|         billing: {
 | |
|           address: {
 | |
|             line1: "1467",
 | |
|             line2: "Harrison Street",
 | |
|             line3: "Harrison Street",
 | |
|             city: "San Fransico",
 | |
|             state: "California",
 | |
|             zip: "94122",
 | |
|             country: "NL",
 | |
|             first_name: "joseph",
 | |
|             last_name: "Doe",
 | |
|           },
 | |
|           phone: {
 | |
|             number: "9123456789",
 | |
|             country_code: "+91",
 | |
|           },
 | |
|         },
 | |
|       },
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "requires_customer_action",
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     giropay: {
 | |
|       Request: {
 | |
|         payment_method: "bank_redirect",
 | |
|         payment_method_type: "giropay",
 | |
|         payment_method_data: {
 | |
|           bank_redirect: {
 | |
|             giropay: {},
 | |
|           },
 | |
|         },
 | |
|         billing: {
 | |
|           address: {
 | |
|             line1: "1467",
 | |
|             line2: "Harrison Street",
 | |
|             line3: "Harrison Street",
 | |
|             city: "San Fransico",
 | |
|             state: "California",
 | |
|             zip: "94122",
 | |
|             country: "DE",
 | |
|             first_name: "joseph",
 | |
|             last_name: "Doe",
 | |
|           },
 | |
|           phone: {
 | |
|             number: "9123456789",
 | |
|             country_code: "+91",
 | |
|           },
 | |
|         },
 | |
|       },
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "failed",
 | |
|           error_code: "payment_method_not_available",
 | |
|           error_message:
 | |
|             "Giropay is deprecated and can no longer be used for payment acceptance. Please refer to https://docs.stripe.com/payments/giropay",
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     sofort: {
 | |
|       Request: {
 | |
|         payment_method: "bank_redirect",
 | |
|         payment_method_type: "sofort",
 | |
|         payment_method_data: {
 | |
|           bank_redirect: {
 | |
|             sofort: {},
 | |
|           },
 | |
|         },
 | |
|         billing: {
 | |
|           address: {
 | |
|             line1: "1467",
 | |
|             line2: "Harrison Street",
 | |
|             line3: "Harrison Street",
 | |
|             city: "San Fransico",
 | |
|             state: "California",
 | |
|             zip: "94122",
 | |
|             country: "DE",
 | |
|             first_name: "joseph",
 | |
|             last_name: "Doe",
 | |
|           },
 | |
|           phone: {
 | |
|             number: "9123456789",
 | |
|             country_code: "+91",
 | |
|           },
 | |
|         },
 | |
|       },
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "requires_customer_action",
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     eps: {
 | |
|       Request: {
 | |
|         payment_method: "bank_redirect",
 | |
|         payment_method_type: "eps",
 | |
|         payment_method_data: {
 | |
|           bank_redirect: {
 | |
|             eps: {
 | |
|               bank_name: "bank_austria",
 | |
|             },
 | |
|           },
 | |
|         },
 | |
|         billing: {
 | |
|           address: {
 | |
|             line1: "1467",
 | |
|             line2: "Harrison Street",
 | |
|             line3: "Harrison Street",
 | |
|             city: "San Fransico",
 | |
|             state: "California",
 | |
|             zip: "94122",
 | |
|             country: "AT",
 | |
|             first_name: "joseph",
 | |
|             last_name: "Doe",
 | |
|           },
 | |
|           phone: {
 | |
|             number: "9123456789",
 | |
|             country_code: "+91",
 | |
|           },
 | |
|         },
 | |
|       },
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "requires_customer_action",
 | |
|           connector: "stripe",
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     blik: {
 | |
|       Request: {
 | |
|         payment_method: "bank_redirect",
 | |
|         payment_method_type: "blik",
 | |
|         payment_method_data: {
 | |
|           bank_redirect: {
 | |
|             blik: {
 | |
|               blik_code: "777987",
 | |
|             },
 | |
|           },
 | |
|         },
 | |
|       },
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "failed",
 | |
|           error_code: "payment_intent_invalid_parameter",
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     przelewy24: {
 | |
|       Request: {
 | |
|         payment_method: "bank_redirect",
 | |
|         payment_method_type: "przelewy24",
 | |
|         payment_method_data: {
 | |
|           bank_redirect: {
 | |
|             przelewy24: {
 | |
|               bank_name: "citi",
 | |
|               billing_details: {
 | |
|                 email: "guest@juspay.in",
 | |
|               },
 | |
|             },
 | |
|           },
 | |
|         },
 | |
|       },
 | |
|       Response: {
 | |
|         status: 200,
 | |
|         body: {
 | |
|           status: "requires_customer_action",
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|   },
 | |
| };
 | 
