Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Disable Shipping Adress on Billing Agreements #800

Closed
alexiovay opened this issue Mar 11, 2017 · 2 comments
Closed

Disable Shipping Adress on Billing Agreements #800

alexiovay opened this issue Mar 11, 2017 · 2 comments
Labels

Comments

@alexiovay
Copy link

I want to offer a Premium Membership based on monthly subscriptions and I do not require the adress of the buyer.

In this CreateBillingAgreementWithPayPal example you can set the shipping adress in the agreement. I didn't found a setNoShipping function or something similiar.

How can I disable shipping for an billing agreement, so the asker won't be asked for it in the checkout dialogue?

@knifesk
Copy link

knifesk commented Mar 13, 2017

I haven't set the shipping address in my code (a.k.a. deleted those lines) and it works perfectly, but then in the confirmation screen you have 2 steps, one is the login and the confirmation, the second is the address, which if the user already have completed the address (s)he just clicks continue.. this is my method:

public function createAgreement(
        $id_suscripcion,
        $nombre,
        $descripcion,
        $plan_id,
        $amount,
        $setup_fee,
        $tax,
        $currency,
        &$agreement_id
    ) {
        $now = new Datetime('now');
        $now->add(new \DateInterval('PT2M'));

        $agreement = new Agreement();

        $agreement
                ->setName($nombre)
                ->setDescription($descripcion)
                ->setStartDate($now->format(Datetime::ISO8601));



        //Add Plan ID Please note that the plan Id should be only set in this case.
        $plan = new Plan();
        $plan->setId($plan_id);
        $agreement->setPlan($plan);

        //Add Payer
        $payer = new Payer();
        $payer->setPaymentMethod('paypal');
        $agreement->setPayer($payer);

        //Update URL
        $merchantPreferences = new MerchantPreferences();

        $merchantPreferences
            ->setCancelUrl(\Config::APP_DOMAIN . '/suscripciones/' . $id_suscripcion . '/cancel')
            ->setReturnUrl(\Config::APP_DOMAIN . '/suscripciones/' . $id_suscripcion . '/confirm');

        //Add Taxes
        if ($tax > 0 && $currency !== null) {
            $chargeModel = new ChargeModel();
            $chargeModel->setType('TAX')
                        ->setAmount(new Currency(['value' => $amount * $tax, 'currency' => $currency]));

            $agreement->addOverrideChargeModel($chargeModel);



            if ($setup_fee > 0) {
                $merchantPreferences->setSetupFee(
                    new Currency(['value' => $setup_fee * (1 + $tax), 'currency' => $currency])
                );
            }
        }

        $agreement->setOverrideMerchantPreferences($merchantPreferences);


        //Create Agreement
        try {
            //Please note that as the agreement has not yet activated, we wont be receiving the ID just yet.
            $agreement = $agreement->create($this->apiContext);

            //Get redirect url

            //The API response provides the url that you must redirect the buyer to.
            //Retrieve the url from the $agreement->getApprovalLink() method
            $approvalUrl = $agreement->getApprovalLink();
        } catch (Exception $ex) {
            $this->log->error($ex->getMessage());
            $this->log->error('Exception Code: ' . $ex->getCode());
            $this->log->error('Exception Data: ' . $ex->getData());
            throw new Exception('error_creating_agreement');
        }

        return $approvalUrl;
    }

@xiaoleih41
Copy link
Contributor

The reason you cannot disable shipping address is because payment experience profile is not yet supported in billing plan. Please refer to this open issue https://github.com/paypal/PayPal-REST-API-issues/issues/4 for tracking purpose. I am going to close this ticket as it's a duplicate. Thanks, Xiaolei

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

No branches or pull requests

3 participants