Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Ebert committed Oct 21, 2015
0 parents commit 100c18b
Show file tree
Hide file tree
Showing 25 changed files with 730 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.gradle
.idea
build
local.properties
*.iml
24 changes: 24 additions & 0 deletions LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
SumUp SDK License

SumUp Payments Limited, UK company number 07836562, (“SumUp”), is providing or making available the software code (the “Software”) and all other documents, specifications and other items (the “Documentation”) for use under the terms of this software development kit license agreement (the “Agreement”). By downloading or otherwise gaining access to the Software and Documentation you agree to be bound by this Agreement. SumUp may at any time subject to SumUp’s notice to you in writing or by e-mail renew, modify or amend this Agreement from time to time. SumUp will then make such new version of this Agreement available to you via email or by other means of communication. If you continue to use the Software and Documentation, you are deemed to have accepted such renewal, modification or amendment. If you agree to this Agreement on behalf of your employer or another legal entity, you warrant that you have the right to enter into this Agreement on behalf of such other party.

1. License grant, etc.
Subject to the terms of this Agreement, SumUp hereby grants to you a non-exclusive, non-transferable, non sub-licensable, worldwide, royalty free license to use the Software and Documentation to develop your mobile applications (i.e. one or more software programs developed by you under your own trademark or brand and which will be provided to end-user’s smart phones or tablets from market places such as Google Play Store), in which the Software and Documentation will be incorporated and which will provide access to SumUp’s services. SumUp may without prior notice to you change the form and nature of the Software and Documentation that SumUp provides which may lead to that future versions of the Software and Documentation may be incompatible with mobile applications developed on previous versions of the Software and Documentation. Furthermore, SumUp may stop (permanently or temporarily) providing the Software and Documentation (or any features within the Software and Documentation) to you or to users generally, at SumUp’s sole discretion without prior notice to you. SumUp may make updates of the Software and Documentation at any time, but shall have no obligation what so ever to provide any updates of the Software and Documentation to you. Except to the extent expressly permitted by any applicable third party license, you may not copy (except for backup purposes), modify, adapt, redistribute, decompile, reverse engineer, disassemble, or create derivative works of the Software or Documentation or any part of the Software or Documentation or any services provided by the Software or Documentation. You may not remove, obscure, or alter any proprietary rights notices (including copyright and trademark notices) that may be affixed to or contained within the Software or Documentation. You must comply with all third party licenses in order to use the third party software contained in the Software. No title to the intellectual property in the Software or Documentation is transferred to you under the terms of this Agreement. You do not acquire any rights to the Software or Documentation except as expressly set forth in this Agreement. You agree to use the Software and Documentation for development of your mobile applications only and for purposes that are permitted by (a) this Agreement and (b) any applicable law, regulation or generally accepted practices or guidelines in the relevant jurisdictions (including any laws regarding the export of data or software (including encryption software) to and from the European Union, the United States or other relevant countries). You agree that you will not engage in any activity with the Software or Documentation, including the development or distribution of applications that interferes with, disrupts, damages, or accesses in an unauthorized manner the servers, networks, or other properties or services of SumUp or any third party including, but not limited to any mobile communications carrier. All ownership and intellectual property rights in the Software and Documentation and any copies and derivative works thereof (regardless of form or media in or on which the original or other copies may exist), including but not limited to patents, design rights, copyrights, trade marks, trade-secrets and proprietary know-how, shall be owned by and vested in SumUp, or SumUp’s licensors, and nothing in this Agreement shall constitute or be interpreted as a transfer of such rights from SumUp to you. You are solely entitled to the limited license to the Software or Documentation specifically granted under this Agreement. You acknowledge that the structure and code of the Software are valuable trade secrets of SumUp which shall remain the sole property of SumUp. At present, the Software and Documentation is provided by SumUp to you free of charge. However, SumUp has the right to at any time, if deemed necessary by SumUp, charge you a license fee for the Software and Documentation. If SumUp decides at its own discretion to charge you for the access to and use of the Software and Documentation, SumUp will provide you with an invoice stating inter alia the amount and the bank account number to which you shall transfer such license fee.

2. Disclaimer.
SumUp licenses the Software and Documentation to you only on an "as is" basis without warranties or conditions of any kind, either express or implied, including without limitation any warranties or conditions of title, non-infringement, merchantability or fitness for a particular purpose. SumUp makes no warranty that the Software and Documentation will be error-free. Each user of the Software or Documentation is solely responsible for determining the appropriateness of using the Software and Documentation and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs, or equipment, and unavailability or interruption of operations. Use of the Software and Documentation is made with the understanding that SumUp will not provide you with any technical or customer support or maintenance.

3. Limitation of liability.
Neither SumUp nor its subsidiaries, affiliates, officers, agents or other partners, and employees shall be liable for loss or damage arising out of this Agreement or from the use of the Software or Documentation. In no event will SumUp or its subsidiaries, affiliates, officers, agents or other partners, and employees be liable to you or any third party for any direct, indirect, consequential, incidental, or special damages including lost profits, lost savings, costs, fees, or expenses of any kind arising out of any provision of this agreement or the use or the inability to use the Software or Documentation, however caused and under any theory of liability, whether in contract, strict liability or tort including negligence or otherwise), even if advised of the possibility of such damages. SumUp's aggregate liability and that of its suppliers under or in connection with this Agreement shall be limited to the amount paid by you for the Software and Documentation.

4. Indemnity.
You shall indemnify and hold SumUp and its subsidiaries, affiliates, officers, agents or other partners, and employees, harmless from any claim or demand (including without limitation attorneys’ fees) made by any third party due to or arising out of your use of the Software and Documentation, your breach of this Agreement or your violation of any rights of another person or entity. You agree that you are solely responsible for (and that SumUp has no responsibility to you or to any third party for) any breach of your obligations under this Agreement, any applicable third party contract or any applicable law or regulation, and for the consequences (including any loss or damage which SumUp or any third party may suffer) of any such breach. You may not enter into any settlement or like agreement with any third party that affects SumUp’s right or binds SumUp in any way, without the prior written consent of SumUp.

5. Confidentiality.
You are aware that the Software and Documentation constitute trade secrets and contains confidential information (”Confidential Information”). You agree to protect all Confidential Information using at least the same degree of care that you use to protect your own confidential information, however not less than a reasonable degree of care. You agree to use Confidential Information solely for the purpose of exercising your rights and performing your obligations under this Agreement and agree not to use the Confidential Information for any other purpose, without SumUp’s prior written consent. Furthermore, you agree not to make the Software and Documentation available to a third party without SumUp’s prior written consent and to with take all reasonable measures to ensure that any Confidential Information is not disclosed or otherwise furnished, directly or indirectly, to any third party. Your confidentiality obligation hereunder shall not apply to Confidential Information which You can evidence: (i) is already known by you when received; (ii) is or has becomes public knowledge other than through a breach of this Agreement; (iii) is received from a third party who lawfully acquired it and who is under no obligation restricting its disclosure; or (iv) is to be made publicly available due to a court order, a decision by a public body or as otherwise required by mandatory law. You agree to impose on your employees and consultants, if applicable, in an appropriate manner, the obligations regarding the use of the Software and Documentation set forth in this Agreement and the obligation of confidentiality set out hereunder. You shall be liable in relation to SumUp for your employees’ and consultants’ actions and for their observance of this Agreement and the obligation of confidentiality set out hereunder. Your obligations of confidentiality hereunder shall be valid during the term of this Agreement and continue for a period thereafter of five (5) years after expiration or termination of the Agreement, regardless of the reason therefore.

6. Term.
This Agreement shall commence as set forth above, and continue to be in full force until terminated. SumUp has the right to terminate the Agreement if you fail to comply with any term of the Agreement. Furthermore, either party may terminate this Agreement for its convenience effective thirty (30) days after providing the other party written notice of termination. Upon termination of this Agreement for whatever reason, you agree to immediately cease all use of the Software and Documentation and to erase and destroy all copies of the Software and Documentation in your possession or control. SumUp will not have any liability to compensate you for any damages which you may suffer due to SumUp’s termination of this Agreement.

7. Governing law and dispute resolution.
This Agreement shall be governed by and construed in accordance with English substantive law. Any dispute, controversy or claim arising out of or in connection with this Agreement, or the breach, termination or invalidity thereof, shall be finally settled by arbitration administered by the Courts of England.
171 changes: 171 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
#SumUp Android Payment API

This documentation is intended for app versions 1.55.0 and up.

##I. Getting Started
* Create a SumUp account and get an affiliate key <a href="https://me.sumup.com/integration-tools" target="_blank">here</a>

##II. How to call the Payment API

* **From your app**
* [Option 1](#api-helper) - Use our API Helper library for easy integration
* [Option 2](#uri-call) - Use a URI to call the API
* **From your mobile website** [Payment API - Web](#payment-api---web)

The sample app provided in this repository can be used as a reference.

<a href="https://sumup.com/integration" target="_blank">Full SumUp API Documentation</a>

##API Helper

#####1. Add the repository to your gradle dependencies
```groovy
allprojects {
repositories {
maven { url 'https://maven.sumup.com/releases' }
}
}
```

#####2. Add the dependency to a module
```groovy
compile 'com.sumup:merchant-api:1.0'
```

#####3. Provide a callback activity
```xml
<activity android:name="com.example.ResultActivity" android:label="Payment Result">
<intent-filter>
<action android:name="com.example.ResultActivity"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
</intent-filter>
</activity>
```

#####4. Make a payment
```java
SumUpPayment payment = SumUpPayment.builder()
//mandatory parameters
// Your affiliate key is bound to the applicationID entered in the SumUp dashboard at https://me.sumup.com/integration-tools
.affiliateKey("YOUR_AFFILIATE_KEY")
.productAmount(1.23)
.currency(SumUpPayment.Currency.EUR)
// optional: add details
.productTitle("Taxi Ride")
.receiptEmail("[email protected]")
.receiptSMS("+3531234567890")
// optional: Add metadata
.addAdditionalInfo("AccountId", "taxi0334")
.addAdditionalInfo("From", "Paris")
.addAdditionalInfo("To", "Berlin")
//optional: foreign transaction ID, must be unique!
.foreignTransactionId(UUID.randomUUID().toString()) // can not exceed 128 chars
.build();

SumUpAPI.openPaymentActivity(MainActivity.this, ResponseActivity.class, payment);
```

##URI call

#####1. Provide a callback activity
```xml
<activity
android:name="com.example.URLResponseActivity"
android:label="Payment Result">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<action android:name="com.example.URLResponseActivity"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<!-- Provide your own scheme here and reference it when you make a payment -->
<data
android:scheme="mycallbackscheme"
android:host="result"/>
</intent-filter>
</activity>
```

#####2. Make a payment
```java
Intent payIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(
"sumupmerchant://pay/1.0"
+ "?affiliate-key="YOUR_AFFILIATE_KEY""
+ "&app-id=com.example.myapp"
+ "&amount=1.23"
+ "&currency=EUR"
+ "&title=Taxi Ride"
+ "&receipt-mobilephone=+3531234567890"
+ "&[email protected]"
+ "&foreign-tx-id=" + UUID.randomUUID().toString()
+ "&callback=mycallbackscheme://result"));

startActivityForResult(payIntent, 0);
```

The result is received as a URI in the callback activity intent:

```java
Uri result = getIntent().getData()
```

Success:
```
mycallbackscheme://result?smp-status=success&smp-message=Transaction%20successful.&smp-receipt-sent=false&smp-tx-code=123ABC&foreign-tx-id=0558637a-b73c-43ad-b358-f93cb909251x
```

Failure:
```
mycallbackscheme://result?smp-status=failed&smp-failure-cause=transaction-failed&smp-message=Transaction%20failed.&smp-receipt-sent=false&smp-tx-code=123ABC&foreign-tx-id=05c14c86-a7a0-49c5-a1ec-acb168f5198x
```

###Payment API - Web

Put a link onto your website

```
<a href="sumupmerchant://pay/1.0?affiliate-key=7ca84f17-84a5-4140-8df6-6ebeed8540fc&app-id=com.example.myapp&amount=1.23&currency=EUR&title=Taxi Ride&receipt-mobilephone=+3531234567890&[email protected]&callback=http://example.com/myapp/mycallback">Start SumUp Payment</a>
```

Make sure that the callback URL you provide is correct and controlled by you.

Success:
```
?smp-status=success&smp-message=Transaction%20successful.&smp-receipt-sent=false&smp-tx-code=123ABC
```

Failure:
```
?smp-status=failed&smp-failure-cause=transaction-failed&smp-message=Transaction%20failed.&smp-receipt-sent=false&smp-tx-code=123ABC
```

#III. Additional features

#####1. Include a transaction identifier

When setting up the SumUpPayment object, it is possible to pass an optional foreignTransactionID parameter. This identifier will be associated with the transaction and can be used to retrieve this transaction later. See <a href="https://sumup.com/integration#transactionReportingAPIs" target="_blank">API documentation</a> for details. Please make sure that this ID is unique within the scope of the SumUp merchant account and sub-accounts. It must not be longer than 128 characters.

#####2. Status code
A status code is provided as part of the callback

#####a) With the API Helper

```java
int resultCode = getIntent().getExtras()getInt(SumUpAPI.EXTRA_RESULT_CODE);
```

Possible values are :

* SumUpAPI.TRANSACTION_SUCCESSFUL = 1
* SumUpAPI.ERROR_TRANSACTION_FAILED = 2
* SumUpAPI.ERROR_GEOLOCATION_REQUIRED = 3
* SumUpAPI.ERROR_INVALID_PARAM = 4


#####b) With the URI call / Payment API - Web

* smp-status: `success/failed`
* smp-failure-cause (send it smp-status is `failed`): `transaction-failed/geolocation-required/invalid-param/invalid-token`



1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
21 changes: 21 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
minSdkVersion 15
targetSdkVersion 21
versionCode 3
versionName "1.0"
}
}

dependencies {
compile 'com.android.support:appcompat-v7:22.2.1'

compile 'com.sumup:merchant-api:1.0'


}
43 changes: 43 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sumup.apisampleapp">

<application
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar">

<activity
android:name="com.sumup.apisampleapp.MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name="com.sumup.apisampleapp.ResponseActivity"
android:label="Payment Result">
<intent-filter>
<action android:name="com.sumup.apisampleapp.ResponseActivity"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
<activity
android:name="com.sumup.apisampleapp.URLResponseActivity"
android:label="Payment Result">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<action android:name="com.sumup.apisampleapp.URLResponseActivity"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data
android:scheme="sumupsampleresult"
android:host="result"/>
</intent-filter>

</activity>
</application>
</manifest>
Loading

0 comments on commit 100c18b

Please sign in to comment.