0
votes

I'm using Paypal REST API to charge my subscriptions. My transaction includes a mixture of one-time purchase and recurring payment. One time purchase will charge a user amount X, and recurring payment should create recurring profile which will annually charge a user with amount Y.

Here is what I have. First I call SetExpressCheckoutPayment with the following parameters:

$orderParams = array(
            'PAYMENTREQUEST_0_AMT' => "10",
            'PAYMENTREQUEST_0_CURRENCYCODE' => 'GBP',
            'PAYMENTREQUEST_0_ITEMAMT' => "10",
            'LOGOIMG'=>"http://mywebsite.com/a.jpg",
            "MAXAMT"=>"100",
            "NOSHIPPING"=>"1",
            "ALLOWNOTE"=>"0",
            "BRANDNAME"=>"My website",
            "GIFTRECEIPTENABLE"=>"0",
            "GIFTMESSAGEENABLE"=>"0"
            );


            $item = array(
                'L_PAYMENTREQUEST_0_NAME0' => 'Subscription',
                'L_PAYMENTREQUEST_0_DESC0' => 'Subscription bla bla bla',
                'L_PAYMENTREQUEST_0_AMT0' => "10",
                'L_PAYMENTREQUEST_0_QTY0' => '1',
            );

            $recurringPayment=array();
            $recurringPayment=array(
                "L_BILLINGTYPE0"=>"RecurringPayments",
                "L_BILLINGAGREEMENTDESCRIPTION0"=>""
            );

What I don't know in the code above is how to set amount Y for recurring payment which is different then amount X for one-time payment?

After SetExpressCheckoutPayment is executed, I execute DoExpressCheckoutPayment, and after that I call CreateRecurringPaymentsProfile with the following arguments:

$requestParams=array(
            "TOKEN"=>$token,
            "PROFILESTARTDATE"=>date("Y-m-d\TH:i:s\Z"),
            "DESC"=>"My Subscription",
            "BILLINGPERIOD"=>"Year",
            "BILLINGFREQUENCY"=>"1",
            "AMT"=>"94",
            "CURRENCYCODE"=>"GBP",
            "L_PAYMENTREQUEST_0_ITEMCATEGORY0"=>"Digital",
            "L_PAYMENTREQUEST_0_NAME0"=>"Subscription",
            "L_PAYMENTREQUEST_0_AMT0"=>"10",
            "L_PAYMENTREQUEST_0_QTY0"=>"1",
             );
             $response=$paypal->request("CreateRecurringPaymentsProfile",$requestParams);

Recurring profile is created, but will charge a user an amount X and I don't want that.

Here are responses: Response from SetExpressCheckout

array (size=50)
  'TOKEN' => string 'EC-0G8072749' (length=20)
  'BILLINGAGREEMENTACCEPTEDSTATUS' => string '1' (length=1)
  'CHECKOUTSTATUS' => string 'PaymentActionNotInitiated' (length=25)
  'TIMESTAMP' => string '2014-09-23T16:57:24Z' (length=20)
  'CORRELATIONID' => string 'c0b0e1a38cd36' (length=13)
  'ACK' => string 'Success' (length=7)
  'VERSION' => string '74.0' (length=4)
  'BUILD' => string '12932421' (length=8)
  'EMAIL' => string '[email protected]' (length=27)
  'PAYERID' => string 'KKBJKUR86XT8L' (length=13)
  'PAYERSTATUS' => string 'verified' (length=8)
  'FIRSTNAME' => string 'John' (length=4)
  'LASTNAME' => string 'Doe' (length=3)
  'COUNTRYCODE' => string 'GB' (length=2)
  'CURRENCYCODE' => string 'GBP' (length=3)
  'AMT' => string '94.00' (length=5)
  'ITEMAMT' => string '94.00' (length=5)
  'SHIPPINGAMT' => string '0.00' (length=4)
  'HANDLINGAMT' => string '0.00' (length=4)
  'TAXAMT' => string '0.00' (length=4)
  'INSURANCEAMT' => string '0.00' (length=4)
  'SHIPDISCAMT' => string '0.00' (length=4)
  'L_NAME0' => string 'My Subscription' (length=27)
  'L_QTY0' => string '1' (length=1)
  'L_TAXAMT0' => string '0.00' (length=4)
  'L_AMT0' => string '94.00' (length=5)
  'L_DESC0' => string 'My Subscription' (length=34)
  'L_ITEMWEIGHTVALUE0' => string '   0.00000' (length=10)
  'L_ITEMLENGTHVALUE0' => string '   0.00000' (length=10)
  'L_ITEMWIDTHVALUE0' => string '   0.00000' (length=10)
  'L_ITEMHEIGHTVALUE0' => string '   0.00000' (length=10)
  'PAYMENTREQUEST_0_CURRENCYCODE' => string 'GBP' (length=3)
  'PAYMENTREQUEST_0_AMT' => string '94.00' (length=5)
  'PAYMENTREQUEST_0_ITEMAMT' => string '94.00' (length=5)
  'PAYMENTREQUEST_0_SHIPPINGAMT' => string '0.00' (length=4)
  'PAYMENTREQUEST_0_HANDLINGAMT' => string '0.00' (length=4)
  'PAYMENTREQUEST_0_TAXAMT' => string '0.00' (length=4)
  'PAYMENTREQUEST_0_INSURANCEAMT' => string '0.00' (length=4)
  'PAYMENTREQUEST_0_SHIPDISCAMT' => string '0.00' (length=4)
  'PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED' => string 'false' (length=5)
  'L_PAYMENTREQUEST_0_NAME0' => string 'My Subscription' (length=27)
  'L_PAYMENTREQUEST_0_QTY0' => string '1' (length=1)
  'L_PAYMENTREQUEST_0_TAXAMT0' => string '0.00' (length=4)
  'L_PAYMENTREQUEST_0_AMT0' => string '94.00' (length=5)
  'L_PAYMENTREQUEST_0_DESC0' => string 'My Subscription' (length=34)
  'L_PAYMENTREQUEST_0_ITEMWEIGHTVALUE0' => string '   0.00000' (length=10)
  'L_PAYMENTREQUEST_0_ITEMLENGTHVALUE0' => string '   0.00000' (length=10)
  'L_PAYMENTREQUEST_0_ITEMWIDTHVALUE0' => string '   0.00000' (length=10)
  'L_PAYMENTREQUEST_0_ITEMHEIGHTVALUE0' => string '   0.00000' (length=10)
  'PAYMENTREQUESTINFO_0_ERRORCODE' => string '0' (length=1)

Response from GetExpressCheckoutDetails

array (size=25)
      'TOKEN' => string 'EC-0G807275JM0847749' (length=20)
      'SUCCESSPAGEREDIRECTREQUESTED' => string 'false' (length=5)
      'TIMESTAMP' => string '2014-09-23T16:57:27Z' (length=20)
      'CORRELATIONID' => string '5b9de22225c55' (length=13)
      'ACK' => string 'Success' (length=7)
      'VERSION' => string '74.0' (length=4)
      'BUILD' => string '12932421' (length=8)
      'INSURANCEOPTIONSELECTED' => string 'false' (length=5)
      'SHIPPINGOPTIONISDEFAULT' => string 'false' (length=5)
      'PAYMENTINFO_0_TRANSACTIONID' => string '1SV99367CG387745H' (length=17)
      'PAYMENTINFO_0_TRANSACTIONTYPE' => string 'expresscheckout' (length=15)
      'PAYMENTINFO_0_PAYMENTTYPE' => string 'instant' (length=7)
      'PAYMENTINFO_0_ORDERTIME' => string '2014-09-23T16:57:26Z' (length=20)
      'PAYMENTINFO_0_AMT' => string '94.00' (length=5)
      'PAYMENTINFO_0_FEEAMT' => string '3.40' (length=4)
      'PAYMENTINFO_0_TAXAMT' => string '0.00' (length=4)
      'PAYMENTINFO_0_CURRENCYCODE' => string 'GBP' (length=3)
      'PAYMENTINFO_0_PAYMENTSTATUS' => string 'Completed' (length=9)
      'PAYMENTINFO_0_PENDINGREASON' => string 'None' (length=4)
      'PAYMENTINFO_0_REASONCODE' => string 'None' (length=4)
      'PAYMENTINFO_0_PROTECTIONELIGIBILITY' => string 'Ineligible' (length=10)
      'PAYMENTINFO_0_PROTECTIONELIGIBILITYTYPE' => string 'None' (length=4)
      'PAYMENTINFO_0_SECUREMERCHANTACCOUNTID' => string 'EW93XTSE5SR4G' (length=13)
      'PAYMENTINFO_0_ERRORCODE' => string '0' (length=1)
      'PAYMENTINFO_0_ACK' => string 'Success' (length=7)

Response from CreateRecurringPayment

array (size=9)
      'TIMESTAMP' => string '2014-09-23T16:57:28Z' (length=20)
      'CORRELATIONID' => string 'dd1f80a935b65' (length=13)
      'ACK' => string 'Failure' (length=7)
      'VERSION' => string '74.0' (length=4)
      'BUILD' => string '12932421' (length=8)
      'L_ERRORCODE0' => string '10004' (length=5)
      'L_SHORTMESSAGE0' => string 'Cart item calculation mismatch.' (length=31)
      'L_LONGMESSAGE0' => string 'Cart item calculation mismatch. The regular non-trial billing period amount is different than the sum of the amounts for each item in the cart.' (length=143)
      'L_SEVERITYCODE0' => string 'Error' (length=5)

Thx!

1

1 Answers

1
votes

The recurring amount you have to specify in the "CreateRecurringPaymentsProfile " API , the amount you set in "SetExpressCheckoutPayment " and "DoExpressCheckoutPayment" is for one time time payment .

So ,recurring amount always needs to be passed in the "CreateRecurringPaymentsProfile" API .