Skip to content

Conversation

@Narayanbhat166
Copy link
Contributor

@Narayanbhat166 Narayanbhat166 commented Feb 2, 2023

Type of Change

  • New feature

Description

Add payment_issuer and payment_experience to payment_attempt table. The pay_later issuer will be decided based on this.

a small example of how this could and will be used.
if payment_issuer is klarna and payment_experience is redirect_to_url then klarna payment will be processed through stripe or any supported connector, but if the payment_experience is invoke_sdk_client then the payment will be processed through klarna which supports sdk.

Additional Changes

  • This PR modifies the database schema
    • Add payment_issuser and payment_experience to payment_attempt table. Migrations can be found here.
    • Remove redirect and payment_flow fields from payment_attempt table since those were not used anywhere. Migrations can be found here.

Motivation and Context

#447 Not sure of how we will be handling the billing and shipping address. Currently billing details must be sent in payment_method_data the same way as stripes api.

How did you test it?

  • Klarna
{
"payment_method": "pay_later",
    "payment_issuer": "klarna",
    "payment_experience": "redirect_to_url",
    "payment_method_data": {
        "pay_later": {
            "klarna_redirect": {
                "billing_email" : "[email protected]",
                "billing_country": "US"
            }
        }
    }
}

Screenshot 2023-02-02 at 4 33 31 PM

  • Affirm
{
"payment_method": "pay_later",
    "payment_issuer": "affirm",
    "payment_experience": "redirect_to_url",
    "payment_method_data": {
        "pay_later": {
            "affirm_redirect": {}
        }
    },
}

Screenshot 2023-02-02 at 4 35 20 PM

  • AfterpayClearpay
{
    "payment_issuer": "afterpay_clearpay",
    "payment_experience": "redirect_to_url",
    "payment_method_data": {
        "pay_later": {
            "afterpay_clearpay_redirect": {
                "billing_email": "[email protected]",
                "billing_name": "Example"
            }
        }
    },
    "shipping": {
        "address": {
            "first_name": "example",
            "zip": "123456",
            "line1": "New York",
            "country": "US"
        }
    },
}

Screenshot 2023-02-02 at 4 41 44 PM

  • Mismatched issuer, experience and payment_method_data
{
"payment_method": "pay_later",
    "payment_issuer": "klarna",
    "payment_experience": "redirect_to_url",
    "payment_method_data": {
        "pay_later": {
            "affirm_redirect": {}
        }
    },
}

Screenshot 2023-02-09 at 3 29 28 PM

  • Any missing fields, error will be thrown before being sent to the connector.
    Screenshot 2023-02-02 at 4 46 48 PM

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed submitted code

Narayanbhat166 and others added 30 commits January 11, 2023 15:41
There is a use case where missing_required_field error should be raised
when constructing the connector request which is possible using encode function