I have the code
var body = @"{
""sender_batch_header"": {
""email_subject"": ""You have a payment"",
""sender_batch_id"": ""batch-1564759643870""
},
""items"": [
{
""recipient_type"": ""PHONE"",
""amount"": {
""value"": ""1.00"",
""currency"": ""USD""
},
""receiver"": ""4087811638"",
""note"": ""Payouts sample transaction"",
""sender_item_id"": ""item-1-1564759643870""
},
{
""recipient_type"": ""EMAIL"",
""amount"": {
""value"": ""1.00"",
""currency"": ""USD""
},
""receiver"": ""ps-rec@paypal.com"",
""note"": ""Payouts sample transaction"",
""sender_item_id"": ""item-2-1564759643870""
},
{
""recipient_type"": ""PAYPAL_ID"",
""amount"": {
""value"": ""1.00"",
""currency"": ""USD""
},
""receiver"": ""FSMRBANCV8PSG"",
""note"": ""Payouts sample transaction"",
""sender_item_id"": ""item-3-1564759643871""
}
]
}";
I want the recipiant's email to be a string/ variable, and so I need to escape the double quote, however nothing Ive tried online works. Is this possible? this code is taken from https://www.paypal.com/apex/product-profile/payouts/createPayouts
I cant use \ to escape it, because I have the modifier @, and its in double quotes, so I cant escape it with more quotes.
I want to make EMAIL a variable that can be changed, not a part of the string's text.
Just break the @string
on the part you need to create a variable. Then after adding the variable, start the string again with @string
var emailVar = ""; //email input
var body = @"{
""sender_batch_header"": {
""email_subject"": ""You have a payment"",
""sender_batch_id"": ""batch-1564759643870""
},
""items"": [
{
""recipient_type"": ""PHONE"",
""amount"": {
""value"": ""1.00"",
""currency"": ""USD""
},
""receiver"": ""4087811638"",
""note"": ""Payouts sample transaction"",
""sender_item_id"": ""item-1-1564759643870""
},
{
""recipient_type"": " + "\"" + emailVar + "\"" + @",
""amount"": {
""value"": ""1.00"",
""currency"": ""USD""
},
""receiver"": ""ps-rec@paypal.com"",
""note"": ""Payouts sample transaction"",
""sender_item_id"": ""item-2-1564759643870""
},
{
""recipient_type"": ""PAYPAL_ID"",
""amount"": {
""value"": ""1.00"",
""currency"": ""USD""
},
""receiver"": ""FSMRBANCV8PSG"",
""note"": ""Payouts sample transaction"",
""sender_item_id"": ""item-3-1564759643871""
}
]
}";