/// <summary> /// create the payload for the rest request /// </summary> /// <param name="paymentInfo"><see cref="PaymentInfo" /></param> /// <param name="endpoint"><see cref="WirecardEndpoint" /></param> /// <param name="paymentMethod"><see cref="PaymentMethod" /></param> /// <returns>System.String.</returns> private string CreatePayload(PaymentInfo paymentInfo, WirecardEndpoint endpoint, WirecardPayment paymentMethod) { // create payload class var payload = new Payload { Payment = new Payment { MerchantAccountId = new MerchantAccountId { Value = paymentMethod.MerchantAccountId }, RequestId = paymentInfo.RequestId, TransactionType = (paymentInfo.TransactionType ?? paymentMethod.DefaultTransactionType).ToString().ToLower(), RequestedAmount = paymentInfo.RequestedAmount, AccountHolder = paymentInfo.AccountHolder, Shipping = paymentInfo.Shipping, PaymentMethods = new PaymentMethods { PaymentMethod = new PaymentMethod[] { new PaymentMethod { Name = paymentMethod.Name } } }, SuccessRedirectUrl = GetRedirecturl(endpoint.SuccessRedirectUrl), FailRedirectUrl = GetRedirecturl(endpoint.FailRedirectUrl), CancelRedirectUrl = GetRedirecturl(endpoint.CancelRedirectUrl), Descriptor = "test", Notifications = Notifications.Create(paymentMethod.RequestType, new Notification[] { new Notification { Url = GetRedirecturl(endpoint.IpnDefaultNotificationUrl) }, new Notification { Url = GetRedirecturl(endpoint.IpnSuccessNotificationUrl), TransactionState = TransactionState.Success }, new Notification { Url = GetRedirecturl(endpoint.IpnFailedNotificationUrl), TransactionState = TransactionState.Failed } } ) } }; // create json string form payload class var data = JsonConvert.SerializeObject(payload, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); return(data); }
/// <summary> /// create the payload for the rest request /// </summary> /// <param name="paymentInfo"><see cref="PaymentInfo" /></param> /// <param name="endpoint"><see cref="WirecardEndpoint" /></param> /// <param name="paymentMethod"><see cref="PaymentMethod" /></param> /// <returns>System.String.</returns> private string CreatePayload(PaymentInfo paymentInfo, WirecardEndpoint endpoint, WirecardPayment paymentMethod) { PaymentMethods paymentMethods = null; if (!endpoint.SelectOnWirecardPage) { paymentMethods = new PaymentMethods { PaymentMethod = new PaymentMethod[] { new PaymentMethod { Name = paymentInfo.TypeName ?? paymentMethod.Name } } }; } // create payload class var payment = new Payment { MerchantAccountId = new MerchantAccountId { Value = paymentMethod.MerchantAccountId }, RequestId = paymentInfo.RequestId, TransactionType = (paymentInfo.TransactionType ?? paymentMethod.DefaultTransactionType).ToString().ToLower(), RequestedAmount = paymentInfo.RequestedAmount, AccountHolder = paymentInfo.AccountHolder, Shipping = paymentInfo.Shipping, PaymentMethods = paymentMethods, SuccessRedirectUrl = GetRedirecturl(endpoint.SuccessRedirectUrl), FailRedirectUrl = GetRedirecturl(endpoint.FailRedirectUrl), CancelRedirectUrl = GetRedirecturl(endpoint.CancelRedirectUrl), Descriptor = paymentInfo.Descriptor ?? endpoint.Descriptor, Notifications = Notifications.Create(paymentMethod.RequestType, new Notification[] { new Notification { Url = GetRedirecturl(endpoint.IpnDefaultNotificationUrl) }, new Notification { Url = GetRedirecturl(endpoint.IpnSuccessNotificationUrl), TransactionState = TransactionState.Success }, new Notification { Url = GetRedirecturl(endpoint.IpnFailedNotificationUrl), TransactionState = TransactionState.Failed } } ), Locale = paymentInfo.Locale }; if (!string.IsNullOrEmpty(endpoint.Theme)) { payment.Options = new Models.Options { Theeme = endpoint.Theme }; } // create json string form payload class var data = JsonConvert.SerializeObject(new Payload { Payment = payment }, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); return(data); }