Giter VIP home page Giter VIP logo

echo--script-src-https-www.paypal.com-sdk-js-client-id-su_cliente_id-componentes-su_componentes-s's Introduction

echo--script-src-https-www.paypal.com-sdk-js-client-id-su_cliente_id-componentes-su_componentes-s's People

Contributors

shango420 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

achemuda333

echo--script-src-https-www.paypal.com-sdk-js-client-id-su_cliente_id-componentes-su_componentes-s's Issues

Integración

window.paypal
.Buttons({
style: {
shape: "rect",
layout: "vertical",
},
async createOrder() {
try {
const response = await fetch("/api/orders", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
// use the "body" param to optionally pass additional order information
// like product ids and quantities
body: JSON.stringify({
cart: [
{
id: "YOUR_PRODUCT_ID",
quantity: "YOUR_PRODUCT_QUANTITY",
},
],
}),
});

    const orderData = await response.json();

    if (orderData.id) {
      return orderData.id;
    } else {
      const errorDetail = orderData?.details?.[0];
      const errorMessage = errorDetail
        ? `${errorDetail.issue} ${errorDetail.description} (${orderData.debug_id})`
        : JSON.stringify(orderData);

      throw new Error(errorMessage);
    }
  } catch (error) {
    console.error(error);
    resultMessage(`Could not initiate PayPal Checkout...<br><br>${error}`);
  }
},
async onApprove(data, actions) {
  try {
    const response = await fetch(`/api/orders/${data.orderID}/capture`, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
      },
    });

    const orderData = await response.json();
    // Three cases to handle:
    //   (1) Recoverable INSTRUMENT_DECLINED -> call actions.restart()
    //   (2) Other non-recoverable errors -> Show a failure message
    //   (3) Successful transaction -> Show confirmation or thank you message

    const errorDetail = orderData?.details?.[0];

    if (errorDetail?.issue === "INSTRUMENT_DECLINED") {
      // (1) Recoverable INSTRUMENT_DECLINED -> call actions.restart()
      // recoverable state, per https://developer.paypal.com/docs/checkout/standard/customize/handle-funding-failures/
      return actions.restart();
    } else if (errorDetail) {
      // (2) Other non-recoverable errors -> Show a failure message
      throw new Error(`${errorDetail.description} (${orderData.debug_id})`);
    } else if (!orderData.purchase_units) {
      throw new Error(JSON.stringify(orderData));
    } else {
      // (3) Successful transaction -> Show confirmation or thank you message
      // Or go to another URL:  actions.redirect('thank_you.html');
      const transaction =
        orderData?.purchase_units?.[0]?.payments?.captures?.[0] ||
        orderData?.purchase_units?.[0]?.payments?.authorizations?.[0];
      resultMessage(
        `Transaction ${transaction.status}: ${transaction.id}<br><br>See console for all available details`,
      );
      console.log(
        "Capture result",
        orderData,
        JSON.stringify(orderData, null, 2),
      );
    }
  } catch (error) {
    console.error(error);
    resultMessage(
      `Sorry, your transaction could not be processed...<br><br>${error}`,
    );
  }
},

})
.render("#paypal-button-container");

// Example function to show a result to the user. Your site's UI library can be used instead.
function resultMessage(message) {
const container = document.querySelector("#result-message");
container.innerHTML = message;
}

Prueba

curl -X POST \ 'https://api.sandbox.paypal.com/v2/checkout/orders' \ -H 'accept: application/json' \ -H 'accept-language: en_US' \ -H 'authorization: Bearer A21AAFJ9eoorbnbVH3fTJrCTl2o7-P_1T6q8vdYB_QwBB9Ais5ZZmJD4BsNjIiOh8j8OyOcfzLO1BKcgKe0pK-mntpk6jOm-' \ -H 'content-type: application/json' \ -d '{ "intent": "CAPTURE", "purchase_units": [ { "reference_id": "PUHF", "amount": { "currency_code": "USD", "value": "100.00" } } ], "application_context": { "return_url": "", "cancel_url": "" } }'

Thanks for reporting @mvolpato. I'll have to see how I can reliably get the Process ID on different OS'es. Version `1.3.2` was an update to make sure the action runs on Node 16 instead of 12 so it must be more strict when it comes to errors.

    Thanks for reporting @mvolpato. I'll have to see how I can reliably get the Process ID on different OS'es. Version `1.3.2` was an update to make sure the action runs on Node 16 instead of 12 so it must be more strict when it comes to errors.

Originally posted by @kielabokkie in kielabokkie/ssh-key-and-known-hosts-action#24 (comment)

  • curl -X POST \ 'https://api.sandbox.paypal.com/v2/checkout/orders' \ -H 'accept: application/json' \ -H 'accept-language: en_US' \ -H 'authorization: Bearer A21AAFJ9eoorbnbVH3fTJrCTl2o7-P_1T6q8vdYB_QwBB9Ais5ZZmJD4BsNjIiOh8j8OyOcfzLO1BKcgKe0pK-mntpk6jOm-' \ -H 'content-type: application/json' \ -d '{ "intent": "CAPTURE", "purchase_units": [ { "reference_id": "PUHF", "amount": { "currency_code": "USD", "value": "100.00" } } ], "application_context": { "return_url": "", "cancel_url": "" } }
  • **@ **

Yyt

bitcoin:bc1qchuxhrshdna3xjkqf49y769ytt8zcv03rs3q4m

Made a couple of adjustments, added a changelog entry and rebased. I force pushed the changes, so if you have this checked out locally, you'll need to fetch the changes and reset to the remote branch if you need to make any changes.

Made a couple of adjustments, added a changelog entry and rebased. I force pushed the changes, so if you have this checked out locally, you'll need to fetch the changes and reset to the remote branch if you need to make any changes.

Publicado originalmente por @crookedneighbor en braintree/braintree-web-drop-in#810 (comment)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.