Developer resources

XPR-Rewards Wordpress Plugin

XPR Wordpress payments Name XPR-Rewards Woocommerce Plugin


Description

Use XPR WooCommerce plugin to accept XPR Rewards payments from customers anywhere. Key features: Simple Install4 boxes to change Easy API request from website accounts dashboard Branded with your icon and store name. Customer selects pay with XPR Rewards and enters username and password of account for easy pay.


Installation

This plugin requires WooCommerce. Please make sure you have WooCommerce installed.

  • Get started by signing up for an My xPay account and get 200* of XPR for registering.
  • Download the latest version of the XPR Rewards plugin from the WordPress site.
  • Install the latest version of the XPR Rewards plugin for WooCommerce: Navigate to your WordPress Admin Panel and select Plugins > Add New > Upload Plugin. Select the downloaded plugin and click “Install Now”. Select “Activate Plugin” to complete installation.

Connecting XPR Rewards and WooCommerce

After you have installed the XPR plugin, you can configure the plugin:

  • Create a XPR Rewards account, once logged in, click merchant tab: add your Merchant Title click on merchant logo and add you icon (128x128 72 dpi) be sure to press save copy the merchant API and merchant key other options to give a payment title “XPR Rewards” and a customer message other option is to change to only XPR Rewards currency symbol “Plugins” -> “Settings” -> “General”-> currency options → XPR Rewards
  • Log in to your WordPress admin panel and select “Plugins” -> “Settings” -> “Payments” Find XPR Rewards Payment Method and enable Click “Setup” and enter your API and Secret code in corresponding boxes Press save

Nice work! Your customers will now be able to check out using their XPR wallet on your WordPress, WooCommerce store site.

*200 XPR Rewards in advertising credit



XPR-Rewards_iOS_SDK

XPR Rewards iOS payments library

  • Requirements
  • Installation
  • Usage
  • Callback
  • Signature
  • Currency Rates
  • License

Requirements
  • iOS 9.0+
  • Xcode 10.0+


Installation


Dependency Managers

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate xBit_iOS_SDK into your Xcode project using CocoaPods, specify it in your Podfile:

code source 'https://github.com/CocoaPods/Specs.git'
             platform :ios, '9.0'
             use_frameworks!
             pod 'xBit_iOS_SDK', '~> 0.0.3'

Then, run the following command:

pod install
Carthage

Carthage is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.

You can install Carthage with Homebrew using the following command:

brew update
$ brew install carthage

To integrate XPR_iOS_SDK into your Xcode project using Carthage, specify it in your Cartfile:

github "xcompanies/XPR-iOS-SDK" ~> 0.0.3
Swift Package Manager

To use XPR_iOS_SDK as a Swift Package Manager package just add the following in your Package.swift file.

// swift-tools-version:4.2
import PackageDescription
let package = Package(
  name: "HelloXPR-iOS-SDK",
  dependencies: [
      .package(url: "https://github.com/xcompanies/XPR-iOS-SDK.git", .upToNextMajor(from: "0.0.3"))
  ],
  targets: [
      .target(name: "XPR-iOS-SDK", dependencies: ["XPR-iOS-SDK"])
  ]
)

Manually

If you prefer not to use either of the aforementioned dependency managers, you can integrate XPR_iOS_SDK into your project manually.


Git Submodules
  • Open up Terminal, cd into your top-level project directory, and run the following command "if" your project is not initialized as a git repository:
    $ git init
  • Add XPR_iOS_SDK as a git submodule by running the following command:
    $ git submodule add https://github.com/xcompanies/XPR-iOS-SDK.git
    $ git submodule update --init --recursive
  • Open the new XPR_iOS_SDK folder, and drag the XPR_iOS_SDK.xcodeproj into the Project Navigator of your application's Xcode project.It should appear nested underneath your application's blue project icon. Whether it is above or below all the other Xcode groups does not matter.
  • Select the XPR_iOS_SDK.xcodeproj in the Project Navigator and verify the deployment target matches that of your application target.
  • Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the "Targets" heading in the sidebar.
  • In the tab bar at the top of that window, open the "General" panel.
  • Click on the + button under the "Embedded Binaries" section.
  • You will see two different XPR_iOS_SDK.xcodeproj folders each with two different versions of the XPR_iOS_SDK.framework nested inside a Products folder.It does not matter which Products folder you choose from.
  • Select the XPR_iOS_SDK.framework.
  • And that's it!

The XPR_iOS_SDK.framework is automagically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device.


Embedded Binaries
  • Download the latest release from https://github.com/xcompanies/XPR_iOS_SDK/releases
  • Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the "Targets" heading in the sidebar.
  • In the tab bar at the top of that window, open the "General" panel.
  • Click on the + button under the "Embedded Binaries" section.
  • Add the downloaded XPR_iOS_SDK.framework.
  • And that's it!

Usage

To start accepting payments in XPR you need to create xChange account, configure a Merchant and get your API Key and API Secret. To initiate a payment, you need to import library and call it's method this way to get a payment ViewController. After that you should present it:


import XPR_iOS_SDK

let paymentVC = XPayment.paymentViewControllerWith(
apiKey: "YOUR API KEY",
apiSecret: "YOUR API SECRET",
amount: "5.0", // Amount of XPRs to pay
orderId: "123", // Id of the order to pay for
callbackBaseUrlString: "https://google.com/") // Url of the service that will handle your payment

present(paymentVC, animated: true, completion: nil)

Example project is available at /XPR_iOS_SDK_Test folder of the repository. To test it, clone repository and open XPR_iOS_SDK.xcworkspace fil


Callback

xChange offers a callback service that will notify your system about successful payments and used to mark an order as paid.

The callback service is asynchronous and as such will not interfere with or prolong the processing time of the API request generating a callback - eg. the time your customer will have to wait for payment confirmation.

In the event that your system is not able to receive or correctly process the callback, the callback service will try to deliver its message up to 10 times, with gradually increasing delays between each try.


Callback params:
api_key your Merchant API Key
amount amount in XPR
order_id given Order ID
signature calculated signature for callback validation

Signature

For protocols HTTP and HTTPS it is specified that xChange signs the callback. If the client verifies the signature according to the specified signature method, any data sent with the callback can be used safely. To verify that the values, which you have received in the result URL, are valid and have not been tampered in the process, refer to this examples.

To verify that the values, which you have received in the result URL, are valid and have not been tampered in the process, refer to this examples:


PHP
<?php
class XPRGateway
{
  private $apiKey;
  private $apiSecret;
  private $logger;

  public function processCallback()
  {
      $this->logger->putLog("Callback");
      foreach (["api_key", "amount", "order_id", "signature"] as $name) {
          if (empty($_POST[$name])) {
              $this->logger->putLog("Callback fail. \n" . var_export($_SERVER, 1) . "\n" . var_export($_REQUEST, 1));
              wp_die( 'XPR Request Check Failure', 'XPR payment', array( 'response' => 500 ) );
          }
      }

      if (!$this->checkSignature()) {
          wp_die( 'XPR Request Check Failure', 'XPR payment', array( 'response' => 500 ) );
      }

      $order = wc_get_order($_POST['order_id']);

      if (($total = get_post_meta($_POST['order_id'], "_XPR_total", true)) == $_POST["amount"]) {
          $this->logger->putLog("Everything is OK");
          $order->payment_complete();
      } else {
          $this->logger->putLog("Order Total is $total but amount is $_POST[amount]");
      }
  }

  private function checkSignature()
  {
      $recalculatedSignature = hash("sha256", $this->apiKey . $_POST["order_id"] . sprintf("%.02f", round($_POST["amount"], 2)) . $this->apiSecret);
      if ($recalculatedSignature !== $_POST["signature"]) {
          $this->logger->putLog("Invalid signature\nRecalculated Signature is $recalculatedSignature\nSent signature is $_POST[signature]\n" . var_export($_REQUEST, 1));
          return false;
      }
      return true;
  }
}
?>
Python
from hashlib import sha256

def process_callback(request):
  data = request.POST.dict()
  api_key = 'YourMerchantAPIKey'
  order_id = data.get('order_id')
  amount = data.get('amount')
  api_secret = 'YourMerchantAPISecret'
  sign = '{api_key}{order_id}{amount}{api_secret}'.format(
      api_key=api_key,
      order_id=order_id,
      amount=amount,
      api_secret=api_secret
  )
  signature = sha256(sign.encode('ascii')).hexdigest()

  # compare calculated signature with received from request
  if signature == data.get(signature):
      # callback is authenticated
  else:
      # callback is not authenticated
  ...

Currency rates

You can get XPR rates in JSON format sending GET request to Currency Rates endpoint:
https://myxpay.net/api/v1/XPR_currency_rates/

Response example:

{
"status": 1,
"rates":{
    "EUR": "0.296766823",
    "USD": "0.332283877",
    "GBP": "0.256415435",
    "BTC": "0.000080135",
    "ETH": "0.002346883"
  }
}

Contributing

Issues and pull requests are welcome!


Author

xGroup


License

XPR_iOS_SDK is released under the MIT license. See LICENSE for details.



xPay-Platform-SDK

  • Usage
  • API Reference
  • Request
  • Signature
  • Response

Usage

The xPay SDK Platform is used to withdraw users' funds from the platform to their xPay wallets. To start sending commission payments from the platform, you should request your Platform Keys from an administrator.Users sign up on the platform and add their xpay wallet address in the profile settings. The platform must use Myxpay API to send withdrawal requests.


API Reference

MyXPay API is organized around REST. Our API has predictable resource-oriented URLs, returns JSON-encoded responses.


Request

Create Withdraw Request:
Param Description
URL https://myxpay.net/api/v2/platform/withdraw/
Method POST
Content-Type application/json
Request Data Params:
Param Description
api_key your Platform API Key
username User phone number
amount amount in xPay with cents
signature calculated signature for callback validation
description optional operation description (doesn't appear in the signature)
currency optional currency code. "EUR" by default. Available currencies: USD, GBP, EUR' (doesn't appear in the signature)
Request example:
curl --header "Content-Type: application/json" \
--request POST \
--data '{"api_key":"1555830491-J64JlACG5Fnpl2o5L19hxb-FpGJdbmJ","username":"+38988888888","amount":"12.65","signature":"ab4fd93ec144dc7545908c4b9710f96c0833f5f5d035fd99958e30c77af58d72","description":"optional"}' \
https://myxpay.net/api/v2/platform/withdraw/

Signature

The platform needs to sign requests according to the specified signature method. Any data sent in this way can be used safely. To verify sent withdrawal requests, API validates the signature on the backend. To create a signature, follow this example:


Python 3
# to create signature join api_key, username, amount and api_secret and make sha256 hash

from hashlib import sha256
api_key = "Your Platform API Key"
username = "User phone number"
amount = "xPay amount with two digits"
api_secret = "Your Platform Secret Key"
raw_sign = f"{api_key}{username}{amount}{api_secret}"
signature = sha256(raw_sign.encode('ascii')).hexdigest()
print(signature)
PHP
<?php
// to create signature join api_key, username, amount and api_secret and make sha256 hash

$apiKey = "Your Platform API Key";
$username = "User phone number";
$amount = "xPay amount with two digits";
$apiSecret = "Your Platform Secret Key";
$calculatedSignature = hash("sha256", $apiKey . $userWallet . sprintf("%.02f", round($amount, 2)) . $apiSecret);
echo $calculatedSignature;

Response

API response consists of status and error, if it exists. The following responses are available:

Status Response
Success {'status': 1, 'withdraw_id': '44'}
Error {'status': 0, 'error': 'Wrong signature'}
Error {'status': 0, 'error': 'Wrong API KEY - platform not found'}
Error {'status': 0, 'error': 'Wrong username - wallet not found'}
Error {'status': 0, 'error': 'Wrong amount format'}
Error {'status': 0, 'error': 'Wrong currency code. Available currencies: USD, GBP, EUR'}


XPR-Android-SDK

XPR Android payments library

  • Requirements
  • Installation
  • Usage
  • Callback
  • Signature
  • Currency Rates
  • License

Requirements
  • Android SDK 21+
  • Android Studio 2.3.2+

Installation


Dependency Managers

JitPack

JitPack is a novel package repository for JVM and Android projects. It builds Git projects on demand and provides you with ready-to-use artifacts.

Add this lines to build.gradle (Project level):

allprojects {
  repositories {
      maven { url 'https://jitpack.io' }
  }
}
      

Add this lines to build.gradle (App level):

dependencies {
  implementation 'com.github.xcompanies:XPR-Android-SDK:1.0.3'
}

Or you can use this library together with:


Maven
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.xcompanies</groupId>
<artifactId>XPR-Android-SDK</artifactId>
<version>1.0.3</version>
</dependency>
      
Sbt
resolvers += "jitpack" at "https://jitpack.io"
libraryDependencies += "com.github.xcompanies" % "XPR-Android-SDK" % "1.0.3"

Manually


JAR file

Add the compiled AAR (or JAR) file (the library must be already built):

  • Click File > New > New Module.
  • Click Import .JAR/.AAR Package then click Next.
  • Enter the location of the compiled AAR or JAR file then click Finish.

Source code

Import the library module to your project (the library source becomes part of your project):

  • Click File > New > Import Module.
  • Enter the location of the library module directory then click Finish.

The library module is copied to your project, so you can actually edit the library code. If you want to maintain a single version of the library code, then this is probably not what you want and you should instead add the compiled AAR file as described above.


Usage

To start accepting payments in XPR you need to create xChange account, configure a Merchant and get your API Key and API Secret. To initiate a payment, you need to import library and call it's method this way to get Activity with payment View. After that you should present it:


Java
import com.XPRcrypto.sdk.PaymentFormCreator;

public class MainActivity extends AppCompatActivity {

  @Override
  protected void onCreate(@Nullable Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      PaymentFormCreator.INSTANCE.runPaymentForm(
          this,
          "API KEY", //todo put your api key here
          "API SECRET", //todo put your api secret here
          1.0, // Amount of XPRs to pay
          "order ID", // Id of the order to pay for
          "http://google.com"); // Url of the service that will handle your payment
  }
}
      
Kotlin
import com.XPRcrypto.sdk.PaymentFormCreator

class MainActivity : AppCompatActivity() {

  override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      PaymentFormCreator.runPaymentForm(
          this,
          "API KEY", //todo put your api key here
          "API SECRET", //todo put your api secret here
          1.0, // Amount of XPRs to pay
          "order ID", // Id of the order to pay for
          "http://google.com") // Url of the service that will handle your payment
  }
}

Example project is available at /app folder of the repository. To test it, clone repository and open it in Android Studio


Callback

xChange offers a callback service that will notify your system about successfull payments and used to mark an order as paid.

The callback service is asynchronous and as such will not interfer with or prolong the processing time of the API request generating a callback - eg. the time your customer will have to wait for payment confirmation.

In the event that your system is not able to receive or correctly process the callback, the callback service will try to deliver its message up to 10 times, with gradually increasing delays between each try.

Callback params
api_key your Merchant API Key
amount amount in XPR
order_id given Order ID
signature calculated signature for callback validation

Signature

For protocols HTTP and HTTPS it is specified that xChange signs the callback. If the client verifies the signature according to the specified signature method, any data sent with the callback can be used safely. To verify that the values, which you have received in the result URL, are valid and have not been tampered in the process, refer to this examples.

To verify that the values, which you have received in the result URL, are valid and have not been tampered in the process, refer to this examples:


PHP
<?php
class XPRGateway
{
  private $apiKey;
  private $apiSecret;
  private $logger;

  public function processCallback()
  {
      $this->logger->putLog("Callback");
      foreach (["api_key", "amount", "order_id", "signature"] as $name) {
          if (empty($_POST[$name])) {
              $this->logger->putLog("Callback fail. \n" . var_export($_SERVER, 1) . "\n" . var_export($_REQUEST, 1));
              wp_die( 'XPR Request Check Failure', 'XPR payment', array( 'response' => 500 ) );
          }
      }

      if (!$this->checkSignature()) {
          wp_die( 'XPR Request Check Failure', 'XPR payment', array( 'response' => 500 ) );
      }

      $order = wc_get_order($_POST['order_id']);

      if (($total = get_post_meta($_POST['order_id'], "_XPR_total", true)) == $_POST["amount"]) {
          $this->logger->putLog("Everything is OK");
          $order->payment_complete();
      } else {
          $this->logger->putLog("Order Total is $total but amount is $_POST[amount]");
      }
  }

  private function checkSignature()
  {
      $recalculatedSignature = hash("sha256", $this->apiKey . $_POST["order_id"] . sprintf("%.02f", round($_POST["amount"], 2)) . $this->apiSecret);
      if ($recalculatedSignature !== $_POST["signature"]) {
          $this->logger->putLog("Invalid signature\nRecalculated Signature is $recalculatedSignature\nSent signature is $_POST[signature]\n" . var_export($_REQUEST, 1));
          return false;
      }
      return true;
  }
}
?>
      
Python
from hashlib import sha256

def process_callback(request):
  data = request.POST.dict()
  api_key = 'YourMerchantAPIKey'
  order_id = data.get('order_id')
  amount = data.get('amount')
  api_secret = 'YourMerchantAPISecret'
  sign = '{api_key}{order_id}{amount}{api_secret}'.format(
      api_key=api_key,
      order_id=order_id,
      amount=amount,
      api_secret=api_secret
  )
  signature = sha256(sign.encode('ascii')).hexdigest()

  # compare calculated signature with received from request
  if signature == data.get(signature):
      # callback is authenticated
  else:
      # callback is not authenticated
  ...
      

Currency rates

You can get XPR rates in JSON format sending GET request to Currency Rates endpoint:
https://myxpay.net/api/v1/XPR_currency_rates/

Response example:

{
"status": 1,
"rates":{
    "EUR": "0.296766823",
    "USD": "0.332283877",
    "GBP": "0.256415435",
    "BTC": "0.000080135",
    "ETH": "0.002346883"
  }
}
      
Contributing

Issues and pull requests are welcome!


Author

xCompanies


License

XPR_iOS_SDK is released under the MIT license. See LICENSEfor details.



Stage Demo

Staging Account Demo Access


User
  • Select United States
  • User Number 3055551212
  • Requires Pin (777555)