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

Subscriptions feature (ICreateSubscriptionRequest) does not support custom_id #167

Open
michaelkariv opened this issue Mar 10, 2021 · 1 comment

Comments

@michaelkariv
Copy link

michaelkariv commented Mar 10, 2021

Subscriptions feature of PayPal allows sending a custom id to PayPal with the subscription.
This is important if you rely on web hooks flow.
This custom id, sent from the client to PayPal, and PayPal adds it to the subscription events message sent to the web hook end point. This allows the application server associate a payment event or subscription transaction with a specific user whose internal (custom) id the client sent.
custom id field is documented by PayPal inconsistently. It shows up on the documentation for Subscription API. However it is not mentioned in the documentation of how to use Smart Button in Subscriptions.

Though undocumented, It still works. Just add custom_id field to actions.subscription.create parameter

paypal.Buttons({
                createSubscription: function (data, actions) {
                    console.info('createSubscription:', data);
                    return actions.subscription.create({
                        'plan_id': '{{plan_id}}',
                        "custom_id": '5533062234233'
                    });
                },...

Now, the problem with ngx-paypal as of version 7.0.0 is that custom_id is not supported by the ICreateSubscriptionRequest type.

@gh-vaishnavi
Copy link
Contributor

export interface myCustomIPayPalConfig extends IPayPalConfig{
createSubscription?: (data: ICreateSubscriptionCallbackData, actions: myCustomICreateSubscriptionCallbackActions) => void;
}

export interface myCustomICreateSubscriptionCallbackActions extends ICreateSubscriptionCallbackActions {
subscription: {
create: (subscription: myCustomSubscription) => Promise;
};
}

interface myCustomSubscription extends ICreateSubscriptionRequest{
custom_id?:string;
application_context?: IApplicationContext;
}

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

2 participants