Paypal subscription buttons now need to be registered on the Paypal website. Unlike the old methods that enabled us to set return urls and invoice number, we must now use JavaScript to call the Paypal identifier for the button registered at Paypal. However the help for custom options is scant and the only recommendation that I could find was tried using the code below. However it doesn't work... if it doesn't return, the client doesn't get our version of an invoice and we don't get notified of the new subscription.
<script src="https://www.paypal.com/sdk/js?client-id=EXAMPLEXYZ&vault=true&intent=subscription" data-sdk-integration-source="button-factory"></script>
<script>
paypal.Buttons({
style: {
shape: 'pill',
color: 'gold',
layout: 'vertical',
label: 'subscribe'
},
createSubscription: function(data, actions) {
return actions.subscription.create({
/* Creates the subscription */
plan_id: 'P-EXAMPLEXYZ'
});
},
onApprove: function(data, actions) {
alert(data.subscriptionID); // You can add optional success message for the subscriber here
actions.redirect('https://example.com/order-return.asp?item_number=<%= strOrderID %>');
}
}).render('#paypal-button-container-P-EXAMPLEXYZ'); // Renders the PayPal button
</script>
Line #18 is not part of the standard button code and was found from online search. But we have yet to see it work. Also, when a subscription is being added and paid at Paypal, we are not receiving a notification email. Has anyone been able to successfully modify these buttons?
NOTE: All help topics that we can find relate to the old method.
window.location.hrefinstead.PAYMENT.SALE.COMPLETED. Other events are not important, all subscription logic can be based on just that one and refreshing a valid-through or (equivalently) a last-paid date every time it is receivedcustom_idparameter when creating the subscription (alongside theplan_id) with a relevant value such as your<%= strOrderID %>. This custom_id will be returned in all webhooks for the subscription.