mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 18:17:13 +08:00 
			
		
		
		
	feat(connector) : add klarna, afterpay support in Nuvei (#1081)
This commit is contained in:
		| @ -177,6 +177,10 @@ pub enum AlternativePaymentMethodType { | |||||||
|     Ideal, |     Ideal, | ||||||
|     #[serde(rename = "apmgw_EPS")] |     #[serde(rename = "apmgw_EPS")] | ||||||
|     Eps, |     Eps, | ||||||
|  |     #[serde(rename = "apmgw_Afterpay")] | ||||||
|  |     AfterPay, | ||||||
|  |     #[serde(rename = "apmgw_Klarna")] | ||||||
|  |     Klarna, | ||||||
| } | } | ||||||
|  |  | ||||||
| #[serde_with::skip_serializing_none] | #[serde_with::skip_serializing_none] | ||||||
| @ -558,6 +562,34 @@ impl<F> | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | fn get_pay_later_info<F>( | ||||||
|  |     payment_method_type: AlternativePaymentMethodType, | ||||||
|  |     item: &types::RouterData<F, types::PaymentsAuthorizeData, types::PaymentsResponseData>, | ||||||
|  | ) -> Result<NuveiPaymentsRequest, error_stack::Report<errors::ConnectorError>> { | ||||||
|  |     let address = item | ||||||
|  |         .get_billing()? | ||||||
|  |         .address | ||||||
|  |         .as_ref() | ||||||
|  |         .ok_or_else(utils::missing_field_err("billing.address"))?; | ||||||
|  |     let payment_method = payment_method_type; | ||||||
|  |     Ok(NuveiPaymentsRequest { | ||||||
|  |         payment_option: PaymentOption { | ||||||
|  |             alternative_payment_method: Some(AlternativePaymentMethod { | ||||||
|  |                 payment_method, | ||||||
|  |                 ..Default::default() | ||||||
|  |             }), | ||||||
|  |             billing_address: Some(BillingAddress { | ||||||
|  |                 email: item.request.get_email()?, | ||||||
|  |                 first_name: Some(address.get_first_name()?.to_owned()), | ||||||
|  |                 last_name: Some(address.get_last_name()?.to_owned()), | ||||||
|  |                 country: address.get_country()?.to_owned(), | ||||||
|  |             }), | ||||||
|  |             ..Default::default() | ||||||
|  |         }, | ||||||
|  |         ..Default::default() | ||||||
|  |     }) | ||||||
|  | } | ||||||
|  |  | ||||||
| impl<F> | impl<F> | ||||||
|     TryFrom<( |     TryFrom<( | ||||||
|         &types::RouterData<F, types::PaymentsAuthorizeData, types::PaymentsResponseData>, |         &types::RouterData<F, types::PaymentsAuthorizeData, types::PaymentsResponseData>, | ||||||
| @ -617,6 +649,21 @@ impl<F> | |||||||
|                 } |                 } | ||||||
|                 .into()), |                 .into()), | ||||||
|             }, |             }, | ||||||
|  |             api::PaymentMethodData::PayLater(pay_later_data) => match pay_later_data { | ||||||
|  |                 payments::PayLaterData::KlarnaRedirect { .. } => { | ||||||
|  |                     get_pay_later_info(AlternativePaymentMethodType::Klarna, item) | ||||||
|  |                 } | ||||||
|  |                 payments::PayLaterData::AfterpayClearpayRedirect { .. } => { | ||||||
|  |                     get_pay_later_info(AlternativePaymentMethodType::AfterPay, item) | ||||||
|  |                 } | ||||||
|  |                 _ => Err(errors::ConnectorError::NotSupported { | ||||||
|  |                     message: "Buy Now Pay Later".to_string(), | ||||||
|  |                     connector: "Nuvei", | ||||||
|  |                     payment_experience: "RedirectToUrl".to_string(), | ||||||
|  |                 } | ||||||
|  |                 .into()), | ||||||
|  |             }, | ||||||
|  |  | ||||||
|             _ => Err(errors::ConnectorError::NotImplemented("Payment methods".to_string()).into()), |             _ => Err(errors::ConnectorError::NotImplemented("Payment methods".to_string()).into()), | ||||||
|         }?; |         }?; | ||||||
|         let request = Self::try_from(NuveiPaymentRequestData { |         let request = Self::try_from(NuveiPaymentRequestData { | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user