Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving customer and for payment #87

Open
IsmetGlumcevic opened this issue Oct 31, 2024 · 0 comments
Open

Saving customer and for payment #87

IsmetGlumcevic opened this issue Oct 31, 2024 · 0 comments

Comments

@IsmetGlumcevic
Copy link

IsmetGlumcevic commented Oct 31, 2024

Hi, is this options savePaymentMethodFor: 'customer' for tracking customers. Whit this option I get error on payment. If customer is created on createOrder API (https://merchant.revolut.com/api/orders) is available in customers endpoint ('https://merchant.revolut.com/api/1.0/customers')

this is code for checkout

`

    RevolutCheckout(publicId, revolutEnv).then(function (instance) {
      instance.payWithPopup({
        name: user.name,
        email: user.email,
        phone: user.phone,
        upsellBanner: false,
        savePaymentMethodFor: 'customer',
        shippingAddress: {
          countryCode: user.code,
          region: user.country,
          city: user.city,
          streetLine1: user.address,
          postcode: user.zip_code
        },
        billingAddress: {
            countryCode: user.code,
          region: user.country,
          city: user.city,
          streetLine1: user.address,
          postcode: user.zip_code
        },
        onSuccess() {
          setPaymentLoading(true);
          sendOrder(paymentIdVal);
        },
        onError(message) {
          setCreateOrderLoading(false);
          handleOpenNotification("error", "Greška prilikom plaćanja!", "");
        },
        onCancel(){
          setCreateOrderLoading(false);
        },
      });
    });

`

and this is code for create order

`

    const customerObj = {
       full_name: name,
      email: email,
      phone: phone,
     };

   const response = await fetch(
  `${urlRevolutApi}/orders`,
  {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${REVOLUT_MERCHANT_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      amount,
      currency,
      merchant_order_ext_ref: orderNo, 
      customer: customerObject,
    }),
  }
);

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant