/// <summary> /// API call example for MarkInvoiceAsPaid /// </summary> /// <param name="context"></param> private void MarkInvoiceAsPaid(HttpContext context) { // Collect input params String invoiceId = context.Request.Params["invoiceId"]; String note = context.Request.Params["note"]; String paymentDate = context.Request.Params["paymentDate"]; String paymentMethod = context.Request.Params["paymentMethod"]; OtherPaymentDetailsType paymentDetails = new OtherPaymentDetailsType(); if (note != "") { paymentDetails.note = note; } if (paymentDate != "") { paymentDetails.date = paymentDate; } if(paymentMethod != "") { paymentDetails.method = (PaymentMethodsType) Enum.Parse(typeof(PaymentMethodsType), paymentMethod); } MarkInvoiceAsPaidRequest request = new MarkInvoiceAsPaidRequest(new RequestEnvelope(ERROR_LANGUAGE), invoiceId, paymentDetails); // Create service object and make the API call MarkInvoiceAsPaidResponse response; InvoiceService service; try { service = getService(context); response = service.MarkInvoiceAsPaid(request); } catch (Exception e) { context.Response.Write(e.Message); return; } // Display response values. Dictionary<string, string> keyResponseParams = new Dictionary<string, string>(); keyResponseParams.Add("API status", response.responseEnvelope.ack.ToString()); keyResponseParams.Add("correlationId", response.responseEnvelope.correlationId); keyResponseParams.Add("invoiceId", response.invoiceID); keyResponseParams.Add("invoiceNumber", response.invoiceNumber); keyResponseParams.Add("invoiceUrl", response.invoiceURL); displayResponse(context, "MarkInvoiceAsPaid", keyResponseParams, service.getLastRequest(), service.getLastResponse(), response.error, null); }
/** * Constructor with arguments */ public MarkInvoiceAsPaidRequest(RequestEnvelope requestEnvelope, string invoiceID, OtherPaymentDetailsType payment) { this.requestEnvelope = requestEnvelope; this.invoiceID = invoiceID; this.payment = payment; }
/// <summary> /// API call example for MarkInvoiceAsPaid /// </summary> /// <param name="context"></param> private void MarkInvoiceAsPaid(HttpContext context) { // Collect input params // (Required) ID of the invoice to mark as paid. string invoiceId = context.Request.Params["invoiceId"]; // (Optional) Optional note associated with the payment. string note = context.Request.Params["note"]; // (Required) Date when the invoice was paid. string paymentDate = context.Request.Params["paymentDate"]; //(Optional) Method that can be used to mark an invoice as paid when the payer pays offline. // It is one of the following values: //BankTransfer – Payment is made by a bank transfer. //Cash – Payment is made in cash. //Check – Payment is made by check. //CreditCard – Payment is made by a credit card. //DebitCard – Payment is made by a debit card. //Other – Payment is made by a method not specified in this list. //PayPal – Payment is made by PayPal. //WireTransfer – Payment is made by a wire transfer. string paymentMethod = context.Request.Params["paymentMethod"]; InvoiceModelAlias.OtherPaymentDetailsType paymentDetails = new InvoiceModelAlias.OtherPaymentDetailsType(); if (note != string.Empty) { paymentDetails.note = note; } if (paymentDate != string.Empty) { paymentDetails.date = paymentDate; } if (paymentMethod != string.Empty) { paymentDetails.method = (InvoiceModelAlias.PaymentMethodsType)Enum.Parse(typeof(InvoiceModelAlias.PaymentMethodsType), paymentMethod); } InvoiceModelAlias.RequestEnvelope env = new InvoiceModelAlias.RequestEnvelope(); // (Required) RFC 3066 language in which error messages are returned; // by default it is en_US, which is the only language currently supported. env.errorLanguage = ERROR_LANGUAGE; InvoiceModelAlias.MarkInvoiceAsPaidRequest request = new InvoiceModelAlias.MarkInvoiceAsPaidRequest(env, invoiceId, paymentDetails); // Create service object and make the API call InvoiceModelAlias.MarkInvoiceAsPaidResponse response; InvoiceAlias.InvoiceService service; SignatureCredential cred = SetThirdPartyAuthorization(context); try { service = GetService(context); if (cred != null) { response = service.MarkInvoiceAsPaid(request, cred); } else { response = service.MarkInvoiceAsPaid(request); } } catch (Exception e) { context.Response.Write(e.Message); return; } // Display response values. Dictionary<string, string> keyResponseParams = new Dictionary<string, string>(); //Acknowledgement code. It is one of the following values: //Success – The operation completed successfully. //Failure – The operation failed. //SuccessWithWarning – The operation completed successfully; however, there is a warning message. //FailureWithWarning – The operation failed with a warning message. keyResponseParams.Add("API status", response.responseEnvelope.ack.ToString()); // Correlation identifier. It is a 13-character, // alphanumeric string (for example, db87c705a910e) that is used // only by PayPal Merchant Technical Support. // Note: You must log and store this data for every response you receive. // PayPal Technical Support uses the information to assist with reported issues. keyResponseParams.Add("correlationId", response.responseEnvelope.correlationId); // ID of the invoice marked as paid. keyResponseParams.Add("invoiceId", response.invoiceID); // Number of the invoice marked as paid. keyResponseParams.Add("invoiceNumber", response.invoiceNumber); // URL location where merchants view the invoice details. keyResponseParams.Add("invoiceUrl", response.invoiceURL); displayResponse(context, "MarkInvoiceAsPaid", keyResponseParams, service.getLastRequest(), service.getLastResponse(), response.error, null); }
/// <summary> /// API call example for MarkInvoiceAsPaid /// </summary> /// <param name="context"></param> private void MarkInvoiceAsPaid(HttpContext context) { // Collect input params String invoiceId = context.Request.Params["invoiceId"]; String note = context.Request.Params["note"]; String paymentDate = context.Request.Params["paymentDate"]; String paymentMethod = context.Request.Params["paymentMethod"]; OtherPaymentDetailsType paymentDetails = new OtherPaymentDetailsType(); if (note != "") { paymentDetails.note = note; } if (paymentDate != "") { paymentDetails.date = paymentDate; } if(paymentMethod != "") { paymentDetails.method = (PaymentMethodsType) Enum.Parse(typeof(PaymentMethodsType), paymentMethod); } MarkInvoiceAsPaidRequest request = new MarkInvoiceAsPaidRequest(new RequestEnvelope(ERROR_LANGUAGE), invoiceId, paymentDetails); // Create service object and make the API call InvoiceService service = getService(context); MarkInvoiceAsPaidResponse response = service.MarkInvoiceAsPaid(request); // Process response context.Response.Write("<html><body><textarea rows=30 cols=80>"); ObjectDumper.Write(response, 5, context.Response.Output); context.Response.Write("</textarea></body></html>"); }