0

I am trying to create a recurring profile using express-checkout (Payum/paypal-express-checkout-nvp).

Howto from Payum

private function createAgreement(Purchase $purchase)
{
    $storage = $this->payum->getStorage('Coachup\PaymentBundle\Entity\PaymentAgreement');

    $agreementDetails = $storage->createModel();
    $agreementDetails['L_BILLINGTYPE0'] = Api::BILLINGTYPE_RECURRING_PAYMENTS;
    $agreementDetails['L_BILLINGAGREEMENTDESCRIPTION0'] = 'test';
    $agreementDetails['PAYMENTREQUEST_0_AMT'] = 0;
    $agreementDetails->setPurchase($purchase);

    $storage->updateModel($agreementDetails);

    $captureToken = $this->securityTokenFactory->createCaptureToken(
        $this->paymentName,
        $agreementDetails,
        'payment_checkout_progress_payment',
        ['purchaseId' => $purchase->getId(), 'paymentType' => $this->getId()]
    );

    $agreementDetails['RETURNURL'] = $captureToken->getTargetUrl();
    $agreementDetails['CANCELURL'] = $captureToken->getTargetUrl();
    $storage->updateModel($agreementDetails);

    return $captureToken->getTargetUrl();

}

A token seems to be generated with paypal, the user gets redirected to paypal (sandbox) and once i log in to confirm the agreement, i get a generic error message (loosely translated) "The request can not be processed, please return to the store and choose another option". Not even an error code...

Any help?

Fivetide
  • 161
  • 5
  • I'd advice you to look at http://sandbox.payum.forma-dev.com/. there is an example of recurring payment. It is written on symfony2. The code could be found here: https://github.com/Payum/PayumBundleSandbox/blob/master/src/Acme/PaypalExpressCheckoutBundle/Controller/RecurringPaymentExamplesController.php – Maksim Kotlyar Jun 27 '14 at 06:40
  • when trying to set up a profile with the demo page, i still get the same error. So i guess the problem might be with my sandbox account. Personal/Verified(Premier)/CC and Debit/Enough balance. – Fivetide Jun 29 '14 at 11:47

1 Answers1

1

Its possible that the initial payment of 0.00 is failing, which is making it so the billing agreement is not created. Here is a way that you can override this and create the profile anyway. This comes directly from the PayPal documentation:

By default, PayPal does not activate the profile if the initial payment amount fails. To override this default behavior, set the FAILEDINITAMTACTION field to ContinueOnFailure. If the initial payment amount fails, ContinueOnFailure instructs PayPal to add the failed payment amount to the outstanding balance due on this recurring payment profile.

If you do not set FAILEDINITAMTACTION or set it to CancelOnFailure, PayPal creates the recurring payment profile. However, PayPal places the profile into a pending status until the initial payment completes. If the initial payment clears, PayPal notifies you by Instant Payment Notification (IPN) that it has activated the pending profile. If the payment fails, PayPal notifies you by IPN that it has canceled the pending profile.

If you created the profile using Express Checkout, the buyer receives an email stating that PayPal cleared the initial payment or canceled the pending profile.

Here is the direct link in case you need it:

Recurring Billing Integration Guide

pp_MSI_Jenn
  • 1,589
  • 1
  • 11
  • 15
  • Thanks for your answer. But this did not solve the problem. Right now i suspect the problem being with my sandbox-account, since i get the same error when using payums demo sandbox. The account i use for payment is personal, bank verified, has a valid CC and nearly 1000USD balance. – Fivetide Jun 29 '14 at 11:48