commercetools / commercetools-paypal-plus-integration

Integration between commercetools API and PayPal Plus API
Apache License 2.0
7 stars 1 forks source link

How to integrate commercetool with paypal plus #208

Open amolbotre769 opened 2 years ago

amolbotre769 commented 2 years ago

Hi @leungkinghin , you provide the documentation for integration with commercetool but it is really confusing. Problem I faced as I am a new learner of commercetool and wanted to integrate payment system with commercetool and I see the documentation and integration guide but what steps should I follow in order to complete the integration means if you provide step by step integration manual or video then it will be helpful. I hope you understand

amolbotre769 commented 2 years ago

If anyone have any info please help me

leungkinghin-ct commented 2 years ago

Hello @amolbotre769. Thank you for your feedback. Did you check this documentation for integration? https://github.com/commercetools/commercetools-paypal-plus-integration/blob/master/docs/IntegrationGuide.md

May we know any example in this page which make you feel confused ? so that we can have better idea how to improve the documentation.

amolbotre769 commented 2 years ago

Hello @leungkinghin how to do below configuration:- Configuration Application on startup will try to load the required configuration as environment variable named "SPRING_APPLICATION_JSON" :

SPRING_APPLICATION_JSON={"tenantConfig":{"tenants":{"my-commercetools-projectkey1":{"ctp":{"projectKey":"my-commercetools-projectkey1","clientId":"xxx","clientSecret":"xxx"},"paypalPlus":{"id":,"secret": ,"mode": "sandbox"}},"my-commercetools-projectkey2":{"ctp":{"projectKey":"my-commercetools-projectkey2","clientId":"xxx","clientSecret": "xxx"},"paypalPlus":{"id": ,"secret":,"mode":"sandbox"}}}},"ctp.paypal.plus.integration.server.url":} The JSON string should NOT be formatted. Be careful that variables like project key, paypal plus account ID and so on are within the above JSON string. Please change it appropriately before the usage.

amolbotre769 commented 2 years ago

@leungkinghin what is term ${tenantName}?

amolbotre769 commented 2 years ago

@leungkinghin how to set below custom fields for payment:-

Required fields for the CTP payment:

amountPlanned cancelUrl (custom field) successUrl (custom field) reference (custom field, up to 116 characters) languageCode (custom field)

leungkinghin-ct commented 2 years ago

Hello @leungkinghin how to do below configuration:- Configuration Application on startup will try to load the required configuration as environment variable named "SPRING_APPLICATION_JSON" :

SPRING_APPLICATION_JSON={"tenantConfig":{"tenants":{"my-commercetools-projectkey1":{"ctp":{"projectKey":"my-commercetools-projectkey1","clientId":"xxx","clientSecret":"xxx"},"paypalPlus":{"id":,"secret": ,"mode": "sandbox"}},"my-commercetools-projectkey2":{"ctp":{"projectKey":"my-commercetools-projectkey2","clientId":"xxx","clientSecret": "xxx"},"paypalPlus":{"id": ,"secret":,"mode":"sandbox"}}}},"ctp.paypal.plus.integration.server.url":} The JSON string should NOT be formatted. Be careful that variables like project key, paypal plus account ID and so on are within the above JSON string. Please change it appropriately before the usage.

Have you already prepared Commercetools project and corresponding client ID / secret? https://docs.commercetools.com/getting-started/create-api-client

For PayPal sandbox account registration, I would suggest you to get information from here

After that, assign corresponding values into mentioned JSON string, and then export it into SPRING_APPLICATION_JSON as environment variables.

leungkinghin-ct commented 2 years ago

@leungkinghin how to set below custom fields for payment:-

Required fields for the CTP payment:

amountPlanned cancelUrl (custom field) successUrl (custom field) reference (custom field, up to 116 characters) languageCode (custom field)

For amountPlanned, please refer to this documentation

"amountPlanned": {
        "type": "centPrecision",
        "currencyCode": "EUR",
        "centAmount": 1000,
        "fractionDigits": 2
      }

For other custom fields, please refer to this documentation

"custom": {
        "type": {
          "typeId": "type",
          "id": <uuid-identifying-the-type-resource-in-ct-project>
        },
        "fields": {
          "languageCode" : xxx,
          "cancelUrl" : xxx.xxx,
          "successUrl" : xxx.xxx,
          "reference" : xxxyyy
        }
}

Don't forget that you need to define fieldDefinitions for Type resource for custom field before creating payments. For details, please refer to documentation

"resourceTypeIds": [
        "payment"
      ],
"fieldDefinitions": [
        {
          "name": "languageCode",
          "label": {
            "en": "Language code is used to determine the default locale for line item names in the matching cart."
          },
          "required": true,
          "type": {
            "name": "String"
          },
          "inputHint": "SingleLine"
        },
       {
          "name": "cancelUrl",
          "label": {
            "en": "cancelUrl"
          },
          "required": false,
          "type": {
            "name": "String"
          },
          "inputHint": "SingleLine"
        },
        {
          "name": "successUrl",
          "label": {
            "en": "successUrl"
          },
          "required": false,
          "type": {
            "name": "String"
          },
          "inputHint": "SingleLine"
        },
        {
          "name": "reference",
          "label": {
            "en": "reference"
          },
          "required": true,
          "type": {
            "name": "String"
          },
          "inputHint": "SingleLine"
        }
]
leungkinghin-ct commented 2 years ago

@leungkinghin what is term ${tenantName}?

It represents an entity consisting of CT project and Paypal account. If you only have one CT project plus one Paypal testing account, then you can simply define single tenant with whatever tenant name for your application. You can refer to this config skeleton for better understanding

leungkinghin-ct commented 2 years ago

Anyway @amolbotre769 . Thank you for your feedback. We would create internal ticket to follow-up further, so that the documentation you mentioned would be covered in future.

amolbotre769 commented 2 years ago

@leungkinghin what is term ${tenantName}?

It represents an entity consisting of CT project and Paypal account. If you only have one CT project plus one Paypal testing account, then you can simply define single tenant with whatever tenant name for your application. You can refer to this config skeleton for better understanding

I understand it thanks

amolbotre769 commented 2 years ago

Hello @leungkinghin how to do below configuration:- Configuration Application on startup will try to load the required configuration as environment variable named "SPRING_APPLICATION_JSON" : SPRING_APPLICATION_JSON={"tenantConfig":{"tenants":{"my-commercetools-projectkey1":{"ctp":{"projectKey":"my-commercetools-projectkey1","clientId":"xxx","clientSecret":"xxx"},"paypalPlus":{"id":,"secret": ,"mode": "sandbox"}},"my-commercetools-projectkey2":{"ctp":{"projectKey":"my-commercetools-projectkey2","clientId":"xxx","clientSecret": "xxx"},"paypalPlus":{"id": ,"secret":,"mode":"sandbox"}}}},"ctp.paypal.plus.integration.server.url":} The JSON string should NOT be formatted. Be careful that variables like project key, paypal plus account ID and so on are within the above JSON string. Please change it appropriately before the usage.

Have you already prepared Commercetools project and corresponding client ID / secret? https://docs.commercetools.com/getting-started/create-api-client

For PayPal sandbox account registration, I would suggest you to get information from here

After that, assign corresponding values into mentioned JSON string, and then export it into SPRING_APPLICATION_JSON as environment variables.

SPRING_APPLICATION_JSON as environment variables. how do I export it and where I export it? can you please elaborate

leungkinghin-ct commented 2 years ago

@amolbotre769 In the command line interface of your application host, please run following command For UNIX / MacOS export SPRING_APPLICATION_JSON="<your-json-string>"

For Windows set SPRING_APPLICATION_JSON="<your-json-string>"