Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
prasunna09 authored Oct 22, 2023
2 parents 346c8e1 + 664093d commit a476b7a
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 77 deletions.
20 changes: 17 additions & 3 deletions crates/router/src/connector/powertranz/transformers.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use api_models::payments::Card;
use common_utils::pii::Email;
use diesel_models::enums::RefundStatus;
use error_stack::IntoReport;
use masking::Secret;
use serde::{Deserialize, Serialize};
use uuid::Uuid;
Expand Down Expand Up @@ -101,9 +102,22 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PowertranzPaymentsRequest
fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result<Self, Self::Error> {
let source = match item.request.payment_method_data.clone() {
api::PaymentMethodData::Card(card) => Ok(Source::from(&card)),
_ => Err(errors::ConnectorError::NotImplemented(
"Payment method".to_string(),
)),
api::PaymentMethodData::Wallet(_)
| api::PaymentMethodData::CardRedirect(_)
| api::PaymentMethodData::PayLater(_)
| api::PaymentMethodData::BankRedirect(_)
| api::PaymentMethodData::BankDebit(_)
| api::PaymentMethodData::BankTransfer(_)
| api::PaymentMethodData::Crypto(_)
| api::PaymentMethodData::MandatePayment
| api::PaymentMethodData::Reward
| api::PaymentMethodData::Upi(_)
| api::PaymentMethodData::Voucher(_)
| api::PaymentMethodData::GiftCard(_) => Err(errors::ConnectorError::NotSupported {
message: utils::SELECTED_PAYMENT_METHOD.to_string(),
connector: "powertranz",
})
.into_report(),
}?;
// let billing_address = get_address_details(&item.address.billing, &item.request.email);
// let shipping_address = get_address_details(&item.address.shipping, &item.request.email);
Expand Down
97 changes: 49 additions & 48 deletions crates/router/src/routes/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ use crate::{
payment_methods::{Oss, PaymentMethodRetrieve},
payments::{self, PaymentRedirectFlow},
},
openapi::examples::{
PAYMENTS_CREATE, PAYMENTS_CREATE_MINIMUM_FIELDS, PAYMENTS_CREATE_WITH_ADDRESS,
PAYMENTS_CREATE_WITH_CUSTOMER_DATA, PAYMENTS_CREATE_WITH_FORCED_3DS,
PAYMENTS_CREATE_WITH_MANUAL_CAPTURE, PAYMENTS_CREATE_WITH_NOON_ORDER_CATETORY,
PAYMENTS_CREATE_WITH_ORDER_DETAILS,
},
// openapi::examples::{
// PAYMENTS_CREATE, PAYMENTS_CREATE_MINIMUM_FIELDS, PAYMENTS_CREATE_WITH_ADDRESS,
// PAYMENTS_CREATE_WITH_CUSTOMER_DATA, PAYMENTS_CREATE_WITH_FORCED_3DS,
// PAYMENTS_CREATE_WITH_MANUAL_CAPTURE, PAYMENTS_CREATE_WITH_NOON_ORDER_CATETORY,
// PAYMENTS_CREATE_WITH_ORDER_DETAILS,
// },
routes::lock_utils,
services::{api, authentication as auth},
types::{
Expand All @@ -36,48 +36,49 @@ use crate::{
path = "/payments",
request_body(
content = PaymentsCreateRequest,
examples(
(
"Create a payment with minimul fields" = (
value = json!(PAYMENTS_CREATE_MINIMUM_FIELDS)
)
),
(
"Create a manual capture payment" = (
value = json!(PAYMENTS_CREATE_WITH_MANUAL_CAPTURE)
)
),
(
"Create a payment with address" = (
value = json!(PAYMENTS_CREATE_WITH_ADDRESS)
)
),
(
"Create a payment with customer details" = (
value = json!(PAYMENTS_CREATE_WITH_CUSTOMER_DATA)
)
),
(
"Create a 3DS payment" = (
value = json!(PAYMENTS_CREATE_WITH_FORCED_3DS)
)
),
(
"Create a payment" = (
value = json!(PAYMENTS_CREATE)
)
),
(
"Create a payment with order details" = (
value = json!(PAYMENTS_CREATE_WITH_ORDER_DETAILS)
)
),
(
"Create a payment with order category for noon" = (
value = json!(PAYMENTS_CREATE_WITH_NOON_ORDER_CATETORY)
)
),
)),
// examples(
// (
// "Create a payment with minimul fields" = (
// value = json!(PAYMENTS_CREATE_MINIMUM_FIELDS)
// )
// ),
// (
// "Create a manual capture payment" = (
// value = json!(PAYMENTS_CREATE_WITH_MANUAL_CAPTURE)
// )
// ),
// (
// "Create a payment with address" = (
// value = json!(PAYMENTS_CREATE_WITH_ADDRESS)
// )
// ),
// (
// "Create a payment with customer details" = (
// value = json!(PAYMENTS_CREATE_WITH_CUSTOMER_DATA)
// )
// ),
// (
// "Create a 3DS payment" = (
// value = json!(PAYMENTS_CREATE_WITH_FORCED_3DS)
// )
// ),
// (
// "Create a payment" = (
// value = json!(PAYMENTS_CREATE)
// )
// ),
// (
// "Create a payment with order details" = (
// value = json!(PAYMENTS_CREATE_WITH_ORDER_DETAILS)
// )
// ),
// (
// "Create a payment with order category for noon" = (
// value = json!(PAYMENTS_CREATE_WITH_NOON_ORDER_CATETORY)
// )
// ),
// )
),
responses(
(status = 200, description = "Payment created", body = PaymentsResponse),
(status = 400, description = "Missing Mandatory fields")
Expand Down
26 changes: 0 additions & 26 deletions openapi/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -1063,32 +1063,6 @@
"application/json": {
"schema": {
"$ref": "#/components/schemas/PaymentsCreateRequest"
},
"examples": {
"Create a 3DS payment": {
"value": "{\n \"amount\": 6540,\n \"currency\": \"USD\",\n \"authentication_type\" : \"three_ds\"\n }"
},
"Create a manual capture payment": {
"value": "{\n \"amount\": 6540,\n \"currency\": \"USD\",\n \"capture_method\":\"manual\"\n }"
},
"Create a payment": {
"value": "{\n \"amount\": 6540,\n \"currency\": \"USD\",\n \"payment_id\": \"abcdefghijklmnopqrstuvwxyz\",\n \"customer\": {\n \"id\":\"cus_abcdefgh\",\n \"name\":\"John Dough\",\n \"phone\":\"9999999999\",\n \"email\":\"[email protected]\"\n },\n \"description\": \"Its my first payment request\",\n \"statement_descriptor_name\": \"joseph\",\n \"statement_descriptor_suffix\": \"JS\",\n \"metadata\": {\n \"udf1\": \"some-value\",\n \"udf2\": \"some-value\"\n }\n }"
},
"Create a payment with address": {
"value": "{\n \"amount\": 6540,\n \"currency\": \"USD\",\n \"customer\": {\n \"id\" : \"cus_abcdefgh\"\n },\n \"billing\": {\n \"address\": {\n \"line1\": \"1467\",\n \"line2\": \"Harrison Street\",\n \"line3\": \"Harrison Street\",\n \"city\": \"San Fransico\",\n \"state\": \"California\",\n \"zip\": \"94122\",\n \"country\": \"US\",\n \"first_name\": \"joseph\",\n \"last_name\": \"Doe\"\n },\n \"phone\": {\n \"number\": \"8056594427\",\n \"country_code\": \"+91\"\n }\n }\n }"
},
"Create a payment with customer details": {
"value": "{\n \"amount\": 6540,\n \"currency\": \"USD\",\n \"customer\": {\n \"id\":\"cus_abcdefgh\",\n \"name\":\"John Dough\",\n \"phone\":\"9999999999\",\n \"email\":\"[email protected]\"\n }\n }"
},
"Create a payment with minimul fields": {
"value": "{\n \"amount\": 6540,\n \"currency\": \"USD\",\n }"
},
"Create a payment with order category for noon": {
"value": "{\n \"amount\": 6540,\n \"currency\": \"USD\",\n \"connector_metadata\": {\n \"noon\": {\n \"order_category\":\"shoes\"\n }\n }\n }"
},
"Create a payment with order details": {
"value": "{\n \"amount\": 6540,\n \"currency\": \"USD\",\n \"order_details\": [\n {\n \"product_name\": \"Apple iPhone 15\",\n \"quantity\": 1,\n \"amount\" : 6540\n }\n ]\n }"
}
}
}
},
Expand Down

0 comments on commit a476b7a

Please sign in to comment.