pronamic / wp-pronamic-pay

The Pronamic Pay plugin allows you to easily accept payments with payment methods like credit card, iDEAL, Bancontact and Sofort through a variety of payment providers on your WordPress website.
https://pronamicpay.com
34 stars 14 forks source link

Store `_pronamic_payment_source` in JSON #232

Closed remcotolsma closed 2 years ago

remcotolsma commented 2 years ago

Should we group _pronamic_payment_source and _pronamic_payment_source_id in a object?

payment {
    "source": {
        "key": "woocommerce",
        "id": "50"
    }
}

or keep it more in line what we have now?

payment {
    "source": "woocommerce",
    "source_id": "50"
}

@rvdsteege ?

rvdsteege commented 2 years ago

I was thinking of grouping it.

remcotolsma commented 2 years ago

I think grouping in an object also has advantages, we could also store additional data in addition to a key and id.

payment {
    "source": {
        "key": "woocommerce",
        "id": "50"
    }
}

Are source.key and source.id the most logic names? Or should we go for source.key and source.value just like meta key and value?

rvdsteege commented 2 years ago

key and value LGTM 👍

remcotolsma commented 2 years ago

Done in https://github.com/pronamic/wp-pay-core/commit/e14edf5d0f452e611f08c597f1073de9c9810f25.

rvdsteege commented 2 years ago
  1. Same for subscriptions?
  2. I think post meta can now override the value from the stored JSON, is that desired? Or should we only read from meta as fallback, when the source details are not yet available in the JSON?
remcotolsma commented 2 years ago
  1. Same for subscriptions?

Yes, it's the same for subscriptions, both Payment and Subscription extend the PaymentInfo class.

  1. I think post meta can now override the value from the stored JSON, is that desired? Or should we only read from meta as fallback, when the source details are not yet available in the JSON?

Good question, it's easier to update post meta than update a JSON property in post_content. We will still use _pronamic_payment_source and _pronamic_payment_source_id for WP_Query. And we have some upgrade scripts in place:

For now i think it's ok that post meta _pronamic_payment_source are _pronamic_payment_source_id are leading. In the future we can always change this behaviour?