Code Monkey home page Code Monkey logo

Comments (5)

patrickyan avatar patrickyan commented on May 22, 2024

I guess I need explanation on this line:

If you want response data saved from the Stripe response into a section, that section needs to have the filter and the section's field handles must match Stripe's response (_ are automatically converted into -, and vice a versa). This allows the greatest flexibility allowing the Symphony CMS developer to choose what information they want to save in the section.

Take this response

{
  "object": "customer",
  "created": 1378743556,
  "id": "cus_2XccWEuqu6Wuqg",
  "livemode": false,
  "description": null,
  "email": null,
  "delinquent": false,
  "subscription": null,
  "discount": null,
  "account_balance": 0,
  "cards": {
    "object": "list",
    "count": 1,
    "url": "/v1/customers/cus_2XccWEuqu6Wuqg/cards",
    "data": [
      {
        "id": "card_2XccD5dkwFCzmU",
        "object": "card",
        "last4": "4242",
        "type": "Visa",
        "exp_month": 3,
        "exp_year": 2054,
        "fingerprint": "qhjxpr7DiCdFYTlH",
        "customer": "cus_2XccWEuqu6Wuqg",
        "country": "US",
        "name": "Asfds Sgf",
        "address_line1": null,
        "address_line2": null,
        "address_city": null,
        "address_state": null,
        "address_zip": null,
        "address_country": null,
        "cvc_check": "pass",
        "address_line1_check": null,
        "address_zip_check": null
      }
    ]
  },
  "default_card": "card_2XccD5dkwFCzmU"
}

I guess I need to add an event on the page for my users section. Then I need to have fields in that section called id, etc. But how does the cards data get stored in a field?

from stripe.

colinbrogan avatar colinbrogan commented on May 22, 2024

I also ran into the problem of getting stripes 2nd dimension values stored into fields. Looking through the code, I figured how to get them, but I think there is a mistake in how it works.
Creating a field called "handle-handle" or "object-object" in the section's event will capture those responses inside "card". I think this was suppose to be "card-handle" and "card-object". You can make this more sensible naming scheme work if you edit stripe/lib/class.stripegeneral.php on line 90:

                foreach($val as $k => $v) {
                    if(!empty($v)) {
                        $key = str_replace('_', '-', $k);
                        $result[$key . '-' . $k] = $v;
                    }
                }

to this:

                foreach($val as $k => $v) {
                    if(!empty($v)) {
                        $k = str_replace('_', '-', $k); //  $key to $k
                        $result[$key . '-' . $k] = $v;
                    }
                }

Also, the Stripe response your trying to store is up to 3 dimensions with the array. To get the stuff inside [cards][data] you could add some more lines to search for those values like this:

                foreach($val as $k => $v) {
                    if(!is_object($v) && !is_array($v) && !empty($v)) {
                        $k = str_replace('_', '-', $k);
                        $result[$key . '-' . $k] = $v;
                    } elseif (!is_object($v) && !empty($v)) {
                        foreach($v as $k2 => $v2) {
                            $k2 = str_replace('_', '-', $k);
                            $result[$key . '-' . $k . '-' . $k2];
                        }
                    }
                }

You should then be able to post to section fields with cards-data-id or cards-data-last4, etc.
@lewiswharf : Can I suggest these lines be changed in your repo?

from stripe.

lewiswharf avatar lewiswharf commented on May 22, 2024

@colinbrogan sorry I missed this issue. Have your modifications been working?

from stripe.

colinbrogan avatar colinbrogan commented on May 22, 2024

Yes, the first change is in one of my forks. I'm pretty certain that was a coding mistake, no? Did you actually want cards > count in the json to be grabbed from count-count.

I never tried the code for pulling from the 3rd level of nesting in the json, but I'm pretty confident it should work.

This is a bad-ass plugin for a bad-ass payment platform, btw.

from stripe.

lewiswharf avatar lewiswharf commented on May 22, 2024

I'm pretty certain that was a coding mistake, no?

Yes. Thank you for your comments above. I was pulling hairs getting this extension to work with event filters. It's part of a slow project that is actually going live next week so I will get a chance to find some more stupid mistakes In the coming days.

from stripe.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.