/// <summary> /// Posts the request to Epay API. /// </summary> /// <param name="payment">The payment.</param> /// <param name="purchaseOrder">The purchase order.</param> /// <param name="message">Return message</param> /// <remarks>Info http://epay.bambora.com/en/payment-web-service and http://epay.bambora.com/en/payment-web-service</remarks> /// <returns>A string contains result from epay API</returns> private bool PostRequest(IPayment payment, IPurchaseOrder purchaseOrder, ref string message) { // parameters int amount = int.Parse(Utilities.GetAmount(new Currency(purchaseOrder.Currency), payment.Amount)); int merchantnNumber = int.Parse(EpayConfiguration.Merchant); long transactionId = long.Parse(payment.TransactionID); // response parameters int pbsresponse = -1; int epayrespone = -1; // Build Soap request //http://epay.bambora.com/en/subscription-web-service epayPaymentService.PaymentSoapClient client = new epayPaymentService.PaymentSoapClient("PaymentSoap"); bool isAuthorize = client.credit( amount: amount, merchantnumber: merchantnNumber, orderid: purchaseOrder.OrderNumber, group: "", pwd: "", transactionid: transactionId, epayresponse: ref epayrespone, pbsresponse: ref pbsresponse, invoice: "" ); message = "Credit has been done"; if (isAuthorize.Equals(false)) { message = $"Credit failed. Epay Response Code: {epayrespone}. PBS Response Code: {pbsresponse} "; } return(isAuthorize); }
/// <summary> /// Posts the capture request to Epay API. /// http://epay.bambora.com/en/payment-web-service#553 /// https://ssl.ditonlinebetalingssystem.dk/remote/payment.asmx /// Returns true if payment is captured /// </summary> /// <param name="payment">The payment.</param> /// <param name="purchaseOrder">The purchase order.</param> public bool PostCaptureRequest(IPayment payment, IPurchaseOrder purchaseOrder) { // Check for subscription and then use auth and capture with that instead if (!(string.IsNullOrEmpty(payment.AuthorizationCode))) { return(PostSubscriptionAuthorize(payment, purchaseOrder)); } // initital var currencyCode = purchaseOrder.Currency; // parameters int amount = 0; int.TryParse(Utilities.GetAmount(new Currency(currencyCode), payment.Amount), out amount); int merchantnNumber = int.Parse(EpayConfiguration.Merchant); long transactionId = long.Parse(payment.TransactionID); // response parameters int pbsresponse = -1; int epayrespone = -1; // build body epayPaymentService.PaymentSoapClient client = new epayPaymentService.PaymentSoapClient("PaymentSoap"); bool isCaptured = client.capture( merchantnumber: merchantnNumber, transactionid: transactionId, amount: amount, group: "", invoice: "", pwd: "", orderid: "", pbsResponse: ref pbsresponse, epayresponse: ref epayrespone ); //todo: some bug issue handling return(isCaptured); }