Search code examples
paypalpaypal-sandboxpaypal-rest-sdk

PayPal prefil Credit Card detaills


So Im trying to prefil the PayPal Credit Card with infos. Therefore I added a payer to my JSON:

    "amount": {
      "currency_code": "EUR",
      "value": "100",
      "breakdown": {
        "item_total": {"currency_code": "EUR", "value": "100"}
      }
    },
    "items": [
      {
        "name": "First Product Name",
        "description": "Optional descriptive text..",
        "unit_amount": {"currency_code": "EUR", "value": "50"},
        "quantity": "1"
      },
      {
        "name": "Second Product Name",
        "description": "Optional descriptive text..",
        "unit_amount": {"currency_code": "EUR", "value": "50"},
        "quantity": "1"
      },
    ],
    "payer": {
      "name": {
        "given_name": 'PayPal',
        "surname": 'Customer',
      },
      "address": {
        "address_line_1": '123 ABC Street',
        "address_line_2": 'Apt 2',
        "admin_area_2": 'San Jose',
        "admin_area_1": 'CA',
        "postal_code": '95121',
        "country_code": 'US',
      },
    },
    "invoice_id": "invoice_number_2388",

Here

The Problem is that even though I added the payer the Infos arent prefiled in the credit card. What have I done wrong?


Solution

  • The payer object is deprecated. For PayPal, there is payment_source.paypal. For sofort, payment_source.sofort object

    But the main issue seems to be that you're putting this information inside the purchase_units array. It doesn't belong there.

    There is a complete guide for integrating sofort in particular here: https://developer.paypal.com/docs/checkout/apm/sofort/