PayPal.Api.Invoice.QrCode C# (CSharp) Méthode

QrCode() public static méthode

Generates a QR code for an invoice, by ID.

The QR code is a PNG image in [Base64-encoded](https://www.base64encode.org/) format that corresponds to the invoice ID. You can generate a QR code for an invoice and add it to a paper or PDF invoice. When a customer uses their mobile device to scan the QR code, he or she is redirected to the PayPal mobile payment flow where he or she can pay online with PayPal or a credit card.

Before you get a QR code, you must:
  1. [Create an invoice](#invoices_create). Specify `[email protected]` as the recipient email address in the `billing_info` object. Use a customer email address only if you want to email the invoice.

  2. [Send an invoice](#invoices_send) to move the invoice from a draft to payable state. If you specify `[email protected]` as the recipient email address, the invoice is not emailed.

public static QrCode ( APIContext apiContext, string invoiceId, int width = 500, int height = 500, string action = "pay" ) : Image
apiContext APIContext APIContext used for the API call.
invoiceId string The ID of the invoice for which to generate a QR code.
width int The width, in pixels, of the QR code image. Valid value is from 150 to 500. Default is 500.
height int The height, in pixels, of the QR code image. Valid value is from 150 to 500. Default is 500.
action string The type of URL for which to generate a QR code. Default is `pay` and is the only supported value.
Résultat Image
        public static Image QrCode(APIContext apiContext, string invoiceId, int width = 500, int height = 500, string action = "pay")
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(invoiceId, "invoiceId");

            var queryParameters = new QueryParameters();
            queryParameters["width"] = width.ToString();
            queryParameters["height"] = height.ToString();
            queryParameters["action"] = action;

            // Configure and send the request
            var pattern = "v1/invoicing/invoices/{0}/qr-code";
            var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { invoiceId }) + queryParameters.ToUrlFormattedString();
            return PayPalResource.ConfigureAndExecute<Image>(apiContext, HttpMethod.GET, resourcePath);
        }