paypal / paypal-ios

One merchant integration point for all of PayPal's services
Apache License 2.0
59 stars 27 forks source link

Vaulting with Purchase #162

Closed KunJeongPark closed 1 year ago

KunJeongPark commented 1 year ago

Summary of changes

Checklist

Authors

List GitHub usernames for everyone who contributed to this pull request.

No Vault Request:

Method: POST URL: https://api.sandbox.paypal.com/v2/checkout/orders/0EL07199CK987522C/confirm-payment-source Body:

{
  "application_context": {
    "return_url": "sdk.ios.paypal://card/success",
    "cancel_url": "sdk.ios.paypal://card/cancel"
  },
  "payment_source": {
    "card": {
      "number": "4344511979394247",
      "security_code": "123",
      "billing_address": null,
      "name": null,
      "attributes": {
        "verification": {
          "method": "SCA_ALWAYS"
        }
      },
      "expiry": "2025-01"
    }
  }
}

Response After Authorize

{
  "id": "0EL07199CK987522C",
  "status": "COMPLETED",
  "payment_source": {
    "card": {
      "last_digits": "4247",
      "expiry": "2025-01",
      "brand": "VISA",
      "type": "UNKNOWN"
    }
  }

Vault with Purchase Request:

Method: POST URL: https://api.sandbox.paypal.com/v2/checkout/orders/3FB45835KB971130X/confirm-payment-source

Body:

{
  "application_context": {
    "return_url": "sdk.ios.paypal://card/success",
    "cancel_url": "sdk.ios.paypal://card/cancel"
  },
  "payment_source": {
    "card": {
      "number": "4344511979394247",
      "security_code": "123",
      "billing_address": null,
      "name": null,
      "attributes": {
        "vault": {
          "store_in_vault": "ON_SUCCESS"
        },
        "verification": {
          "method": "SCA_ALWAYS"
        },
        "customer": {
          "id": "test567"
        }
      },
      "expiry": "2025-01"
    }
  }
}

Response After Authorize:

{
  "id": "3FB45835KB971130X",
  "status": "COMPLETED",
  "payment_source": {
    "card": {
      "last_digits": "4247",
      "expiry": "2025-01",
      "brand": "VISA",
      "type": "UNKNOWN",
      "attributes": {
        "vault": {
          "id": "3fb3mfxf",
          "status": "VAULTED",
          "customer": {
            "id": "test567"
          }..