Payment to the user using Paypal and Swift

2

I'm trying to find a day sample code in swift required to perform a payment to the user.

The PayPal development guide does not contain the syntax in swift and every attempt I made trying to translate from other languages was unsuccessful.

    
asked by anonymous 20.06.2016 / 16:10

1 answer

1

According to the PayPal public repository in github you are unable to do Pagamento(Payout) operation directly through the iOS SDK :

  

The SDK supports two use cases for making payments - Single Payment   and Future Payments - and a third case for obtaining information   about the customer - Profile Sharing.

To do this type of operation you will have to implement your backend code using one of the PayPal APIs:

C # | JAVA | Node.js | PHP | Python | Ruby

and then communicate with your backend by the app, for example, using the default REST API

Here's an example of how to use the Ruby API to make a payout:

require 'paypal-sdk-rest'
require 'securerandom'
require './runner.rb'

include PayPal::SDK::REST
include PayPal::SDK::Core::Logging

@payout = Payout.new({
                         :sender_batch_header => {
                             :sender_batch_id => SecureRandom.hex(8),
                             :email_subject => 'You have a Payout!'
                         },
                         :items => [
                             {
                                 :recipient_type => 'EMAIL',
                                 :amount => {
                                     :value => '12.34', # valor com até 2 casas decimais representada como string
                                     :currency => 'USD' # código da moeda de 3 letras
                                 },
                                 :note => 'Thanks for your patronage!', # observação para as notificações. A observação é fornecida pelo emissor do pagamento.
                                 :sender_item_id => '2014031400023', # um número de identificação específico do remetente, pode ser usado em um sistema de contabilidade para fins de rastreamento.
                                 :receiver => '[email protected]' # o recebedor do pagamento.
                             }
                         ]
                     })
begin
  @payout_batch = @payout.create
  logger.info "Created Payout with [#{@payout_batch.batch_header.payout_batch_id}]"
rescue ResourceNotFound => err
  logger.error @payout.error.inspect
end

Remembering: To use Payments, you must request access through your account page. Alternatively, contact your PayPal account manager or Customer Support. You must have a PayPal merchant account.     

20.06.2016 / 22:31