paypalrecurly

Recurly Paypal normal workflow


I'm searching for example of implementation for Recurlyjs normal Paypal checkout flow. I suppose to request Billing info from the user besides Paypal token but it's not clear how do I merge them together to use.

Here are docs mentioning normal workflow but no details: https://docs.recurly.com/docs/paypal-payments

Here is example of Paypal express flow: https://github.com/recurly/recurly-js-examples/blob/master/public/paypal/index.html . It looks like I need to add [additional-fields] to the form and merge_token_fields, but I can not find appropriate function.

<section>
  <form method="post" action="/api/subscriptions/new">
    <button id="subscribe">Subscribe with PayPal</button>
    <div name="recurly-[additional-fields]></div>  // TODO: fix this
    <input type="hidden" id="recurly-token" name="recurly-token">
  </form>

  <script>
  var form = $('form');
  recurly.configure('PUBLIC_KEY');

  var paypal = recurly.PayPal({
    display: { displayName: 'My product' }
  });

  paypal.on('token', function (token) {
    $('#recurly-token').val(token.id);
    merge_token_fields(); // TODO: fix this
    form[0].submit();
  });

  form.on('submit', function (event) {
    event.preventDefault();
    paypal.start();
  });
  </script>
</section>

Solution

  • The steps you'd want to follow: 1) Get Paypal token 2) Collect billing address (can be done on the recurly.js form and passed to the API) 3) From API, pass the Paypal billing agreement to the account 4) A subsequent request to pass billing address to account as a billing info update