Setup Paypal Pre-authorisation and change from free plan to paid play in one request

Craig Willis's Avatar

Craig Willis

21 Jun, 2016 11:57 AM

Afternoon,

  I'm following the instructions on here: http://support.cheddargetter.com/kb/api-8/using-paypal-with-the-api, and I've got the request correctly creating the pre-authorisation, as part of the process of upgrading a user from a free account to a paid account.

  When I view the customer in the system, I can see that the pre-auth has been created and approved, but the planCode has not changed from the free plan to the paid for plan. Do I have to do this in two separate requests? One to capture the pre-auth, and then on a success send you a second request to change the plan?
 
 Thanks

Craig

  1. 1 Posted by Drew Songer on 21 Jun, 2016 01:37 PM

    Drew Songer's Avatar

    You are passing in the new planCode as described the general request dictionary here correct? The Update Subscription API call is the same with the exception of the 4 required fields outlined in the article you referenced.

  2. 2 Posted by Craig Willis on 21 Jun, 2016 01:54 PM

    Craig Willis's Avatar

    Yep. This is an example of the response sent:

    planCode=PROFESSIONALBADGES&subscription[method]=paypal&subscription[ccFirstName]=Craig&subscription[ccLastName]=Willis&subscription[returnUrl]=https%3a%2f%2ftesturl%2f%2fpaymentSuccess&subscription[cancelUrl]=https%3a%2f%2ftesturl%2f%2fpaymentFailure&subscription[changeBillDate]=now

    And this is an example of the result

    <?xml version="1.0" encoding="UTF-8"?>
    <customers>
      <customer id="123d9156-36f7-11e6-bab9-005056a548e6" code="c255c828-8de5-e311-8cfe-78e3b597545b">
        <firstName>Craig</firstName>
        <lastName>Willis</lastName>
        <company>MKM</company>
        <email>[email blocked]</email>
        <notes>Automatically created by MyPayments</notes>
        <gatewayToken/>
        <isVatExempt>0</isVatExempt>
        <vatNumber/>
        <firstContactDatetime/>
        <referer/>
        <refererHost/>
        <campaignSource/>
        <campaignMedium/>
        <campaignTerm/>
        <campaignContent/>
        <campaignName/>
        <key>b7ffd43934</key>
        <createdDatetime>2016-06-20T14:55:47+00:00</createdDatetime>
        <modifiedDatetime>2016-06-20T15:08:22+00:00</modifiedDatetime>
        <metaData/>
        <subscriptions>
          <subscription id="2f1b741f-37a6-11e6-bab9-005056a548e6">
            <plans>
              <plan id="6753a8c0-3212-11e6-bab9-005056a548e6" code="BASICBADGES">
                <name>Basic</name>
                <displayName>Basic</displayName>
                <description/>
                <isActive>1</isActive>
                <isFree>1</isFree>
                <paymentMethodIsRequired>0</paymentMethodIsRequired>
                <trialDays>0</trialDays>
                <initialBillCount>1</initialBillCount>
                <initialBillCountUnit>months</initialBillCountUnit>
                <initialInvoiceBillingDatetime>2016-07-21T13:52:05+00:00</initialInvoiceBillingDatetime>
                <billingFrequency>monthly</billingFrequency>
                <billingFrequencyPer>month</billingFrequencyPer>
                <billingFrequencyUnit>months</billingFrequencyUnit>
                <billingFrequencyQuantity>1</billingFrequencyQuantity>
                <nextInvoiceBillingDatetime>2016-08-21T13:52:05+00:00</nextInvoiceBillingDatetime>
                <setupChargeCode/>
                <setupChargeAmount>0.00</setupChargeAmount>
                <recurringChargeCode>BASICBADGES_RECURRING</recurringChargeCode>
                <recurringChargeAmount>0.00</recurringChargeAmount>
                <onChangeInitialBillHandler>next</onChangeInitialBillHandler>
                <setupChargeBillHandler>now</setupChargeBillHandler>
                <onChangeSetupChargeBillHandler>no</onChangeSetupChargeBillHandler>
                <createdDatetime>2016-06-14T09:28:50+00:00</createdDatetime>
                <items>
                  <item id="0255a09d-323e-11e6-bab9-005056a548e6" code="PackBadges">
                    <name>Badges</name>
                    <quantityIncluded>1.0E+14</quantityIncluded>
                    <isPeriodic>0</isPeriodic>
                    <overageAmount>0.00</overageAmount>
                    <createdDatetime>2016-06-14T14:40:59+00:00</createdDatetime>
                  </item>
                  <item id="59226553-3215-11e6-bab9-005056a548e6" code="MonthBadges">
                    <name>Badges</name>
                    <quantityIncluded>50</quantityIncluded>
                    <isPeriodic>1</isPeriodic>
                    <overageAmount>0.00</overageAmount>
                    <createdDatetime>2016-06-14T09:49:55+00:00</createdDatetime>
                  </item>
                </items>
              </plan>
            </plans>
            <gatewayToken>SIMULATED-5769468516ce7</gatewayToken>
            <gatewayAccount>
              <id>5d942912-322a-11e6-bab9-005056a548e6</id>
              <gateway>PayPal_Simulator</gateway>
              <type>paypal</type>
            </gatewayAccount>
            <redirectUrl>https://cheddargetter.com/service/paypal/simulate/productId/303447cf-3212-11e6-bab9-005056a548e6/id/123d9156-36f7-11e6-bab9-005056a548e6?preapprovalkey=SIMULATED-5769468516ce7</redirectUrl>
            <ccFirstName>Craig</ccFirstName>
            <ccLastName>Willis</ccLastName>
            <ccCompany/>
            <ccCountry/>
            <ccAddress/>
            <ccCity/>
            <ccState/>
            <ccZip/>
            <ccType/>
            <ccLastFour/>
            <ccExpirationDate/>
            <ccEmail/>
            <cancelType>paypal-wait</cancelType>
            <cancelReason>PayPal preapproval is pending</cancelReason>
            <canceledDatetime>2016-06-21T13:52:05+00:00</canceledDatetime>
            <createdDatetime>2016-06-21T11:49:17+00:00</createdDatetime>
            <items>
              <item id="59226553-3215-11e6-bab9-005056a548e6" code="MonthBadges">
                <name>Badges</name>
                <quantity>0</quantity>
              </item>
              <item id="0255a09d-323e-11e6-bab9-005056a548e6" code="PackBadges">
                <name>Badges</name>
                <quantity>0</quantity>
              </item>
            </items>
            <invoices>
              <invoice id="568f558f-37b7-11e6-bab9-005056a548e6">
                <number>5</number>
                <type>subscription</type>
                <vatRate/>
                <billingDatetime>2016-07-21T13:52:04+00:00</billingDatetime>
                <paidTransactionId/>
                <createdDatetime>2016-06-21T13:52:05+00:00</createdDatetime>
                <charges>
                  <charge id="" code="BASICBADGES_RECURRING">
                    <type>recurring</type>
                    <quantity>1</quantity>
                    <eachAmount>0.00</eachAmount>
                    <description/>
                    <createdDatetime>2016-07-21T13:52:04+00:00</createdDatetime>
                  </charge>
                </charges>
              </invoice>
              <invoice id="74b45849-37a3-11e6-bab9-005056a548e6">
                <number>4</number>
                <type>subscription</type>
                <vatRate/>
                <billingDatetime>2016-06-21T13:52:04+00:00</billingDatetime>
                <paidTransactionId/>
                <createdDatetime>2016-06-21T11:29:45+00:00</createdDatetime>
                <charges>
                  <charge id="" code="BASICBADGES_RECURRING">
                    <type>recurring</type>
                    <quantity>1</quantity>
                    <eachAmount>0.00</eachAmount>
                    <description/>
                    <createdDatetime>2016-06-21T13:52:04+00:00</createdDatetime>
                  </charge>
                </charges>
              </invoice>
            </invoices>
          </subscription>
          <subscription id="1b6c94cd-37a6-11e6-bab9-005056a548e6">
            <plans>
              <plan id="bd09aa7a-321e-11e6-bab9-005056a548e6" code="PROFESSIONALBADGES">
                <name>Professional</name>
                <displayName>Professional • 25.00 / Month</displayName>
                <description/>
                <isActive>1</isActive>
                <isFree>0</isFree>
                <paymentMethodIsRequired>1</paymentMethodIsRequired>
                <trialDays>0</trialDays>
                <initialBillCount>1</initialBillCount>
                <initialBillCountUnit>months</initialBillCountUnit>
                <initialInvoiceBillingDatetime>2016-07-21T13:52:05+00:00</initialInvoiceBillingDatetime>
                <billingFrequency>monthly</billingFrequency>
                <billingFrequencyPer>month</billingFrequencyPer>
                <billingFrequencyUnit>months</billingFrequencyUnit>
                <billingFrequencyQuantity>1</billingFrequencyQuantity>
                <nextInvoiceBillingDatetime>2016-08-21T13:52:05+00:00</nextInvoiceBillingDatetime>
                <setupChargeCode>PROFESSIONALBADGES_S</setupChargeCode>
                <setupChargeAmount>0.00</setupChargeAmount>
                <recurringChargeCode>PROFESSIONALBADGES_RECURRING</recurringChargeCode>
                <recurringChargeAmount>25.00</recurringChargeAmount>
                <onChangeInitialBillHandler>next</onChangeInitialBillHandler>
                <setupChargeBillHandler>now</setupChargeBillHandler>
                <onChangeSetupChargeBillHandler>no</onChangeSetupChargeBillHandler>
                <createdDatetime>2016-06-14T10:57:08+00:00</createdDatetime>
                <items>
                  <item id="0255a09d-323e-11e6-bab9-005056a548e6" code="PackBadges">
                    <name>Badges</name>
                    <quantityIncluded>1.0E+14</quantityIncluded>
                    <isPeriodic>0</isPeriodic>
                    <overageAmount>0.00</overageAmount>
                    <createdDatetime>2016-06-14T14:40:59+00:00</createdDatetime>
                  </item>
                  <item id="59226553-3215-11e6-bab9-005056a548e6" code="MonthBadges">
                    <name>Badges</name>
                    <quantityIncluded>2000</quantityIncluded>
                    <isPeriodic>1</isPeriodic>
                    <overageAmount>0.00</overageAmount>
                    <createdDatetime>2016-06-14T10:57:08+00:00</createdDatetime>
                  </item>
                </items>
              </plan>
            </plans>
            <gatewayToken>SIMULATED-5769252250890</gatewayToken>
            <gatewayAccount>
              <id>5d942912-322a-11e6-bab9-005056a548e6</id>
              <gateway>PayPal_Simulator</gateway>
              <type>paypal</type>
            </gatewayAccount>
            <ccFirstName>Craig</ccFirstName>
            <ccLastName>Willis</ccLastName>
            <ccCompany/>
            <ccCountry/>
            <ccAddress/>
            <ccCity/>
            <ccState/>
            <ccZip/>
            <ccType/>
            <ccLastFour/>
            <ccExpirationDate>2019-06-20T00:00:00+00:00</ccExpirationDate>
            <ccEmail>[email blocked]</ccEmail>
            <cancelType/>
            <cancelReason/>
            <canceledDatetime/>
            <createdDatetime>2016-06-21T11:48:44+00:00</createdDatetime>
          </subscription>
          <subscription id="123ec73a-36f7-11e6-bab9-005056a548e6">
            <plans>
              <plan id="6753a8c0-3212-11e6-bab9-005056a548e6" code="BASICBADGES">
                <name>Basic</name>
                <displayName>Basic</displayName>
                <description/>
                <isActive>1</isActive>
                <isFree>1</isFree>
                <paymentMethodIsRequired>0</paymentMethodIsRequired>
                <trialDays>0</trialDays>
                <initialBillCount>1</initialBillCount>
                <initialBillCountUnit>months</initialBillCountUnit>
                <initialInvoiceBillingDatetime>2016-07-21T13:52:05+00:00</initialInvoiceBillingDatetime>
                <billingFrequency>monthly</billingFrequency>
                <billingFrequencyPer>month</billingFrequencyPer>
                <billingFrequencyUnit>months</billingFrequencyUnit>
                <billingFrequencyQuantity>1</billingFrequencyQuantity>
                <nextInvoiceBillingDatetime>2016-08-21T13:52:05+00:00</nextInvoiceBillingDatetime>
                <setupChargeCode/>
                <setupChargeAmount>0.00</setupChargeAmount>
                <recurringChargeCode>BASICBADGES_RECURRING</recurringChargeCode>
                <recurringChargeAmount>0.00</recurringChargeAmount>
                <onChangeInitialBillHandler>next</onChangeInitialBillHandler>
                <setupChargeBillHandler>now</setupChargeBillHandler>
                <onChangeSetupChargeBillHandler>no</onChangeSetupChargeBillHandler>
                <createdDatetime>2016-06-14T09:28:50+00:00</createdDatetime>
                <items>
                  <item id="0255a09d-323e-11e6-bab9-005056a548e6" code="PackBadges">
                    <name>Badges</name>
                    <quantityIncluded>1.0E+14</quantityIncluded>
                    <isPeriodic>0</isPeriodic>
                    <overageAmount>0.00</overageAmount>
                    <createdDatetime>2016-06-14T14:40:59+00:00</createdDatetime>
                  </item>
                  <item id="59226553-3215-11e6-bab9-005056a548e6" code="MonthBadges">
                    <name>Badges</name>
                    <quantityIncluded>50</quantityIncluded>
                    <isPeriodic>1</isPeriodic>
                    <overageAmount>0.00</overageAmount>
                    <createdDatetime>2016-06-14T09:49:55+00:00</createdDatetime>
                  </item>
                </items>
              </plan>
            </plans>
            <gatewayToken>SIMULATED-5769252250890</gatewayToken>
            <gatewayAccount>
              <id>5d942912-322a-11e6-bab9-005056a548e6</id>
              <gateway>PayPal_Simulator</gateway>
              <type>paypal</type>
            </gatewayAccount>
            <ccFirstName>Craig</ccFirstName>
            <ccLastName>Willis</ccLastName>
            <ccCompany/>
            <ccCountry/>
            <ccAddress/>
            <ccCity/>
            <ccState/>
            <ccZip/>
            <ccType/>
            <ccLastFour/>
            <ccExpirationDate>2019-06-20T00:00:00+00:00</ccExpirationDate>
            <ccEmail>[email blocked]</ccEmail>
            <cancelType/>
            <cancelReason/>
            <canceledDatetime/>
            <createdDatetime>2016-06-20T14:55:47+00:00</createdDatetime>
            <invoices>
              <invoice id="1245d6f7-36f7-11e6-bab9-005056a548e6">
                <number>3</number>
                <type>subscription</type>
                <vatRate>0.0000</vatRate>
                <billingDatetime>2016-06-21T11:29:38+00:00</billingDatetime>
                <paidTransactionId>7548f60d-37a3-11e6-bab9-005056a548e6</paidTransactionId>
                <createdDatetime>2016-06-20T14:55:47+00:00</createdDatetime>
                <charges>
                  <charge id="74ba0e86-37a3-11e6-bab9-005056a548e6" code="BASICBADGES_RECURRING">
                    <type>recurring</type>
                    <quantity>1</quantity>
                    <eachAmount>0.00</eachAmount>
                    <description/>
                    <createdDatetime>2016-06-21T11:29:45+00:00</createdDatetime>
                  </charge>
                </charges>
                <transactions>
                  <transaction id="7548f60d-37a3-11e6-bab9-005056a548e6" code="">
                    <parentId/>
                    <gatewayToken/>
                    <gatewayAccount/>
                    <amount>0.00</amount>
                    <memo/>
                    <response>approved</response>
                    <responseReason/>
                    <transactedDatetime>2016-06-21T11:29:46+00:00</transactedDatetime>
                    <createdDatetime>2016-06-21T11:29:46+00:00</createdDatetime>
                  </transaction>
                </transactions>
              </invoice>
            </invoices>
          </subscription>
        </subscriptions>
      </customer>
    </customers>

    I then click approve on the paypal simulator, and I'm sent back to my site, but the license stays on the free plan.

  3. 3 Posted by Drew Songer on 22 Jun, 2016 06:55 PM

    Drew Songer's Avatar

    We are looking into this issue and have enable verbose logging on your MyBadges account so that we can better track what you are doing. Could you run a controlled test on a new record? Let us know when you do that so we can take a better look.

  4. 4 Posted by Craig Willis on 24 Jun, 2016 10:15 AM

    Craig Willis's Avatar

    Drew,

      I've just created the following user:

    1e06339b-39f3-11e6-a93d-005056a548e6

     and then upgraded them to a paid for plan with the paypal stuff, and the approval was accepted. They are still on the free plan.

      I have the fiddler traffic log for the requests if that would be helpful? However I'll need to make this private, or send it to you some other way, as it'll show api key details.

  5. 5 Posted by Craig Willis on 24 Jun, 2016 10:21 AM

    Craig Willis's Avatar

    I do notice that when I'm creating a user, the API documentation says to use subscription[planCode] (http://docs.cheddargetter.com/?php#create-a-new-customer), but when I'm updating the subscription, it says to just use planCode (http://docs.cheddargetter.com/?php#update-a-subscription-only). Will that make a difference?

  6. 6 Posted by Craig Willis on 24 Jun, 2016 10:24 AM

    Craig Willis's Avatar

    Yep, that fixed it. Sending subscription[planCode] instead of just plancode, and the user's plan is changed as part of the request.

  7. Drew Songer closed this discussion on 27 Jun, 2016 03:22 PM.

Discussions are closed to public comments.
If you need help with Cheddar please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

28 Mar, 2024 10:45 PM
24 Jan, 2024 08:33 AM
11 Jan, 2024 07:13 AM
30 Nov, 2023 02:07 AM
22 Nov, 2023 08:41 AM