update : sep pay url
This commit is contained in:
@@ -36,17 +36,16 @@ class SepGateway {
|
|||||||
ResNum: Date.now().toString(),
|
ResNum: Date.now().toString(),
|
||||||
CellNumber: mobile,
|
CellNumber: mobile,
|
||||||
};
|
};
|
||||||
console.log("purchase data", purchaseData);
|
|
||||||
const response = await axios.post<SepRequestPaymentResponse>(requesturl, purchaseData, { headers: this.requestHeader });
|
const response = await axios.post<SepRequestPaymentResponse>(requesturl, purchaseData, { headers: this.requestHeader });
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
|
|
||||||
console.log("response data", data);
|
|
||||||
if (data.status == -1) {
|
if (data.status == -1) {
|
||||||
throw new InternalError(data.errorCode + " " + data.errorDesc);
|
throw new InternalError(data.errorCode + " " + data.errorDesc);
|
||||||
}
|
}
|
||||||
|
const redirectUrl = `${this.gatewayApiUrl}/OnlinePG/SendToken?token=${data.token}`;
|
||||||
return {
|
return {
|
||||||
redirectUrl: this.callBackURL,
|
redirectUrl,
|
||||||
message: "successfull",
|
message: "successfull",
|
||||||
authority: data.token,
|
authority: data.token,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ class ZarinPalGateway {
|
|||||||
metadata: { email, mobile },
|
metadata: { email, mobile },
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('purchaseData',purchaseData);
|
|
||||||
|
|
||||||
const response = await axios.post(`${this.gatewayApiUrl}/v4/payment/request.json`, purchaseData, { headers: this.requestHeader });
|
const response = await axios.post(`${this.gatewayApiUrl}/v4/payment/request.json`, purchaseData, { headers: this.requestHeader });
|
||||||
const { data } = response.data as ZarinPalPGNewRequestData;
|
const { data } = response.data as ZarinPalPGNewRequestData;
|
||||||
|
|
||||||
|
|||||||
@@ -136,20 +136,16 @@ class PaymentService {
|
|||||||
if (!paymentMethod) throw new BadRequestError(PaymentMessage.PaymentMethodNotFound);
|
if (!paymentMethod) throw new BadRequestError(PaymentMessage.PaymentMethodNotFound);
|
||||||
|
|
||||||
const { price, description } = this.calculateTotalPrice(cart, cartShipmentItems);
|
const { price, description } = this.calculateTotalPrice(cart, cartShipmentItems);
|
||||||
console.log("start handle payment");
|
|
||||||
// extracted to handle payment creation
|
// extracted to handle payment creation
|
||||||
const { payment, paymentData } = await this.handlePaymentCreation(paymentMethod, price, user, description, session);
|
const { payment, paymentData } = await this.handlePaymentCreation(paymentMethod, price, user, description, session);
|
||||||
console.log("handle payment done");
|
|
||||||
|
|
||||||
console.log("start create order");
|
|
||||||
// create order and order items
|
// create order and order items
|
||||||
const { order, orderItems } = await this.orderService.createOrder(user, payment, cartShipmentItems, session);
|
const { order, orderItems } = await this.orderService.createOrder(user, payment, cartShipmentItems, session);
|
||||||
console.log("create order done");
|
// clear cart and adjust stock
|
||||||
// clear cart and adjust stock
|
await this.finalizeOrder(user, cartShipmentItems, session);
|
||||||
console.log("start finalize order");
|
|
||||||
await this.finalizeOrder(user, cartShipmentItems, session);
|
|
||||||
console.log("Done");
|
|
||||||
|
|
||||||
await session.commitTransaction();
|
await session.commitTransaction();
|
||||||
await session.endSession();
|
await session.endSession();
|
||||||
return { paymentData, order, orderItems };
|
return { paymentData, order, orderItems };
|
||||||
|
|||||||
Reference in New Issue
Block a user