# MD for: https://www.mercadopago.com.pe/developers/pt/docs/checkout-api-payments/integration-configuration/yape.md \# Yape Yape is a mobile application that simplifies the process of bank transfers. Users can make transactions easily and quickly directly from their cell phones, after linking their MultiRed debit card to the application. To make a transaction with Yape, first you must generate a token, which is necessary for the payment creation stage. This token can be generated in two ways: directly through an API or using the Mercado Pago JS SDK. In this documentation, you will find all the necessary steps to perform the configuration and integration tests with Yape comprehensively. ## Integração via SDK javascript With Checkout API, it is possible to offer payments via Yape using the JS SDK method to generate a token. For this, it is necessary to send the phone number and OTP (one-time password found in the Yape application) fields. With the token, a payment can be created. To offer payments with Yape, follow these steps. ## Importing MercadoPago.js The first step in the payment integration process with Yape is capturing the OTP (One-time password) and phone number data to generate the payment token. This is done by including the MercadoPago.js library in your project, followed by the form to capture the necessary data. > WARNING > > Important > > If you wish to perform the integration via API, proceed to the section \[Adding form for OTP and phone number capture\](https://www.mercadopago.com.pe/developers/en/docs/checkout-api-payments/integration-configuration/yape#bookmark\_adding\_form\_for\_otp\_and\_phone\_number\_capture) and follow the instructions. Use the following code to import the MercadoPago.js library before adding the form. You can import the library via HTML or Bash. * [bash ](#editor%5F2) * [html ](#editor%5F1) html bash ```
``` Copiar ``` npm install @mercadopago/sdk-js ``` Copiar \## Configure credentials Credentials are unique keys used to identify an integration in your account. They are used to securely capture payments in online stores and other applications. Use the code below to configure your credential, replacing the value \`YOUR\_PUBLIC\_KEY\` with your production Public key available in the application created in \[Your integrations\](https://www.mercadopago.com.pe/developers/panel/app). For more details, see \[credentials\](https://www.mercadopago.com.pe/developers/en/docs/checkout-api-payments/additional-content/your-integrations/credentials). \`\`\` const mp = new MercadoPago("YOUR\_PUBLIC\_KEY"); \`\`\` ## Adding form for OTP and phone number capture To generate a Yape token, you need to fill out the OTP field, which represents the code generated in the Yape application, and the phone number. To capture this data, use the following HTML directly in your project: \`\`\`html Phone Number OTP Create YAPE \`\`\` ## Generate token After completing the inclusion of the form and obtaining the necessary data, generate the Yape token using MercadoPago.js or via API. > NOTE > > The token is single-use per purchase and must be sent during the payment creation stage. ### Generate token via MercadoPago.js Use the \`mp.yape.create\` method to generate a Yape token, as shown in the code below: \`\`\`javascript (async function handleYape () { const otp = docment.getElementById("form-checkout\_\_payerOTP").value; const phoneNumber = docment.getElementById("form-checkout\_\_payerPhone").value; const yapeOptions = { otp, phoneNumber }; const yape = mp.yape(yapeOptions); const yapeToken = await yape.create(); return yapeToken; }); \`\`\` ### Generate token via API Another way to generate the token is through an API. To do this, use the following cURL, filling in the parameters as detailed in the table below. | Field | Type | Description | Required/Optional | Examples/Possible values | |--------------|---------|----------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------|-------------------------------------------| | \`phoneNumber\` | number | Phone number of the payer obtained in the Capture cell phone and OTP data step. | Required | 123214234342 | | \`otp\` | number | Unique numeric 6-digit code found in the Yape app. This field is obtained in the Capture cell phone and OTP data step. | Required | 123344 | | \`requestId\` | string | Field automatically generated by the JS SDK, not necessary to send. Must be sent only in integrations done via cURL. | Required for integrations done via cURL | aaaaaaaa-bbbb-1ccc-8ddd-eeeeeeeeeeee | \`\`\`curl curl --location 'https://api.mercadopago.com/platforms/pci/yape/v1/payment?public\_key=' \\ --header 'Content-Type: application/json' \\ --data '{ "phoneNumber": "123214234342", "otp": "123344", "requestId": "3127367123234234" }' \`\`\` Example response: \`\`\`json { "live\_mode": true, "luhn\_validation": null, "require\_esc": null, "cloned": false, "cardholder": { "identification": { "number": null, "type": null, "subtype": null }, "name": "yape" }, "security\_code\_id": 8069792005119486812, "security\_code\_length": 6, "card\_number\_length": 9, "expiration\_month": 5, "expiration\_year": 2024, "card\_present\_id": null, "card\_id": null, "client\_id": 7775327892346559, "present": null, "id": "45d013f72bf42717a1625f4c508fc20f", "card\_number\_id": "FFTSHQTOSJTXGFVFGJKCBAIVOUISTFZBDRTQWLYJ", "creation\_date": null, "due\_date": null, "last\_modified\_date": null, "product\_id": null, "trust\_level": "unknown", "public\_key": "APP\_USR-352587ca-674b-4ae4-a348-8583ab39b4ac", "site\_id": "MPE", "status": "active", "transaction\_id": null, "trunc\_card\_number": null, "used\_date": null, "bin": "111111", "version": 0, "client\_header": null, "first\_six\_digits": "111111", "last\_four\_digits": "6789" } \`\`\` ## Create payment After adding the form to capture the cell phone and OTP data and generating the token, you must create the payment. To do so, send the token provided by the Mercado Pago JS SDK and all the necessary data to the endpoint \[/v1/payments\](https://www.mercadopago.com.pe/developers/en/reference/online-payments/checkout-api-payments/create-payment/post). These data include 'transaction\_amount', 'installments', 'payment\_method\_id' (specifically 'yape'), and payer information. Alternatively, you can also make the request using one of our \[backend SDKs\](https://www.mercadopago.com.pe/developers/en/docs/sdks-library/landing). Details of each parameter mentioned above, as well as their respective possible values, are described in the following table. > WARNING > > Important > > For this step, when making the request through the API or SDKs, it is necessary to send your productive private key (\_access\_token\_ ). | Field | Type | Description | Required/Optional | Examples/Possible values | |-------------------|---------|---------------------------------------------------------------------------------------------------------------------------------------|---------------------|------------------------------------------| | \`token\` | string | Token provided by the Mercado Pago JS SDK. For more details, see the \[Generate Yape token\](https://www.mercadopago.com.pe/developers/en/docs/checkout-api-payments/integration-configuration/yape#bookmark\_generate\_token) section. | Required | "f8ae90c6a83e71d698d5ea927f851034" | | \`transaction\_amount\`| number | Transaction amount. There is a maximum amount limit that can be S/500, S/900, or S/2000, configured directly within the Yape application. | Required | 2000 | | \`description\` | string | Product title. | Optional | "Video game" | | \`installments\` | number | Number of installments. As it is a debit card payment, the number of installments will be 1\. | Required | 1 | | \`payment\_method\_id\`| string | \`yape\` for all cases. | Required | \`yape\` | | \`payer.email\` | string | Payer's email. | Required | "test\_user\_12345@gmail.com" | * [curl ](#editor%5F10) * [dotnet ](#editor%5F7) * [go ](#editor%5F9) * [java ](#editor%5F3) * [node ](#editor%5F5) * [php ](#editor%5F4) * [python ](#editor%5F6) * [ruby ](#editor%5F8) java php node python dotnet ruby go curl ``` MercadoPagoConfig.setAccessToken("ENV_ACCESS_TOKEN"); PaymentClient client = new PaymentClient(); PaymentCreateRequest createRequest = PaymentCreateRequest.builder() .description("Titulo del producto") .installments(1) .payer(PaymentPayerRequest.builder() .email("test_user_pe@testuser.com") .build()) .paymentMethodId("yape") .token("ff8080814c11e237014c1ff593b57b4d") .transactionAmount(new BigDecimal("5000")) .build(); client.create(createRequest); ``` Copiar ``` MercadoPagoConfig::setAccessToken("ENV_ACCESS_TOKEN"); $client = new PaymentClient(); $createRequest = [ "description" => "Titulo del producto", "installments" => 1, "payer" => [ "email" => "test_user_pe@testuser.com", ], "payment_method_id" => "yape", "token" => "ff8080814c11e237014c1ff593b57b4d", "transaction_amount" => 5000, ]; $client->create($createRequest, $request_options); ``` Copiar ``` const mercadopago = require('mercadopago'); mercadopago.configurations.setAccessToken(config.access_token); var payment = req.body; var payment_data = { token: '