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

Paypal and EU vat issue #294

Closed
MosesSymeonidis opened this issue Jan 12, 2017 · 3 comments
Closed

Paypal and EU vat issue #294

MosesSymeonidis opened this issue Jan 12, 2017 · 3 comments
Labels
V2 V2 Client

Comments

@MosesSymeonidis
Copy link

I try to create subscription with paypal and I want to have EU vat.
I have developed it in three steps, based on the documentation you provide. If I execute these steps one by one manually with a delay everything works fine. If I execute these steps sequentially the address is not updated and for that reason it does not calculate the EU vat. Please provide me some help.

The steps of my code are:
step 1 update billing info with recurly token

final public static function update_billing_info( $id, $recurly_token )
    {
        self::init_recurly();
        $billing_info = new Recurly_BillingInfo();
        $billing_info->account_code = $id;
        $billing_info->token_id = $recurly_token;
        try{
            $billing_info->update();
        }
        catch( Recurly_Error $e ){
            throw new Error( $e->getMessage(), 0 , Error::RECURLY_ERROR );
        }
        return true;
    }

step 2 update only address billing info:

final public static function update_billing_info_address( $id, $address)
    {
        self::init_recurly();
        $billing_info = new Recurly_BillingInfo();
        $billing_info->account_code = $id;
        $billing_info->address1 = $address['address'];
        $billing_info->city = $address['city'];
        $billing_info->country = $address['country'];
        $billing_info->zip = $address['zip'];
        
        try{
            $billing_info->update();
        }
        catch( Recurly_Error $e ){
            throw new Error( $e->getMessage(), 0 , Error::RECURLY_ERROR );
        }
        return true;
    }

step 3 create subscription

final public static function create_subscription_via_paypal( $customer, $starts_at = null, $recurly_coupon = null )
    {
        $cfg = self::init_recurly();
        
        $subscription = new Recurly_Subscription();
        $subscription->plan_code = $customer->plan_type;
        $subscription->currency = $cfg['currency'];
        if ( $starts_at ) {
            $subscription->starts_at = $starts_at;
        }
        if ( $recurly_coupon ) {
            $subscription->coupon_code = $recurly_coupon;
        }
        
        try {
            $subscription->account = Recurly_Account::get( $customer->_id );
        }
        catch ( Recurly_Error $e ) {
            throw new Error( $e->getMessage(), 0, Error::RECURLY_ERROR );
        }

        try {
            $subscription->create();
        }
        catch ( Recurly_Error $e ) {
            throw new Error( $e->getMessage(), 0, Error::RECURLY_ERROR );
        }
        return true;
    }
@nekkon
Copy link

nekkon commented Jan 13, 2017

+1

@MosesSymeonidis
Copy link
Author

I find the solution, with help of recurly's support. My fault was the first step because I updated the billing info but the right way is to create billing info first so I change that:

$billing_info->update();

to

$billing_info->create();

@bhelx
Copy link
Contributor

bhelx commented Jan 18, 2017

Thanks for updating us with your resolution @MosesSymeonidis

@bhelx bhelx added the V2 V2 Client label Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
V2 V2 Client
Projects
None yet
Development

No branches or pull requests

3 participants